If

Definition

The contents within this tag will execute if the variable value is equal to the result of the expression.

Value

The contents within this tag are more nodes to execute. This tag can also contain an "else" tag.

Attributes

Attribute Required Values Description
name N any text A unique name for the tag
loggingEnabled Y any text A JavaScript expression to evaluate. Examples = " '${call.lastinput}' + ' 2 3'" or "1+2" or "${call.lastinput} + 10"

Examples

This gives the user three attempts to press the correct button, then it ends the call.

<dialplan name="Root">
    <setvar varname="Counter">0</setvar>
        <menu name="Menu" maxdigits="1" timeout="3500">
            <play type="tts">This is the play tag.  Press 1 for more information.</play>
            <keypress pressed="1">
                <play type="tts">Nice job pressing one!</play>
                <hangup>
                </hangup>
            </keypress>
            <keypress name="keypress" pressed="timeout">
                <setvar varname="Counter">${Counter}+1</setvar>
                <if expr="${Counter} > 2">
                    <play type="tts">Too many mistakes.  Bye for now!</play>
                    <hangup name="hangup">
                    </hangup>
                </if>
                <play type="tts">Oh dear.  You are taking a long time.  Try again.</play>
                <goto>Menu</goto>
            </keypress>
        </menu>
</dialplan>