Context Passing

NLP engines (like dialogflow) only store the sender context for a limited amount of time. The following guide will show you how to store the context on Rocketbots for advance contextual awareness.

Trigger different intents based on user's value for a custom field

Let's say there's a custom field called "Employee Type" which can have two type of values i.e. Office and Retail.

For each type of value, you will have to define an intent with the appropriate input context defined. For example, the input context for retail would be rb-employee_type-retail. Notice that this format has three parts: the prefix (rb), the custom field (normalized), and the value (normalized).

Input contexts are passed by the platform with each query, and they determine which intent(s) to trigger. Generally speaking, if a context is set then priority is given to those intents which have that context defined as input. Also, when a specific context is not set, then intents having that context as input are never triggered.

Now, we also need to define a third default intent which won't have any input context. This is triggered for those users who have different value for the custom field (other than office or retail), or for whom the custom field has no value provided at all.

Please note that the output context can be left as empty.

In summary, for Employee Type (employee_type) custom field having 2 type of values, we'll have at least 3 intents of each type with the following input contexts defined respectively:

  • rb-employee_type-retail (with all intents that deal with Retail Employees)

  • rb-employee_type-office (with all intents that deal with Office Employees)

  • [no context] (default)