Responding to DTMFs in CCXML

Blueworx Voice Response usually processes DTMFs using a VoiceXML dialog. Sometimes it can be useful to handle them on the CCXML level, whether the application calls for processing when connected to two endpoints rather than a dialog or a persistent monitoring of DTMFs is required when switching VXML dialogs.

To generate events in CCXML when a DTMF is detected, you will need to edit the Blueworx Voice Response configuration file at /opt/blueworx/vr/config/machine-name/bvr.config and go to the [ccxml] section:

[ccxml]
   cache_size = 16777216
   ccx_min_threads = 5
   ccx_max_threads = 600
   connection_signal = true

Ensure that the connection_signal and [ccxml] lines are not commented out with #, and that connection_signal is set to true.

When a DTMF is pressed on a call, a connection.signal event will be generated, with the connectionidi> and dtmf properties set to determine the call in question and the DTMF key pressed.

With the connection.signal event being generated, you are free to program any response that you wish in your CCXML document. An example ccxml document can be viewed at /opt/blueworx/vr/sample/ccxml/dtmf_example.ccxml, the connection.signal transition replicated for convenience here:

    <transition event="connection.signal">
        <log expr="'dtmf_example [' + event$.name + '] for connection ' + event$.connectionid + ', DTMF ' + event$.dtmf"/>
        <if cond="(lastDTMF === '*') || (lastDTMF === '#')">
            <log expr="'dtmf_example [' + event$.name + '] Good last character'"/>
            <if cond="event$.dtmf === '7'">
                <log expr="'dtmf_example [' + event$.name + '] Starting dialog'"/>
                <dialogstart src="'file:///opt/blueworx/vr/sample/Welcome.vxml'" connectionid="incomingCall"/>
            </if>
        </if>
        <assign name="lastDTMF" expr="event$.dtmf"/>
    </transition>

The above CCXML will wait until it sees the sequence *7 in the dtmfs pressed, starting up a VoiceXML dialog once the pattern is observed.

Note that DTMFs that are being processed by VoiceXML will also be reported in connection.signal events, so your application should be coded to act appropriately to that.