Teneo Developers

Prompt Triggers

Trigger Flows with script expressions

Thanks to Dialogue Continuation Prompt Triggers, the conversational AI application is able to show initiative and be more proactive. Prompt Triggers can, for example, be used for providing addition information related to the user's query, for promoting events or campaigns, or to add a sentence such as Can I help you with anything else? to the answer.

From a technical point of view, Prompt Triggers are script triggers that are tested when the Flow stack becomes empty. That is to say, when the last active Flow ends and the conversational AI application has nothing else to process. So, a Prompt Trigger is not activated based on user input, but on the programmatic condition set by the user; the language used for this in the Teneo Platform is Groovy.

The Prompt Trigger will be triggered by the script expression in the Trigger, and can be used to ensure that the Flow is only executed under certain circumstances: when a Global Variable has a certain value, when another Flow has completed, when the dialogue length is greater than a certain value, when the current date is within a specific date range, etc. If wanting the Flow to always be considered, enter the word true in the expression field.


Consider the following example:

User: Do you sell dog food?
AI app: I am sorry, I am afraid I don't know much about dogs.

If at this point the Flow stack is empty, the Prompt Triggers are tested in order. The first one that satisfies all conditions will trigger the corresponding flow.

Imagine for example, having a Boolean Global Variable named bAnimalsMentioned that was set to true by the Do you sell dog food? Flow triggered above. This could help to trigger a Prompt Trigger Flow telling the user about offers for a new pet insurance scheme.

It is possible, though not very common, to use Prompt Triggers together with Intent Triggers to bring up a Flow promptly or through user input.

The answer

The answer given in the triggered Flow is concatenated with the answer from the last Flow which has just exited, so a single response is given:

I am sorry, I am afraid I don't know much about dogs.
Would you like to know about our available pet insurance scheme?

The first sentence in the above answer comes from the originally triggered Flow, whereas the second is from the triggered Prompt Trigger Flow.

Another simple example could consist of making the conversational AI application add the text How can I help you? at the end of a response.

Other examples

  • Would you like to participate in a quick survey? This could be set to trigger "once per session" with the following expression _.dialogHistoryLength>=5 (meaning this Trigger will only be considered for execution when at least 5 transactions have taken place between the application and an end user).
  • Would you like to know about our available pet insurance scheme? This could be set to "once per session" with an expression checking for a topic or Boolean Global Variable.
  • What else can I do for you? This could be set to "always" and bring back the default prompt.

Groovy in Teneo Studio
Scripts in Prompt Triggers
Stack of active Flows