我在Alexa技能中使用自定义插槽。我创建了一个插槽名为pName作为插槽名称,插槽类型为ProductName。当我在打开我的技能后调用我的意图时,它总是进入未处理的输入。我已经关注创建自定义插槽的文档,但仍未取得成功。例如,我的样本话语如下:我有一个意图名称OnHandQuantityIntent with item stock for item stock for item {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。
它进入Unhandled
因为AMAZON.FallbackIntent
没有意图处理程序。并且提到的用户输入触发了此意图,最终称为“未处理”。
Slot值中的缩写和数字
当你处理像AT或ATZ或XYZ这样的缩写时,你必须像这样给出插槽值。 (尝试提供更多变化)
x. y. z. two four seven nine
A. T. Z. one two three four
A. T. two three eight zero eight
在Test Simulator中测试它时,请使用像
在项目x的库存中询问ebs演示。年。 ž。五三七
通过您的交互模型和我提到的更改,我得到了一个针对上述话语生成的请求
"intent": {
"name": "OnHandQuantityDemoIntent",
"confirmationStatus": "NONE",
"slots": {
"PName": {
"name": "PName",
"value": "XYZ537",
...
此外,将调用名称从ebs
更改为e. b. s.
是个好主意
让我们假设我必须输入用户的产品。所以产品是我的插槽,productType将是我的插槽类型。
Slot Types: productType
Values: washing machine.
product is of type: ProductType
Sample Utterance: My {product} is not working.
User input: My washing machine is not working.
这应该工作。
在您的情况下,我猜您需要为您的ProductName添加字母数字的样本值。那肯定会奏效。祝一切顺利。