The <If/>
Element
This element permits flow control based on result of an expression evaluation.
Element Attributes
Attribute Name |
Description |
Allowed Values |
Default Value |
expr |
expression to be evaluated. If it evaluates to True then the child element <Then/> is executed. If it evaluates to False and a child element <Else/> is present, it will be executed instead. See expressions |
non-empty string |
none |
Example 1: <If/>
with <Then/>
and <Else/>
1
2
3
4
5
6
7
8
9
10
11
|
<IVR>
<GetJSON var="data" url="https://somewhere.com/get_account?phone_number={{CallingNumber}}"/>
<If expr="data.balance > 100">
<Then>
<Transfer>promotion</Transfer>
</Then>
<Else>
<Speak voice="en-US-Standard-C">Sorry, you don't have enough credit in your account.</Speak>
</Else>
</If>
</IVR>
|
Example 2: No <Else/>
1
2
3
4
5
6
7
8
9
|
<IVR>
<GetJSON var="data" url="https://somewhere.com/get_account?phone_number={{CallingNumber}}"/>
<If expr="data.balance > 100">
<Then>
<Transfer>promotion</Transfer>
</Then>
</If>
<Speak voice="en-US-Standard-C">Sorry, you don't have enough credit in your account.</Speak>
</IVR>
|