我在Alexa技能中使用自定义插槽 . 我创建了一个插槽名为pName作为插槽名称,插槽类型为 ProductName . 当我在打开我的技能后调用我的意图时,它总是进入未处理的输入 . 我已经关注创建自定义插槽的文档,但仍未取得成功 . 例如,我的样本话语如下:我有一个意图名称OnHandQuantityIntent with sample ltterance on hand stock for item
User input : 项目xyz234 Alexa response : 在未处理的意图内的库存 .
型号:
{
"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 .
2 回答
它进入
Unhandled
因为AMAZON.FallbackIntent
没有意图处理程序 . 并且提到的用户输入正在触发此意图,最终为"Unhandled" .Abbreviations and numbers in Slot values
当你处理像AT或ATZ或XYZ这样的缩写时,你必须像这样给出插槽值 . (尝试提供更多变化)
在Test Simulator中测试它时,请使用像
通过您的交互模型和我提到的更改,我得到了一个针对上述话语生成的请求
此外,将调用名称从
ebs
更改为e. b. s.
是个好主意让我们假设我必须输入用户的产品 . 所以产品是我的插槽,productType将是我的插槽类型 .
这应该工作 .
在您的情况下,我猜您需要为您的ProductName添加字母数字的样本值 . 那肯定会奏效 . 祝一切顺利 .