| CCXML Voxeo 1.0 Development Guide | Home | Frameset Home |
|
<transition> placement
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
</ccxml>
<eventhandler> can only be scoped to a single state variable. Let's take a look:
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<var name="app_state" expr="'initial'"/>
<eventhandler statevariable="app_state">
</eventhandler>
</ccxml>
<eventhandler> will use "app_state" for the state variable. This does not mean that we must use state information as part of our specific event check; instead, it forces us to use the specified state variable if we choose to check for state.
<eventhandler statevariable="app_state">
<transition state="'initial'" event="connection.CONNECTION_ALERTING" name="evt">
<assign name="app_state" expr="'accepting'"/>
<accept/>
<var name="in_callid" expr="evt.callid"/>
</transition>
<transition state="'accepting'" event="connection.CONNECTION_CONNECTED">
<assign name="app_state" expr="'incall_0'"/>
<send event="'continue'" target="session.id" delay="'3000'"/>
</transition>
</eventhandler>
<transition> tag handles more than one conditional requirement: for our first example, the state (as defined within the "app_state" variable) must be equal to "initial" as well as the raw event itself being "connection.CONNECTION_ALERTING". If either of these is not the case, then there is no match. Case in point: we are changing the value (via the <assign> tag) to a new value -- should our state variable never be reset to "initial", then this <transition> will never be visited again. We are also storing the value of the call leg's ID. This will become important later in our application. <send> an event.<send> we are able to post an event to any session we have the identifier of. In this example, we send one simple event to ourselves. Additionally, we will delay the sending for three seconds (yes, the delay value is expressed in milliseconds), allowing us to implement timer functionality or just pause our application briefly. <send> element requires us to catch a user-defined event.
<eventhandler statevariable="app_state">
<transition state="'incall_0'" event="user.continue">
<assign name="app_state" expr="'incall_1'"/>
<send event="'continue'" target="session.id" delay="'1000'"/>
</transition>
<transition state="'incall_1'" event="user.continue">
<disconnect callid="in_callid"/>
<assign name="app_state" expr="'disconnecting'"/>
</transition>
</eventhandler>
<disconnect> event, but what if we want to detect an earlier event (say, for example, your impatient little sister called and the four seconds of silence overwhelmed her)? Clearly, you might want to know when this situation occurs...
<eventhandler statevariable="app_state">
<transition event="call.CALL_INVALID"
cond="('incall_0' == app_state) || ('incall_1' == app_state)">
<log expr="'premature disconnection detected in state [' + app_state + ']'"/>
<exit/>
</transition>
<transition event="call.CALL_INVALID">
<log expr="'not premature... wise, learned, mature disconnection'"/>
<exit/>
</transition>
<transition event="call.*">
<log expr="'unhandled call.* event detected'"/>
</transition>
</eventhandler>
<?xml version="1.0" encoding="UTF-8"?>
<!-- NOTE THAT WE *MUST* DECLARE THE xmlns ATTRIBUTE -->
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<var name="app_state" expr="'initial'"/>
<eventhandler statevariable="app_state">
<transition state="'initial'" event="connection.CONNECTION_ALERTING" name="evt">
<assign name="app_state" expr="'accepting'"/>
<accept/>
<var name="in_callid" expr="evt.callid"/>
</transition>
<transition state="'accepting'" event="connection.CONNECTION_CONNECTED">
<assign name="app_state" expr="'incall_0'"/>
<send event="'continue'" target="session.id" delay="'3000'"/>
</transition>
<transition state="'incall_0'" event="user.continue">
<assign name="app_state" expr="'incall_1'"/>
<send event="'continue'" target="session.id" delay="'1000'"/>
</transition>
<transition state="'incall_1'" event="user.continue">
<disconnect callid="in_callid"/>
<assign name="app_state" expr="'disconnecting'"/>
</transition>
<transition event="call.CALL_INVALID"
cond="('incall_0' == app_state) || ('incall_1' == app_state)">
<log expr="'premature disconnection detected in state [' + app_state + ']'"/>
<voxeo:sendemail to="'yourEmail@there.com'"
from="'myApp@here.com'"
type="'debug'"
body=" 'premature disconnection detected!' "/>
<exit/>
</transition>
<transition event="call.CALL_INVALID">
<log expr="'not premature... wise, learned, mature disconnection'"/>
<exit/>
</transition>
<transition event="call.*">
<log expr="'unhandled call.* event detected'"/>
<voxeo:sendemail to="'yourEmail@there.com'"
from="'myApp@here.com'"
type="'debug'"
body="'unhandled call event detected!'"/>
</transition>
</eventhandler>
</ccxml>
| ANNOTATIONS: EXISTING POSTS |
jason.m.hanna
|
|
| Hi,
Perhaps a correction for the documentation. In the last sentence before Step 5, the documentation states: --- As stated in our last tutorial, the order of the transitions is critical -- if we put this code piece at the top of the <eventhandler>, nothing would work at all (we wouldn't get our four seconds of silence!). --- I don't think that is 100% accurate. If you move the "call.*" transition event to the first position in the transition definitions, the "connection.*" events will still be handled properly, still giving you the 4 seconds of silence. You won't, however, ever capture the "premature" or "mature" call.CALL_INVALID transition events and exit gracefully from the disconnect. The call.* filter will always catch it first. Correct? Regards, -jmh |
|
MattHenry
|
|
|
Correct you are, sir. I have fixed this in our internal doc build so that other folks won't be mislead by that statement. Thanks again, ~Matthew Henry |
|
kave
|
|
| hi there!
where could i get some information about "call leg id" or "callid"? best, kave |
|
voxeojeremy
|
|
| Kave,
You may get some information on call legs at this doc post: http://docs.voxeo.com/ccxml/1.0/introcalllegs_ccxml.htm And you may wish to do the associated tutorial, at this link: http://docs.voxeo.com/ccxml/1.0/t_6ccxml.htm Regards, Jeremy McCall Voxeo Extreme Support |
|
kave
|
|
| hi Jeremy!
thanks for the links, i'm still a little confused about callid, callerid and calledid... when i want to disconnect an inbound call , would it be with callid right?,, callerid is more like a variable for user recognition, isn't it? also a question about calledid, is it possible that a phone number that is connected by an application, everytime when i do an inbound call to this phone number, could the calledid number be different...??? i mean... example: phone number: 1-800-123-456 Application numbers (Dnis) 1rst call --> DNIS =3212022485 2nd call --> DNIS = 3212024875... or is the same DNIS always? in other words, are callerid and callid static variables? and is calledid or application number a dinamic variable? thanks in avance, best kave |
|
mikethompson
|
|
| Hi Kave,
I'm happy to clarify callerid, callid, and calledid for you. When calling into an application, the called ID will always be the inbound phone number you are dialing. This value shouldn't change. The caller ID (ANI) is just that, the number of the phone trying to reach the application. This will clearly be dynamic. You are correct, callid is used to associate certain events with a call leg. For example, you can use this to do a dialogstart for a specific call leg. I hope I was able to provide some clarity for you, but do let me know if you have additional questions. Best, Mike Thompson Voxeo Corporation |
|
kave
|
|
| Hi Mike!
Thanks a lot Mike, like they song in Jamaica! "I can see clear now and very strong!!!" lol Best Regards! kave |
| login |
|