单击轮播项目后如何触发意图?
How to trigger intent after clicking on carousel item?
这让我很困惑。所以,我有以下包含三个项目的轮播:
//This is my test Carousel
function googleAssistantOther1(agent){
let conv = agent.conv();
conv.ask('Please choose an item');
conv.ask(new Carousel({
title: `All Items`,
items: {
'WorksWithGoogleAssistantItemKey1':{
title: `My Message`,
description: `No description required`,
image:{
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item1`,
},
},
'GoogleHomeItemKey1': {
title: `Test1`,
description: `blah blah`,
image: {
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item2`,
},
},
'SomeRandomKey1':{
title: `Test2`,
description: `blah blah blah`,
image: {
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item3`,
},
},
},
}));
// Add Actions on Goole responses to your agent's response
agent.add(conv);
}
当我在 Actions on Google Simulator 中测试它时,它运行良好。但是,当我单击轮播项目(比如第一个)时,它不会触发与标题关联的意图。例如,在模拟器中,如果我键入 "My message" 将触发意图,但是当我单击具有相同标题 "My message" 的轮播项目时,会发生以下情况:
所以我的问题是如何通过单击轮播项目来触发 "My message" 意图。任何解决方案或建议将不胜感激。
点击列表轮播卡片(或项目)时,它会生成一个事件,该事件将触发您的 webhook,这与简单的文本消息不同。
第一种方式(如果您的 webhook 处理响应)
所以你需要在你的代码中处理它。
一般情况下,应该有intent
和actions_intent_OPTION
。从那里你需要隔离它。
第二种方式(如果您的代码未处理响应)
这样,您的意图必须能够处理由轮播(或列表)生成的 actions_intent_OPTION
事件。
为此,您的意图需要添加事件,如下图所示(基本上它告诉对话流,无论何时触发 actions_intent_OPTION
事件,此意图都能够处理它,但目前在您的情况下,没有任何意图与描述相符,它将转到默认后备意图)
因此只要点击列表项,它就可以处理流程。
这让我很困惑。所以,我有以下包含三个项目的轮播:
//This is my test Carousel
function googleAssistantOther1(agent){
let conv = agent.conv();
conv.ask('Please choose an item');
conv.ask(new Carousel({
title: `All Items`,
items: {
'WorksWithGoogleAssistantItemKey1':{
title: `My Message`,
description: `No description required`,
image:{
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item1`,
},
},
'GoogleHomeItemKey1': {
title: `Test1`,
description: `blah blah`,
image: {
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item2`,
},
},
'SomeRandomKey1':{
title: `Test2`,
description: `blah blah blah`,
image: {
url: 'https://i.imgur.com/sdUL0T7.png',
accessibilityText: `item3`,
},
},
},
}));
// Add Actions on Goole responses to your agent's response
agent.add(conv);
}
当我在 Actions on Google Simulator 中测试它时,它运行良好。但是,当我单击轮播项目(比如第一个)时,它不会触发与标题关联的意图。例如,在模拟器中,如果我键入 "My message" 将触发意图,但是当我单击具有相同标题 "My message" 的轮播项目时,会发生以下情况:
所以我的问题是如何通过单击轮播项目来触发 "My message" 意图。任何解决方案或建议将不胜感激。
点击列表轮播卡片(或项目)时,它会生成一个事件,该事件将触发您的 webhook,这与简单的文本消息不同。
第一种方式(如果您的 webhook 处理响应)
所以你需要在你的代码中处理它。
一般情况下,应该有intent
和actions_intent_OPTION
。从那里你需要隔离它。
第二种方式(如果您的代码未处理响应)
这样,您的意图必须能够处理由轮播(或列表)生成的 actions_intent_OPTION
事件。
为此,您的意图需要添加事件,如下图所示(基本上它告诉对话流,无论何时触发 actions_intent_OPTION
事件,此意图都能够处理它,但目前在您的情况下,没有任何意图与描述相符,它将转到默认后备意图)
因此只要点击列表项,它就可以处理流程。