我正在尝试创建一个侦听用户回复的技能。出于某种原因,我不能总是抓住用户回复。
New chat session started
intents
我的设置中的某些内容是错误的。我相信代码没问题,所以可能exports.handler = (event, context) =>
{
// if the session is old,
if (event.session.new === false) {
// get the user reply
// this doesn't seem to allways work
var userReply = event.request.intent.slots.Reply.value;
}
try {
switch (event.request.type) {
case "LaunchRequest":
// do nothing here
break;
case "IntentRequest":
switch (event.request.intent.name) {
case "ChatSession":
// the chat session starts, when I say: Alexa, open MyApp and start chat.
// this works, and the session seems to remain open, because Alexa waits for me to say something else
alexaReplyes({noCard: true, noNewSession: true, reply: 'New chat session started'});
break;
default:
throw "Invalid intent"
}
break;
case "SessionEndedRequest":
// do nothing here
break;
default:
context.fail(`INVALID REQUEST TYPE`)
}
} catch (error) {
context.fail(`Exception: ${error}`)
}
}
设置错误
代码很简单。
{
"intents": [
{
"intent": "ChatSession",
"slots": [
{
"name": "Reply",
"type": "REPLIES"
}
]
}
]
}
ChatSession start chat
{{1}}
答案 0 :(得分:0)
是的,意图设置不正确。几件事:
1)您需要在话语中包含插槽,例如:
ChatSession start chat {Reply}
2)为你期望用户说话的方式添加更多话语是有意义的,例如:
ChatSession Yes {Reply}
希望有所帮助!
答案 1 :(得分:0)
我明白了。
_logger = {
'/routeA': _logger(name: 'routeA'),
'/routeB': _logger(name: 'routeB')
}