How to Handle an Intent Not Recognized

The steps described in this article make reference to the subscription of MQTT topics on your action code. The same operation can be handled in Android or iOS, please check the Dialogue API Reference to see how to handle it for these platforms.

By default, the Snips platform terminates the dialogue session when an intent is not recognized. You may want to handle differently the behaviour of your assistant when this occurs. There are two strategies you could use:

  1. Fetch the error message on dialogue termination

  2. Overwrite the default behaviour when starting a session

This article will guide you through the necessary steps to apply the proposed strategies.

You may want to build or refresh your understanding on how sessions work on the platform before continuing by:

  1. Reading the Sessions article

  2. Checking the relevant topics and events described in the Session article in the Hermes Reference and the Dialogue API Reference.

Fetch the error message on dialogue termination

As mentioned before, the default behaviour of the Snips platform is to terminate the dialogue session once an intent not recognized is detected. The termination type that causes the session to end can be accessed if you are subscribed to the Session Ended MQTT topic.

You can take advantage of the way this is handled by doing the following in your action code:

  1. Subscribe to Session Ended MQTT topic

  2. Parse Session Ended messages and access the termination key in the payload

  3. If intentNotRecognized is present on the value of the termination key, handle a new interaction with the user. You could start a new session asking the user to reiterate their request or whatever other strategy that suits your context.

Make sure to not to have conflicts if you have multiple apps in your assistant as any could be handling the steps described.

Overwrite the default behaviour when starting a session

The default setup of the platform when starting a session is to not to send a message to the platform if an intent is not recognized. Luckily, this behaviour can be overwritten so the platform sends messages when an intent is not recognized.

To overwrite the default behaviour you need to: 1. Set the flag sendIntentNotRecognized to true when starting or continuing a session programmatically with action code using Start Session or Continue Session respectively. 2. Be subscribed to the Intent Not Recognized MQTT topic to start listening for messages. 3. Once a new Intent Not Recognized message is received, handle it the way you prefer.

Step 1 could be executed right after a push-to-talk action has been performed.

As you can't set parameters to the Start Session sent by the wake word (after "Hey Snips"), currently you can't expect to receive a sendIntentNotRecognized for the interaction following the wake word.

A work around is to subscribe to Session Started and directly close the current session to then send a Start Session with sendIntentNotRecognized set to true.

Make sure that there won't be any conflicts between apps as any app could register to this intent.