Skip to main content

<If>

The <If> conditional allows you to implement If/Then style conditionals.

<If> Attributes

<If> supports the following attributes that change its behavior:

AttributeAllowed ValuesDefault Value
expressionstring expression to evaluatenone

expression

The expression attribute accepts a string of conditionals to evaluate. If the expression evaluates to true, then all verbs nested inside <If> are executed. Otherwise, the nested verbs are ignored and the next VoXML instruction is executed.

<If> Examples

Simple Usage

Welcome the caller, transcribe input, and evaluate response.

<Response>
<Gather input="speech" output="menu">
<Say>Hello. What is the purpose of your call?</Say>
</Gather>
<If expression="${menu.speech}=~'(support|sales)'">
<Say>Transfering you to support or sales.</Say>
</If>
</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>