Skip to content

Instantly share code, notes, and snippets.

@johntdyer
Created June 10, 2010 17:42
Show Gist options
  • Save johntdyer/433341 to your computer and use it in GitHub Desktop.
Save johntdyer/433341 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<ccxml xmlns="http://www.w3.org/2002/09/ccxml"; xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml"; version="1.0">
<var name="state0" expr="'init'"/>
<var name="call_0"/>
<var name="playMsg"/>
<var name="param1" expr="session.values.param1"/>
<var name="param2" expr="session.values.param2"/>
<var name="param3" expr="session.values.param3"/>
<var name="param4" expr="session.values.param4"/>
<var name="param5" expr="session.values.param5"/>
<var name="sessionID" expr="session.id"/>
<!-- CALLER ID-->
<var name="callerid" expr="14075551212"/>
<!-- -->
<var name="status" expr="'unknown'"/>
<var name="callDuration" expr="0"/>
<var name="callStartTime" expr="new Date().getTime()"/>
<var name="callEndTime" expr="new Date().getTime()"/>
<var name="hasCpa" expr="false"/>
<var name="hasSentDuration" expr="false"/>
<var name="hasSentConnect" expr="false"/>
<var name="message_Dlg"/>
<var name="dlgStatus" expr="'stopped'"/>
<var name="dlgPrepared" expr="false"/>
<var name="detectedMachine" expr="false"/>
<var name="restartMsg" expr="false"/>
<var name="forcedDlgExit" expr="false"/>
<var name="voxeo_cpa_result" expr="'human'"/>
<var name="filename"/>
<eventprocessor statevariable="state0">
<transition state="init" event="ccxml.loaded">
<createcall dest="session.values.numberToDial" timeout="'60000ms'" voxeo-cpa-runtime="'60000'" voxeo-cpa-maxtime="'3200'" voxeo-cpa-maxsilence="'1000'" voxeo-cpa-maskevent="'human,machinedetected,machine,beepdetected,beep,modem,faxtone,sit'" voxeo-cpa-maskstop="'modem,faxtone,sit'" connectionid="call_0" callerid="callerid"/>
</transition>
<transition event="connection.connected">
<log expr="'@@@ CALL CONNECTED @@@ '"/>
<log expr="'@@@ CALL CONNECTED -- WAITING FOR CPA @@@ '"/>
<assign name="filename" expr="event$.connection._RecordCall(100,'TestRecording')"/>
<send name="'playMsg'" target="session.id"/>
<assign name="status" expr="'connected'"/>
<assign name="hasCpa" expr="false"/>
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</transition>
<transition event="connection.failed">
<log expr="'@@@ CALL FAILED [' + event$.connectionid + '] @@@ '"/>
<log expr="'@@@ REASON [' + event$.reason + '] @@@ '"/>
<assign name="state0" expr="'connectionfailed'"/>
<if cond="event$.reason == 'busy'">
<assign name="status" expr="'busy'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
<elseif cond="event$.reason == 'badnumber'"/>
<assign name="status" expr="'intercept'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
<elseif cond="event$.reason == 'rejected'"/>
<assign name="status" expr="'intercept'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
<elseif cond="event$.reason == 'timeout'"/>
<assign name="status" expr="'no_answer'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
<elseif cond="event$.reason == 'unknown'"/>
<assign name="status" expr="'intercept'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
<elseif cond="event$.reason == 'unreachable'"/>
<assign name="status" expr="'intercept'"/>
<if cond="hasSentConnect == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
</if>
</if>
</transition>
<transition state="connectionfailed" event="send.successful">
<log expr="'@@@ CONNECTION FAILED AFTER SEND.SUCCESSFUL @@@ '"/>
<exit/>
</transition>
<transition event="voxeo.cpa.result" cond="event$.type == 'beepdetected'">
<log expr="'@@@ CPA SAYS [' + event$.type + '] @@@ '"/>
<assign name="hasCpa" expr="true"/>
<var name="voxeo_cpa_result" expr="event$.type"/>
<if cond="detectedMachine == true &amp;&amp; dlgStatus == 'started'">
<log expr="'@@@ MACHINE PREVIOUSLY DETECTED / DIALOG CURRENTLY STARTED -- STOP MESSAGE @@@ '"/>
<assign name="restartMsg" expr="true"/>
<send name="'stopMsg'" target="session.id"/>
<elseif cond="detectedMachine == true"/>
<log expr="'@@@ NO DIALOG CURRENTLY STARTED -- EVENT IGNORED @@@ '"/>
<else/>
<log expr="'@@@ MACHINE WAS NOT PREVIOUSLY DETECTED -- EVENT IGNORED @@@ '"/>
</if>
</transition>
<transition event="voxeo.cpa.result" cond="event$.type == 'machinedetected'">
<log expr="'@@@ CPA SAYS [' + event$.type + '] @@@ '"/>
<assign name="hasCpa" expr="true"/>
<assign name="detectedMachine" expr="true"/>
<if cond="dlgStatus == 'started'">
<log expr="'@@@ DIALOG CURRENTLY STARTED -- STOP MESSAGE @@@ '"/>
<assign name="restartMsg" expr="false"/>
<send name="'stopMsg'" target="session.id"/>
<else/>
<log expr="'@@@ NO DIALOG CURRENTLY STARTED -- WAIT FOR NEXT CPA EVENT @@@ '"/>
</if>
</transition>
<transition event="voxeo.cpa.result" cond="event$.type == 'machine' || event$.type == 'beep'">
<log expr="'@@@ CPA SAYS [' + event$.type + '] @@@ '"/>
<assign name="hasCpa" expr="true"/>
<script>
// machine has been detected
// lower min duration monotonous signal needed for beep detection
// this allows less stringent and faster delivery of beepdetected event
session.connections[call_0]._CPA.Beep.ontime = 1;
</script>
<assign name="detectedMachine" expr="true"/>
<assign name="restartMsg" expr="true"/>
<assign name="voxeo_cpa_result" expr="event$.type"/>
<if cond="dlgStatus == 'started'">
<log expr="'@@@ DIALOG CURRENTLY STARTED -- STOP MESSAGE @@@ '"/>
<send name="'stopMsg'" target="session.id"/>
<elseif cond="dlgStatus == 'pending_start'"/>
<log expr="'@@@ DIALOG PENDING START -- WAIT FOR MESSAGE @@@ '"/>
<else/>
<log expr="'@@@ NO DIALOG CURRENTLY STARTED -- PLAY MESSAGE @@@ '"/>
<assign name="dlgStatus" expr="'pending_start'"/>
<send name="'playMsg'" target="session.id"/>
</if>
</transition>
<transition event="voxeo.cpa.result" cond="event$.type == 'modem' || event$.type == 'faxtone' || event$.type == 'sit' || event$.type == 'unknown'">
<log expr="'@@@ CPA EVENT [' + event$.type + '] DETECTED -- EXIT @@@ '"/>
<exit/>
</transition>
<transition event="voxeo.cpa.result" cond="event$.type == 'human'">
<log expr="'@@@ CPA EVENT [' + event$.type + '] IGNORED @@@ '"/>
</transition>
<transition event="dialog.exit" cond="forcedDlgExit == true">
<log expr="'@@@ DIALOG EXITED @@@ '"/>
<assign name="dlgStatus" expr="'stopped'"/>
<assign name="dlgPrepared" expr="false"/>
<if cond="restartMsg == true">
<log expr="'@@@ DELAYED MESSAGE RESTART @@@ '"/>
<assign name="dlgStatus" expr="'pending_start'"/>
<send name="'playMsg'" target="session.id" delay="'1000ms'"/>
<elseif cond="restartMsg == false"/>
<log expr="'@@@ WAIT FOR NEXT CPA EVENT @@@ '"/>
</if>
</transition>
<transition event="dialog.exit" cond="forcedDlgExit == false">
<log expr="'@@@ MESSAGE COMPLETE -- EXIT @@@ '"/>
<assign name="callEndTime" expr="new Date().getTime()"/>
<assign name="callDuration" expr="callEndTime-callStartTime"/>
<assign name="state0" expr="'dialogexited'"/>
<assign name="status" expr="'duration'"/>
<if cond="hasSentDuration == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
<assign name="hasSentDuration" expr="true"/>
<else/>
<exit/>
</if>
</transition>
<transition state="dialogexited" event="send.successful">
<exit/>
</transition>
<transition event="playMsg" cond="dlgStatus == 'started'">
<log expr="'@@@ DIALOG ALREADY STARTED -- playMsg EVENT IGNORED @@@ '"/>
</transition>
<transition event="playMsg">
<assign name="forcedDlgExit" expr="false"/>
<assign name="dlgStatus" expr="'started'"/>
<dialogstart src="'http://evodesigner-speech-dev.voxeo.com/SpeechRuntime/route.speech?vr.application.id=13817'"; type="'application/voicexml+xml'" connectionid="call_0" dialogid="message_Dlg" namelist="voxeo_cpa_result param1 param2 param3"/>
</transition>
<transition event="stopMsg" cond="dlgStatus == 'started'">
<assign name="forcedDlgExit" expr="true"/>
<assign name="dlgStatus" expr="'pending_stop'"/>
<dialogterminate dialogid="message_Dlg" immediate="true"/>
</transition>
<transition event="stopMsg">
<log expr="'@@@ NO DIALOG CURRENTLY STARTED -- stopMsg EVENT IGNORED @@@ '"/>
</transition>
<transition event="connection.disconnected">
<if cond="call_0 == event$.connectionid">
<log expr="'@@@ CALL DISCONNECTED -- EXIT @@@ '"/>
<!-- track the time -->
<assign name="callEndTime" expr="new Date().getTime()"/>
<assign name="callDuration" expr="callEndTime-callStartTime"/>
<assign name="state0" expr="'dialogexited'"/>
<log expr="'@@@ CALL DURATION: @@@ ' callDuration"/>
<assign name="status" expr="'duration'"/>
<if cond="hasSentDuration == false">
<send targettype="'basichttp'" target="'http://myCoolWebserver.com/myLoggingScript.php'"; name="'http.get'" namelist="sessionID voxeo_cpa_result callDuration param1 param2 param3 param4 param5"/>
<assign name="hasSentDuration" expr="true"/>
<else/>
<exit/>
</if>
</if>
</transition>
<transition event="error.*">
<log expr="'@@@ AN ERROR HAS OCCURRED [' + event$.reason + '] @@@ '"/>
<exit/>
</transition>
</eventprocessor>
</ccxml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment