Skip to main content

timeout

This tag sets a timeout — an automatic transition to another state if there is no input from the user.

Syntax

timeout: /Start/Timeout || interval = 10
timeout: ./Timeout || interval = "10 seconds"

The tag is followed by the path to the state where the bot will switch to if there is no user input during the specified time.

The tag has one required parameter, interval — the time interval during which input from the user is expected.

Interval format

The value of interval can be either a number or a string.

  • As a number, it means the timeout duration in seconds.
  • As a string, it signifies the timeout duration in human-readable format.

An interval cannot exceed 99 hours.

String values of interval must be matched by the following regular expression:

(\s*(?<h>\d{0,2})\s*(hours|hour|h))?(\s*(?<m>\d{0,2})\s*(minutes|minute|min|m))?(\s*(?<s>\d{0,2})\s*(seconds|second|sec|s))?\s*
Examples of interval string values
  • 5 seconds
  • 1 sec
  • 3s
  • 1 min
  • 1 minute
  • 10 minutes
  • 1 hour
  • 10 hours
  • 3 min 1 sec
  • 1h5m3s

Usage details

Only one timeout can be active at a time. If the tag is user multiple times in the same state, the script will produce an error.

How to use

In the following example, the bot asks the user to rate the service.

  • If the user gives a rating, the bot records it to analytics using the $analytics.setNps method and says goodbye.
  • If the user fails to give a rating for 5 minutes, the bot gives up waiting and proceeds to say goodbye by its own.
state: ServiceEvaluation
a: Thank you for your time. How would you rate your experience with us?
timeout: /Goodbye || interval = "5 minutes"

state: GetEvaluation
q: $regex<\d+>
a: Thank you. Your opinion is very important to us.
script: $analytics.setNps(parseInt($parseTree.text));
go!: /Goodbye

state: Goodbye
a: Take care and goodbye!