<Do>
The <Do>
conditional allows you to implement Do/While style looping.
<Do>
Attributes
<Do>
supports the following attributes that change its behavior:
Attribute | Allowed Values | Default Value |
---|---|---|
expression | string expression to evaluate | none |
maxLoops | integer > 0 | 1 |
expression
The expression
attribute accepts a string of conditionals to evaluate. If the expression
evaluates to true
, then all verbs nested inside <Do>
are executed. Otherwise, the nested verbs are ignored and the next VoXML instruction is executed.
maxLoops
The maxLoops
attributes sets the maximum number of loops to execute before exiting the <Do>
loop.
<Do>
Examples
Simple Usage
Prompt the caller up to 3 times to enter DTMF 1 or 2.
<Response>
<Do expression="${menu.digits}!~(1|2)" maxLoops="3">
<Gather input="dtmf" output="menu">
<Say>Hello. Press 1 to speak with support or 2 to speak with sales.</Say>
</Gather>
</Do>
</Response>
Advanced Usage
Welcome the caller and transfer them to multiple agents. Kill the call at the 1hr mark.
<Response>
<Say>Hello. Please stay on the line while I transfer you to an agent.</Say>
<Dial timeout="30" timeLimit="3600">
<Number>13003003000</Number>
<Number>13003003001</Number>
<Number>13003003002</Number>
</Dial>
</Response>