我在 Alexa 技能中使用自定义插槽。我创建了一个插槽,其中 pName 为插槽名称,插槽类型为ProductName。当我在打开我的技能后调用我的意图时,它总是会进入未处理的输入。我已按照文档创建自定义插槽,但仍未成功。例如// 我的示例话语如下:我有一个意图名称 OnHandQuantityIntent,其中包含 项目 {pName} 的现有库存示例话语
用户输入:项目 xyz234 的现有库存 Alexa 响应:内部未处理的意图。
模型 :
{
"interactionModel": {
"languageModel": {
"invocationName": "ebs demo",
"intents": [
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "OnHandQuantityDemoIntent",
"slots": [
{
"name": "PName",
"type": "Product_Type"
}
],
"samples": [
"Onhand quantity {PName}",
"get onhand quantity for item {PName}",
"provide me onhand quantity for {PName}"
]
}
],
"types": [
{
"name": "Product_Type",
"values": [
{
"id": "AT23808",
"name": {
"value": "AT23808",
"synonyms": [
"at23808",
"AT23808"
]
}
}
]
}
]
}
}
}
这是我的 alexa.js 函数
'use strict';
const Alexa = require('alexa-sdk');
const APP_ID = undefined;
const SKILL_NAME = 'DemoForDirectCall';
const GET_ITEM_MESSAGE = "ITEM DETAIL: ";
const HELP_MESSAGE = 'WE can get real time on hand quantity for Product';
const HELP_REPROMPT = 'What can I help you with?';
const STOP_MESSAGE = 'Goodbye!';
const handlers = {
'LaunchRequest': function () {
this.response.speak("Welcome to Demo for direct call");
this.response.shouldEndSession(false);
this.emit(':responseReady');
},
'OnHandQuantityDemoIntent': function () {
console.log(JSON.stringify(this.event.request));
var productName = "NONE";
var intent = this.event.request.intent;
if(!intent.slots.PName)
productName = intent.slots.PName.value;
const speechOutput = "You have entered "+productName;
this.response.speak(speechOutput);
this.emit(':responseReady');
},
'AMAZON.HelpIntent': function () {
const speechOutput = HELP_MESSAGE;
const reprompt = HELP_REPROMPT;
this.response.speak(speechOutput).listen(reprompt);
this.emit(':responseReady');
},
'AMAZON.CancelIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'AMAZON.StopIntent': function () {
this.response.speak(STOP_MESSAGE);
this.emit(':responseReady');
},
'Unhandled': function () {
console.log("Inside unhandled Intent");
this.response.speak("Inside Unhandled Intent");
this.emit(':responseReady');
},
};
exports.handler = function (event, context, callback) {
const alexa = Alexa.handler(event, context, callback);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};
用户输入:打开带有欢迎消息的 ebs 演示 Alexa 响应用户输入:项目 AT23808 Alexa 响应的现有数量:内部未处理的 Intnet。