The <Switch/> Element

This element permits to execute conditional code based on the value of an expression.

It is equivalent to the switch statement in programming languages.

Element Attributes

Attribute Name Description Allowed Values Default Value
expr expression to be evaluated and matched. See expressions non-empty string none

Example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<IVR>
  <GetDigits retries="3" validDigits="012" numDigits="1">
    <Speak voice="en-US-Standard-C">Press 1 to talk with Sales. Press 2 to talk with Support</Speak>
  </GetDigits>
  <Switch expr="Digits">
    <Case val="1">
      <Transfer>Sales</Transfer>
    </Case>
    <Case val="2">
      <Transfer>Support</Transfer>
    </Case>
    <Default>
      <Speak voice="en-US-Standard-C">Bye.</Speak>
    </Default>
  </Switch>
</IVR>