google 动作:使用动作 sdk 的对话退出不会调用 actions.intent.CANCEL
google actions: conversation exit using actions sdk does not invoke actions.intent.CANCEL
我正在使用操作 SDK 来构建履行。我正在使用 Google 函数。我在 action.json
中有以下内容
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "App"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
. . .
]
}
}
}
],
"conversations": {
"App": {
"name": " ... ",
"url": " ...",
"fulfillmentApiVersion": 2
}
},
"locale": "en"
}
在函数代码中,我注意到当用户说/键入 exit
或 Goodbye
时,不会调用 actions.intent.CANCEL
的自定义意图代码。在模拟器中只出现 <earcon>
。 JS代码如下:
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Welcome to ...');
});
app.intent('actions.intent.TEXT', (conv, input) => {
// the main logic of the application is here
});
app.intent('actions.intent.CANCEL', (conv) => {
conv.close(`Okay, let's try this again later.`);
// this code does not get called
});
要在 action.json 中设置一些内容才能使取消意图生效
是的,您需要 add something 您的 action.json 才能向您发送取消意向。在您现有的 conversations
对象中,添加一个 inDialogIntents
属性,其中包含一个对象数组,给出了 CANCEL Intent 的名称。像这样:
"conversations": {
"App": {
"name": "...",
"url": "...",
"fulfillmentApiVersion": 2
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
}
]
}
}
我正在使用操作 SDK 来构建履行。我正在使用 Google 函数。我在 action.json
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "App"
},
"intent": {
"name": "actions.intent.MAIN",
"trigger": {
"queryPatterns": [
. . .
]
}
}
}
],
"conversations": {
"App": {
"name": " ... ",
"url": " ...",
"fulfillmentApiVersion": 2
}
},
"locale": "en"
}
在函数代码中,我注意到当用户说/键入 exit
或 Goodbye
时,不会调用 actions.intent.CANCEL
的自定义意图代码。在模拟器中只出现 <earcon>
。 JS代码如下:
app.intent('actions.intent.MAIN', (conv) => {
conv.ask('Welcome to ...');
});
app.intent('actions.intent.TEXT', (conv, input) => {
// the main logic of the application is here
});
app.intent('actions.intent.CANCEL', (conv) => {
conv.close(`Okay, let's try this again later.`);
// this code does not get called
});
要在 action.json 中设置一些内容才能使取消意图生效
是的,您需要 add something 您的 action.json 才能向您发送取消意向。在您现有的 conversations
对象中,添加一个 inDialogIntents
属性,其中包含一个对象数组,给出了 CANCEL Intent 的名称。像这样:
"conversations": {
"App": {
"name": "...",
"url": "...",
"fulfillmentApiVersion": 2
"inDialogIntents": [
{
"name": "actions.intent.CANCEL"
}
]
}
}