错误:TypeError:handlerInput.serviceClientFactory.getReminderManagementServiceClient不是函数

时间:2019-03-23 17:52:01

标签: alexa-skills-kit

我正在尝试在Alexa中创建一个提醒,以在x分钟内提醒我,但是即使我检查了索引文件并更新了SDK,也始终无法获得getReminderManagementServiceClient的功能。

const client = handlerInput.serviceClientFactory.getReminderManagementServiceClient();

var date = new Date();

var timestamp = date.getTime();

const reminderRequest = {
    "trigger": {
      "type" : "SCHEDULED_RELATIVE",
        "offsetInSeconds" : "30"
            },
                "alertInfo": {
                    "spokenInfo": {
                        "content": [{
                            "locale": event.request.locale,
                            //"locale": "en-US",
                            "text": `The price of ${companyName} now is ${latestPrice}`
                        }]
                    }
                },
                "pushNotification" : {
                    "status" : "ENABLED"
                }
       }
      const reminderResponse = await client.createReminder(reminderRequest);
      console.log(JSON.stringify(reminderResponse));

error: TypeError: handlerInput.serviceClientFactory.getReminderManagementServiceClient is not a function

1 个答案:

答案 0 :(得分:0)

您的回答帮助了我。我需要更新SDK。为了使它正常工作,我还必须做一些事情。也许这可以帮助您

您使用ask-sdk-core吗?

const Alexa = require('ask-sdk-core');

您有.withApiClient(new Alexa.DefaultApiClient())吗? https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues/356

const skillBuilder = Alexa.SkillBuilders.custom();
exports.handler = skillBuilder
    .addRequestHandlers(...)
    .withApiClient(new Alexa.DefaultApiClient())
    .withSkillId(...)
    .lambda();

祝你好运!