alexa - Alexa Skills - 如何从另一个意图返回具有槽值的意图?
问题描述
如何从另一个意图返回具有槽值的意图?
我想通过在另一个意图中返回它的槽值来触发一个意图。
这是我的 JSON 文件的示例:
{
"interactionModel": {
"languageModel": {
"invocationName": "movie antakshari",
"intents": [
{
"name": "SchoolIntent",
"slots": [
{
"name": "Subject",
"type": "subjects"
}
],
"samples": ["{subjects}"]
},
{
"name": "teachersIntent",
"slots": [],
"samples": ["teachers"]
},
],
"types": [
{
"name": "subjects",
"values": [
{
"name": {"value": "maths"}
},
{
"name": {"value": "english"}
}
]
}
]
}
}
}
这是我的 index.js 文件:
const teacherIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'teacherIntent';
},
handle(handlerInput) {
if (some condition) {
// Here I want to return the schoolIntentHandler with a slot value maths
}
}
}
解决方案
意图调用由用户话语驱动。用户必须说些什么,这样 Alexa 服务才能将用户所说的内容与模型中的意图相匹配。
在您的情况下,您需要通过正确引导用户来让用户调用 schoolIntent。即你需要从这里返回一个演讲,让用户说出符合 schoolIntent 的内容
handle(handlerInput) {
if (some condition) {
// Here I want to return the schoolIntentHandler with a slot value maths
//
// You need to return a speech from here that will make user to utter something that matches schoolIntent.
}
}
推荐阅读
- apache-spark - 在火花中优先分区/任务执行
- apache-spark - TensorflowOnSaprk 应用程序卡在 fit_generator() 后跟 predict_generator()
- c# - 将阿拉伯文本编码为十六进制格式
- html - 中心数字输入,就好像没有箭头一样
- php - 如何使用 shieldUI 上传器和 php 实际上传和删除文件?
- sharepoint-2013 - 将本地 SharePoint 报表集成到 Power BI 报表服务器
- javascript - Angular 中 tsconfig.json 文件中的 lib 数组中的 dom 是什么?
- git - git pull / stash 与 git 过滤器冲突
- javascript - 在 Javascript onClick 方法中嵌套 PHP 变量
- javascript - 如何获取从哪个拖动开始的父级的 ID?jQuery 用户界面