Docs »

Bots »

Interactions »

Prompts »


You can validate a user’s response to a prompt by running multiple tests using bot scripting.

Any output from this template is considered to be an error that will be displayed to the user.

Cerb will take care of automatically repeating your prompt for you until valid input is given.

When the template returns no output, the response is considered to be valid and Cerb will save it to your placeholder.

Validate a date

{% set ts = message|date('U') %}
{% if 0 == ts %}
Please enter a valid date. For instance, "Friday noon".
{% elseif ts < 'now'|date('U') %}
Please enter a date in the future.
{% endif %}

Validate a number within a range

{% if message is not numeric %}
Please enter a valid number.
{% elseif message < 1 or message > 100 %}
The number must be between 1 and 100.
{% endif %}

Validate an email address

{% set email = message|parse_emails|first %}
{% if message is empty %}
Please enter an email address.
{% elseif == 'localhost' %}
Please enter a valid email address.
{% endif %}