aws-lambda - 在我的 Launch 请求之后,试图让 Alexa 听取我的回复
问题描述
我对开发 Alexa 技能非常陌生,我正在尝试编写一个简单的 lambda 函数,让 Alexa 询问我想知道哪一天,当我说出我的意图时,它会给我一个回应。
该技能正常工作,问题是在我说“打开调用名称”之后,它给了我启动请求响应,但当我说出我的意图时不听我的响应。
例如,如果我说 Alexa,打开我的技能,它会给我一个启动功能,上面写着“嗨,欢迎来到我的课堂技能。你想知道哪一天?” 但是当我说我的话语来启动我的意图功能时,alexa 没有做任何事情。
如果我说“打开我的技能并说”我星期一的课是什么“它会起作用,但前提是我先说“打开我的技能”。
我必须为 Alexa 编写一个监听函数来确认她的问题并倾听我的意图吗?
/* eslint-disable func-names */
/* eslint quote-props: ["error", "consistent"]*/
'use strict';
const Alexa = require('alexa-sdk');
const handlers = {
'LaunchRequest': function () {
this.emit('Launch');
},
'MondayIntent': function () {
this.emit('Monday');
},
'TuesdayIntent': function () {
this.emit('Tuesday');
},
'Launch': function() {
this.response.speak("Hi, Welcome to the my classes skill. What day would you like to know about?");
this.emit(':responseReady');
},
'Monday': function() {
this.response.speak("On Monday you have User Experience at 4:00pm.");
this.emit(':responseReady');
},
'Tuesday': function() {
this.response.speak("On Tuesday you have Integrative business Apps at 12:30pm.");
this.emit(':responseReady');
},
'Unhandled': function() {
this.response.speak("Sorry, Please say a day of the week?");
this.emit(':responseReady');
}
};
exports.handler = function (event, context) {
const alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
解决方案
您的问题是您准备好返回响应。您的启动请求应该是
'LaunchRequest': function () {
this.emit(':ask', "Hi, Welcome to the my classes skill. What day would you like to know about?");
},
也许还考虑到您在项目中使用 alexa-sdk 库,您查看文档:https ://www.npmjs.com/package/alexa-sdk#basic-project-structure提供了对结构的真正有用的理解对于这个应用程序。
推荐阅读
- python - 多线程请求并连接到 DataFrame
- python - 哪个python3返回全局python二进制而不是虚拟环境
- python - Traceback(最近一次调用最后一次):在 python 中
- java - 用括号括起来的对象
- swift - 在 macOS Monterey 及更高版本中检测 MacBook 缺口
- java - 无法使用 Jackson 解析简单的空 JSON 数组
- python - 使用 pandas 数据框中的条形图绘制子图
- php - 函数数组列的替代
- javascript - 弹出模型未在 for 循环中打开 (HTML)
- javascript - 为什么异步等待返回一个承诺?