Tropo WebAPI Development Guide Home  |  Frameset Home

  Example Application  |  TOC  |  Sessions & Tokens  

Behind the Scenes JSON - Quick Start


Interested in the JSON sent back and forth between Tropo and your web server by the Quick Start Example? It's all here, in the same order as the main description of the application.

First, the initial session JSON to start the whole process:

{
   "session":{
      "id":"af02debeca9c4f6f6f98d41a82591428",
      "accountId":"46256",
      "timestamp":"2010-09-20T21:30:16.315Z",
      "userType":"HUMAN",
      "initialText":null,
      "callId":"edad88ff110a8b5ef6a1466aa332ace8",
      "to":{
         "id":"3473051212",
         "name":"default.externalppid.voxeo.net",
         "channel":"VOICE",
         "network":"SIP"
      },
      "from":{
         "id":"4075551212",
         "name":"192.168.27.76",
         "channel":"VOICE",
         "network":"SIP"
      },
      "headers":{
         "x-sbc-user-agent":"CommuniGatePro-callLeg/5.2.11",
         "x-sbc-contact":"",
         "Content-Length":"247",
         "x-sbc-p-charge-info":"sip:+14075551212@192.168.27.76",
         "x-sid":"b117b6523408cb4bc7de4b1fd671564d",
         "x-sbc-cseq":"1 INVITE",
         "x-sbc-expires":"180",
         "x-sbc-supported":"histinfo",
         "CSeq":"2 INVITE",
         "Via":"SIP/2.0/UDP 66.193.54.6:5060;received=10.6.63.201",
         "x-sbc-allow":"REFER",
         "x-voxeo-sbc-name":"10.6.63.201",
         "Contact":"",
         "To":""
      }
   }
}

The application interprets the session JSON to see whether it's a text or voice channel; since we're working with voice, it sends back the following JSON instructing Tropo to ask the caller for their birth year (line 15 of Figure 3.1). It also provides instructions telling Tropo what to do if the user doesn't enter correct input (lines 7, 8, 11 & 12 of Figure 3.1).

{"tropo":[
      {
         "ask":{
            "bargein":true,
            "say":[
               {
                  "value":"Sorry, I did not hear anything.",
                  "event":"timeout"
               },
               {
                  "value":"Don't think that was a year, champ.",
                  "event":"nomatch:1 nomatch:2"
               },
               {
                  "value":"What is your birth year?"
               }
            ],
            "required":true,
            "attempts":2,
            "timeout":60,
            "name":"year",
            "choices":{
               "value":"[4 DIGITS]"
            }
         }
      },
      {
         "on":{
            "next":"/your_age.json",
            "event":"continue"
         }
      }
   ]
}

Tropo relays the request for the birth year using an ask with speech recognition, then sends back the following JSON with the input received (1980 in our case, indicated by line 15 of Figure 3.2):

{
   "result":{
      "sessionId":"af02debeca9c4f6f6f98d41a82591428",
      "callId":"edad88ff110a8b5ef6a1466aa332ace8",
      "state":"ANSWERED",
      "sessionDuration":5,
      "sequence":1,
      "complete":true,
      "error":null,
      "actions":{
         "name":"year",
         "attempts":1,
         "disposition":"SUCCESS",
         "confidence":100,
         "interpretation":"1980",
         "utterance":"1 9 8 0",
         "value":"1980",
         "xml":"<?xml version=\"1.0\"?>\r\n\r\n \r\n \r\n dtmf-1 dtmf-9 dtmf-8 dtmf-0<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n"
      }
   }
}

The application interprets the JSON, calculates the age range of the caller, then sends back the following JSON so Tropo can relay to the caller:

{"tropo":[
      {
         "say":[
            {
               "value":"Your age is between 29 and 31"
            }
         ]
      },
      {
         "hangup":null
      }
   ]
}




  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Example Application  |  TOC  |  Sessions & Tokens  

© 2011 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site