messageKeypress

The messageKeypress Rule will catch input from the caller's phone keypad and allow different routes to be taken in the Call Flow

Structure

The different parts of this rules are:

  • Play: We had a look at this in the Play Rule in this documentation.
  • eventHandler: This is the element which will handle the different events in a messageKeypress Rule.
    • keyEvent: This is the keypress event we want to capture  e.g. caller presses '1' on their phone keypad
    • failure: This is the capture event if the keypress is not in the list of keypress events.This rule has two types of messages:
      • onNoKeypress: If the caller did not press any key after the specified timeout
      • onUnmatchedKeypress: If the Keypress is does not match a value specified in the rest of the keyPress events
<messageKeypress id="messageKeypress_1" label="Keypress Menu" captureKeypress="false" timeout="10">
    <play id="play_0" label="PLAY">
        <!-- messageParts -->
    </play>
     <eventHandlers>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="1">
            <!-- Rules -->
        </keyEvent>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="2">
        <!-- Rules -->
        </keyEvent>
        <failure id="failure_1" label="Failure" attempts="3">
            <keypressFailureMessages>
                <keypressFailureMessage behaviour="onNoKeypress">
                    <!-- messageParts -->
                </keypressFailureMessage>
                <keypressFailureMessage behaviour="onUnmatchedKeypress">
                    <!-- messageParts -->
                </keypressFailureMessage>
            </keypressFailureMessages>
            <!-- Rules -->
        </failure>
     </eventHandlers>
 </messageKeypress>

Examples

Basic keypress Rule with two options

Imagine if you have Support Team and Sales Team, so you will make a call to Support if you press 1, or to the Sales team if you press 2. In order to make the outbound call in this example we are using the Call Rule. Please have a look at it before this example if you have not read it yet.

<messageKeypress id="messageKeypress_1" label="Keypress Menu" captureKeypress="false" timeout="10">
    <play id="_play_0" label="">
        <soundFile soundLabel="Option 1 Support Option 2 Sales"/>
    </play>
     <eventHandlers>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="1">
            <call id="call_1" label="Call" sendCallAlert="NONE" record="false" destinationPhoneNumber="442033468855" destinationContactName="Support Team"></call>
        </keyEvent>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="2">
            <call id="call_1" label="Call" sendCallAlert="NONE" record="false" destinationPhoneNumber="442033468666" destinationContactName="Sales Team"></call>
        </keyEvent>
     </eventHandlers>
 </messageKeypress>

Keypress Rule with a Failure message

The previous example does not define what will happen if the caller presses something other than '1' or '2'.  In order to control this we have the failure rule. By using this we can control what happens if the caller presses an incorrect option, or no keypress at all. In the instance of such an error the CallFlow will attempt to get the correct input again x times, as defined by the 'attempts' parameter of the failure rule. Following the 'attempts' being exceeded, the flow will continue in the rules after the failure messages. In this instance it will send the caller to a voicemail rule.

<messageKeypress id="messageKeypress_1" label="Keypress Menu" captureKeypress="false" timeout="10">
    <play id="_play_0" label="">
        <soundFile soundLabel="Option 1 Support Option 2 Sales"/>
    </play>
    <eventHandlers>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="1">
        <call id="call_1" label="Call" record="false" sendCallAlert="NONE" destinationPhoneNumber="442033468855" destinationContactName="Support Team"></call>
        </keyEvent>
        <keyEvent action="onMatchKeypressSequence" keypressSequence="2">
            <call id="call_2" label="Call" record="false" sendCallAlert="NONE" destinationPhoneNumber="442033468666" destinationContactName="Sales Team"></call>
        </keyEvent>
        <failure id="failure_1" label="Failure" attempts="3">
            <keypressFailureMessages>
                <keypressFailureMessage behaviour="onNoKeypress">
                    <soundFile soundLabel="You did not pressed anything"/>
                </keypressFailureMessage>
                <keypressFailureMessage behaviour="onUnmatchedKeypress">
                    <soundFile soundLabel="Wrong key pressed"/>
                </keypressFailureMessage>
            </keypressFailureMessages>
            <voicemail id="voicemail_1" label="Voicemail" from="noreply@voxanalytics.com" fromName="IOVOX Team" subject="You have a Voicemail" silence="2" maxDuration="300" templateName="basicTemplate" destinationEmailAddress="business@iovox.com" destinationContactId="1">
                <voicemailMessage>
                    <soundFile soundLabel="Welcome to my Voicemail!"/>
                </voicemailMessage>
            </voicemail>
        </failure>
    </eventHandlers>
</messageKeypress>

Result

Error Result

HTTP CodeError StringResolution
400Rule ID Empty Set the value of the id attribute
400Rule Label Empty Set the value of the label attribute
400Rule ID Not Unique in Message Keypress RuleThe value of the id attribute is used for an other rule, change it to be unique
400Attribute captureKeypress needs to be either true or false Correct attribute captureKeypress with the values TRUE or FALSE
400Timeout Empty Set the value for Timeout attribute
400Timeout Not a NumberSet the Timeout as a numeric value
400maxDigits Empty Set the value for maxDigits attribute
400maxDigits Not a NumberSet the maxDigits as a numeric value
400Sound File Variable need to be set in Play RuleSet the required Sound File for the variable needed
400Sound File x of y Does not exist in Play RuleCorrect the Sound Label or the Sound Group for that file
400Action EmptySet the attribute Action
400Action InvalidThe Action set is not valid in the Key Event
400Keypress EmptySet the attribute Keypress
400Keypress_value Invalid KeypressThe Keypress value is invalid
400Duplicate ITEM_1 ReceivedThe Value Result is duplicated in the Key Events