The <Set/> Element
This element sets a variable var to a value val or result of an expression evaluation
The variables can be interpolated in text for element Speak.
They can also be used with the <Switch/> element.
They will be informed in subsequent HTTP XML requests.
Element Attributes
| Attribute Name | Description | Allowed Values | Default Value |
|---|---|---|---|
| var | name of the variable to be set | non-empty string | none |
| val | value | any string | none |
| expr | an expression to be evaluated to generated the value for the var. See expressions | a string | none |
Either val or expr must be present.
Examples
Example 1: using val
1 2 3 4 |
<IVR> <Set var="amount" val="1234"/> <Speak voice="en-US-Standard-C">Hello, you have {{amount}} dollars in your account.</Speak> </IVR> |
Since in the above XML there is nothing else to be done, if notification of CallStatus=completed is enabled, you will receive a request containing this: Direction=inbound&To=05011112222From=090111122226&CallerName=09011112222&DomainName=brs.basix.ne.jp&CallUUID=c58ae32a-6f19-47ba-a402-6f3d031cb1ab&CallStatus=completed&var_amount=1234
Example 2: using expr
1 2 3 4 5 |
<IVR> <GetJSON var="user" url="https://somewhere.com/get_user?phone={{CallingNumber}}"/> <Set var="discount" expr="user.balance * 0.2"/> <Speak voice="en-US-Standard-C">Your discount will be {{discount}} dollars</Speak> </IVR> |
Obs: the above is just for illustration purposes as usually, the back-end server called by GetJSON would return de value of discount directly
