Gray_Rhino
Gray_Rhino

Reputation: 1303

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. 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: enter image description here
So my question is how can I trigger "My message" intent by clicking on carousel item. Any solution or suggestion would be appreciated.

Upvotes: 0

Views: 172

Answers (1)

Jay Patel
Jay Patel

Reputation: 2451

When a list carousel card(or item) is tapped, it generates an event that will hit your webhook, unlike the simple text message.

1st way (if your webhook handling the response)

So you need to handle it in your code.

Generally, it should have intent as 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).

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) enter image description here

So whenever the list item tapped it can handle the flow.

For more refer this documentation.

Upvotes: 2

Related Questions