Session Variable Examples

The JSON to and appData fields are merged into a single application data. This application data is accessible to the application via session variables. If the appData field is a String the value is passed as the “value” variable. If the appData field is an Object the keys are used as the variable name.

For VXML applications the application data is present in the session.blueworx.appdata variables. The to JSON field will be in the session.blueworx.appdata.to_hdr.

For CCXML applications the application data is present in the evt.connection.appdata variables for the makeCall action. The to JSON field will be in the evt.connection.appdata.to. For the startApplication action the application data is present in the session.values variable. The to JSON field will be in the session.values.to.

makeCall action example using JSON String appData

  
        {
          "action": "makeCall",
          "to": "sip:1234@1.2.3.4",
          "apiKey": "bd75a37a-1ccd-42f4-b2c9-abb30bf4bbe0",
          "appData": "Hello world"        
        }
    

For a VXML application this will generate these variables:

 
        session.blueworx.appdata.to_hdr = sip:1234@1.2.3.4
        session.blueworx.appdata.value = “Hello World”
            

VXML code snippet:

 
        <block>
            <if cond="session.blueworx.appdata.to_hdr != undefined">
                <log>session.blueworx.appdata.to_hdr :
                <value expr="session.blueworx.appdata.to_hdr"/>
                </log>
            </if>
            <if cond="session.blueworx.appdata.value != undefined">
                <log>session.blueworx.appdata.value :
                <value expr="session.blueworx.appdata.value"/>
                </log>
            </if>
        </block>
    

For a CCXML application this will generate these variables

 
        evt.connection.appdata.to = sip:1234@1.2.3.4
        evt.connection.appdata.value = “Hello World”
        

makeCall action example using JSON Object appData

 
        {
          "action": "makeCall",
          "to": "sip:1234@1.2.3.4",
          "apiKey": "bd75a37a-1ccd-42f4-b2c9-abb30bf4bbe0",
          "appData": {
            "hello": "world",
            "foo": "bar"
          }
        }
        
    

For a VXML application this will generate these variables:

 
        session.blueworx.appdata.to_hdr = sip:1234@1.2.3.4
        session.blueworx.appdata.hello = “world”
        session.blueworx.appdata.foo = “bar”        
    

VXML code snippet:

 
        <block>
            <if cond="session.blueworx.appdata.to_hdr != undefined">
                <log>session.blueworx.appdata.to_hdr :
                <value expr="session.blueworx.appdata.to_hdr"/>
                </log>
            </if>
            <if cond="session.blueworx.appdata.hello != undefined">
                <log>session.blueworx.appdata.hello :
                <value expr="session.blueworx.appdata.hello"/>
                </log>
            </if>
            <if cond="session.blueworx.appdata.foo != undefined">
                 <log>session.blueworx.appdata.foo :
                 <value expr="session.blueworx.appdata.foo"/>
                 </log>
            </if>
        </block>
    

For a CCXML application this will generate these variables

 
        evt.connection.appdata.to = sip:1234@1.2.3.4
        evt.connection.appdata.hello = “world”
        evt.connection.appdata.foo = “bar”        
    

startApplication action example using JSON String appData

        {
          "action": "startApplication",
          "to": "sip:1234@1.2.3.4",
          "apiKey": "bd75a37a-1ccd-42f4-b2c9-abb30bf4bbe0",
          "appData": "Hello world"
        }
    

For a CCXML application this will generate these variables:

        session.values.to = sip:1234@1.2.3.4
        session.values.value = “Hello World”
    

startApplication action example using JSON Object appData

        {
          "action": "startApplication",
          "to": "sip:1234@1.2.3.4",
          "apiKey": "bd75a37a-1ccd-42f4-b2c9-abb30bf4bbe0",
          "appData": {
                "hello": "world",
                "foo": "bar"
          }
        }
        

For a CCXML application this will generate these variables:

        session.values.to = sip:1234@1.2.3.4
        session.values.hello = “world”
        session.values.foo = “bar”
            

CCXML code snippet:

             
        <transition event="ccxml.loaded" name="evt">            
            <if cond="session.values.to != undefined">
                <createcall dest="session.values.to" connectionid="myConnectionID"/>
            <else/>
                <exit/>
            </if>            
        </transition>