简体   繁体   English

单击轮播项目后如何触发意图?

[英]How to trigger intent after clicking on carousel item?

This is something that is confusing me.这是让我困惑的事情。 So, I have the following carousel with three items:所以,我有以下三个项目的轮播:

 //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); }

When I test it in Actions on Google Simulator, it is working perfectly. 当我在 Google Simulator 上的 Actions 中对其进行测试时,它运行良好。 However, when I click on the carousel item (say first one) it does not trigger the intent associated with the title. 但是,当我单击轮播项目(比如第一个)时,它不会触发与标题相关联的意图。 For example, in Simulator if I type "My message" the intent will be triggered but when I click on the carousel item with the same title "My message" the following happens: 例如,在模拟器中,如果我输入“我的消息”,意图将被触发,但是当我单击具有相同标题“我的消息”的轮播项目时,会发生以下情况: 在此处输入图片说明
So my question is how can I trigger "My message" intent by clicking on carousel item. 所以我的问题是如何通过单击轮播项目来触发“我的消息”意图。 Any solution or suggestion would be appreciated. 任何解决方案或建议将不胜感激。

When a list carousel card(or item) is tapped, it generates an event that will hit your webhook, unlike the simple text message.与简单的文本消息不同,当点击列表轮播卡片(或项目)时,它会生成一个将点击您的 webhook 的事件。

1st way (if your webhook handling the response)第一种方式(如果您的 webhook 处理响应)

So you need to handle it in your code.所以你需要在你的代码中处理它。

Generally, it should have intent as actions_intent_OPTION .通常,它的intent应该是actions_intent_OPTION from there you need to segregate it.从那里你需要隔离它。

2nd way (if your code is not handling the response)第二种方式(如果您的代码未处理响应)

In this way, your intent must be able to handle actions_intent_OPTION event generated by the carousel(or list).这样,您的意图必须能够处理由轮播(或列表)生成的actions_intent_OPTION事件。

for that, your intent need to add the event as shown in below image (Basically it tells the dialogflow that whenever the actions_intent_OPTION events triggered, this intent is capable to handle it, but currently in your case, no intent matches the description and it's going to Default Fallback Intent)为此,您的意图需要添加如下图所示的事件(基本上它告诉对话流,每当触发actions_intent_OPTION事件时,该意图都能够处理它,但目前在您的情况下,没有意图与描述相匹配,它将继续默认回退意图) 在此处输入图片说明

So whenever the list item tapped it can handle the flow.因此,无论何时点击列表项,它都可以处理流程。

For more refer this documentation.有关更多信息,请参阅此文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM