Prompts

Prompts are blocks in the conversation flow used to receive user input. Each prompt is consist of a message (e.g. How old are you?) and expects an answer with a certain structure (e.g. an Integer between 18-120). If the user input is invalid, users will be prompted until they a valid answer is received, or they will be redirected to a fallback logic if defined.

Use Prompts when you need the user inputs.

Validation and Fallback

When prompts are triggered, they first present the user with one or more messages. This will be usually a question followed by instruction for the user about the expected response.

Upon reply, the response will be validated. If the response is valid on_complete will be triggered. Otherwise, the user will be prompted again until it replies with . You can control how many tries users can have before they are redirected to a fallback flow by setting the attempts property, for example:

{
"identifer": "get_email",
"type": "prompt",
"prompt_type": "email",
"attempts": 3,
"fallback": {
"go_to": "registration_fails"
}
}

In the above example, we ask the users for a valid email. If an invalid email was provided 3 times, they will be redirected to a "registration_fails", which can be some message or any other logic.

Examples

Prompt Text

This is the very basic prompt. When triggered, a message will be presented to the user, expecting the input to be text. Any input that include text is valid.

{
"identifer": "ask_name"
"type": "prompt",
"prompt_type": "text",
"messages": ["What is your name?"]
}

On a valid response, the conversation state will be update with the key ask_age.textto include the user answer.

Prompt Number

Use this when numeric input is expected from the user. Default is that any number (not only integers) are valid. Use min max and step parameters to configure the desired input structure from the user.

{
"identifer": "ask_age"
"type": "prompt",
"prompt_type": "number",
"min": 18,
"max": 120,
"step": 1,
"messages": ["What old are you?"]
}

Prompt Choice

Prompt Choice used when users need to select an option out of a predefined short list of options, In rich-UI platforms such as Messenger or Telegram, the options are rendered as Buttons for easier interaction with the users.

{
"identifer": "select_prefered_color"
"type": "prompt",
"prompt_type": "choice",
"choices": [
{"title": "Red"},
{"title": "Green"},
{"title": "Blue"}
],
"messages": ["What is your favorite color?"]
}

Branching the conversation flow

Sometimes you want to continue the conversation flow depending on the users selection