Dialogflow CX - Handle user matching same intent twice in a row for all intents

I’m trying to set up a structure for the following situation;

  1. User matches to an intent

  2. Bot gives response, and flow ends.

  3. User matches to the same intent

  4. Bot detects same intent twice in a row and either acknowledges this, then waits for another input, or sends to another page / flow, which then resets this count (so if user matches to the same intent a third time, it lets them through.

I’m hoping to do this without webhooks if possible, but if a webhook is the only way, then advice on how to use that approach would be great. I’ve attempted some logic with routes on my “intent routing” page (which is on my start page) such as a condition for currentIntent = lastIntent (where I set current intent on entry to an intent, and on exit back from the intents flow, set lastIntent to current intent, then wait again) but having some issues, which may be due to where I’m doing checks or how routes and route groups work together.

Any help appreciated or high level structure on how to achieve this.

1 Like

Hi @Bharr You can do this without a webhook by using session parameters.

Create a session parameter like last_intent and optionally repeat_count. On each intent route, first check a condition such as $session.params.last_intent = intent.displayName. If true, route to a page that handles the repeated intent case. If false, continue normally.

In the intent fulfillment, set last_intent = intent.displayName and increment or reset repeat_count as needed. When a different intent is matched, reset the counter.

This way you can detect consecutive matches and control the behavior entirely within CX using conditional routes.

Hi @a_aleinikov . I got a similar answer when I was searching, but intent.displayName isnt a parameter that seems to exist natively. so I can’t use it, unless I’m missing something.

The only way I found that you can reference an intent that has been matched without creating a parameter for it is via webhook, But, if you create the intent parameter on the route, lastIntent and currentIntent will always be true when you return to the router. The workaround here is to set it on start page to the flow pointed at by the intent, and then have a second route to the same intent that checks for currentIntent and lastIntent matching, but this requires every page in the build to have currentIntent setting and lastIntent setting.

I was looking at whether I can use two intent “route” pages to get around this but having issues with it still always matching, or not matching ever.

The hope is to be able to handle this in a single flow or at a global level without disrupting the journey unless repeat is picked up, but allow for user to route past repeat check via a choice.