Skip to main content

Prompt Triggers

Prompt Triggers are used to execute Flows when certain circumstances are met, e.g. when a Global Variable has a certain value or when another Flow has completed.

The pages in this section provide information about the various aspects of Prompt Triggers:

Concept

Sometimes we want our bot to give some extra information that the user did not explicitly request, such as special deals, promotions and more. We can accomplish this by using Prompt Triggers.

Prompt Triggers do not make use of match requirements, but are executed only in specific circumstances, for example, when a Global Variable has a certain value or when another Flow has completed. A Prompt Trigger may also be executed when the dialogue length is greater than a certain value or the current date within a specific date range.

The circumstances that trigger a Prompt Trigger are defined by Groovy script expressions which are tested when the flow stack becomes empty, i.e. when the last active Flow is dropped and the bot has nothing else to process. If a Prompt Trigger matches, the Flow containing this trigger will be executed and the resulting output will be added to the response.

info

Intent Triggers are triggered by Matches in the user input, whereas Prompt Triggers are triggered by external circumstances.

Prompt Flows

A Prompt Flow refers to any Flow that contains a Prompt Trigger. It can be created by...

  • opening a new Prompt Flow, which automatically adds a Prompt Trigger to the beginning.

  • simply adding a Prompt Trigger to a regular Flow after its creation.

Please see the UI section to learn more about how Prompt Flows and Prompt Triggers are added.

Prompt Trigger Ordering

To control the order in which Prompt Triggers are tested in a solution, read more about Trigger Ordering.

note

Prompt Trigger ordering is only available in Teneo Studio Desktop.

How To

Create Prompt Flow

To create a Prompt Flow in Studio Desktop, follow the below steps:

  1. In the top ribbon of the Home tab, click the lower part of the Flow button.
  2. Select Prompt Flow.
  3. The new Prompt Flow window opens on the Properties tab in the backstage, add the Name of the Prompt Flow.
  4. Optionally, add a Description and/or a Resume Prompt.
  5. Click the green Play icon or the back arrow in the top, left corner to go to the main Flow window.
  6. Select the Prompt Trigger, add the Expression in the right-side panel, optionally give the Prompt Trigger a Name and Description.
  7. Select the Output node, add the wanted Answer, optionally, add a Name, Description and Output Hyperlink.
  8. Remember to Save the Prompt Flow to conserve the modifications.
tip

If the Flow should always be considered, write the word true in the expression field.

NEW PROMPT FLOW

The new Prompt Flow is automatically opened in edit mode and contains a Prompt Trigger and a Bot Output node as placeholders for development of the new Prompt Flow.

Add Prompt Trigger

With the Flow open, follow the below steps:

  1. Click the Plus icon available before the raise label and select Add Prompt. Alternatively, in the Flow's top ribbon, click Add Prompt.

desktop-plus-icon

  1. Next, select the Prompt Trigger in the Flow editor.
    • Optionally, give it a Name.
    • Write a Description in the right-side panel.
  2. Under Expression, add the script expression (Groovy).
  3. Under Triggering, select an order groups.
  4. In the Advanced Options section, specify if the Prompt Trigger should be Matched only once per session or potentially always*.
  5. Under Metadata, click Add to add Metadata definitions.
  6. Select the Output node and enter relevant details.
  7. Remember to Save the Flow to preserve the modifications.
OVERTRIGGERING

When always is selected, the Flow may be triggered every time that the flow stack is empty in all sessions.

AVOID OVERTRIGGERING

If you want a Prompt Trigger to execute more than once per session (but not all the time) untick the Matched only once per session option in the trigger's configuration panel and use programmatic or Flow logic to control how often the Prompt Trigger is fired per session. See the Practical Examples section for an example.

Edit Prompt Trigger

With the Flow open, follow the below steps:

  1. Select the Prompt Trigger in the Flow editor, this will open the right-side Prompt Trigger panel. If the panel does not open automatically, click Prompt Trigger in the right side of the Flow window.
  2. Now, edit the wanted properties.
  3. Remember to Save the Flow to preserve the changes.

Delete Prompt Trigger

With the Flow open, follow the below steps:

  1. Select the Prompt Trigger in the Flow editor.
  2. In the top ribbon, click Delete.
  3. Remember to Save the Flow to preserve the changes.

UI

Icons

IconDescriptionVisualizationRelated Pages
prompt triggerPrompt Trigger in the Flow.A configuration panel opens on the right; please see Prompt Trigger.Prompt Trigger
prompt triggerAdds Prompt Trigger in Flow.prompt triggerPrompt Trigger
prompt triggerOpens ordering for Prompt Triggersprompt triggerTrigger Ordering
Prompt Trigger Ordering
media/create prompt flow.pngCreates a Prompt Flow.prompt triggerFlows
Prompt Flow

Prompt Flow

media/prompt-trigger-properties.png

SectionDescription
NameAdds a name for easy identification of the Flow.
DescriptionAdds a description of the Flow.
Flow LocationFolder where the Flow is saved.
Resume PromptGiven when a user returns to a Flow after discussing something else. Reminds the user what they were discussing with the bot.

Prompt Trigger

prompt trigger desktop
SectionDescription
Prompt TriggerAdds a name and description for the Prompt Trigger.
ExpressionGroovy script expressions which are tested when the flow stack becomes empty.
Open With...Opens an external code editor.

Practical Examples

Use a Prompt Trigger

In our example, we are developing a solution for a fictional coffee shop. In the example below, the first part of the bot's answer comes from a Flow handling user requests to order a coffee, while the second part, in italics, comes from a Flow with a Prompt Trigger:

User: Could I get a large macchiato?

Bot: Ok, a large macchiato will be ready for pickup in 5 minutes. It is cookie hour right now! You’ll get a free cookie to go along with your coffee.

This Prompt Trigger is designed to only match during a certain time of day. We can implement this by doing the following:

  1. Create a new Prompt Flow called Cookie hour campaign using the Flow dropdown menu in the ribbon bar.

  2. In the output node, paste the following: "It is cookie hour right now! You’ll get a free cookie to go along with your coffee."

  3. In the Prompt Trigger, paste the following script:

    // get the hour of the day
    def currentHour = java.time.LocalDateTime.now().getHour()
    // is it cookie hour?
    (currentHour == 16)
  4. Save the Flow.

final_flow_desktop

When interacting with the bot in Tryout between 16:00 and 17:00, the Prompt Flow's output answer text will be added to the bot output.