Tropo WebAPI Development Guide Home  |  Frameset Home

  PHP - Favorite Movie Trilogy Example  |  TOC  |  Node.js - Voice Recording Example  

Behind the Scenes JSON - Favorite Movie Trilogy


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

Here's the initial session JSON that starts it all off:

{
   "session":{
      "id":"cdfc037a569baf929161e92335ebf5e1",
      "accountId":"46256",
      "timestamp":"2010-10-04T22:04:40.894Z",
      "userType":"HUMAN",
      "initialText":null,
      "callId":"c11617f3737dc78db86d95b5449200d6",
      "to":{
         "id":"9991457004",
         "name":"default.externalppid.voxeo.net",
         "channel":"VOICE",
         "network":"SIP"
      },
      "from":{
         "id":"4073862000",
         "name":"unknown",
         "channel":"VOICE",
         "network":"SIP"
      },
      "headers":{
         "x-sbc-user-agent":"CommuniGatePro-callLeg/5.2.11",
         "x-sbc-contact":"",
         "Content-Length":"247",
         "x-sid":"024c21db8e37e4e6cebaf33be11fff3f",
         "x-sbc-cseq":"1 INVITE",
         "x-sbc-supported":"histinfo",
         "x-sbc-expires":"180",
         "CSeq":"2 INVITE",
         "Via":"SIP/2.0/UDP 66.193.54.6:5060;received=10.6.63.201",
         "x-sbc-to":"",
         "x-sbc-allow":"REFER",
         "x-voxeo-sbc-name":"10.6.63.201",
         "Contact":"",
         "To":"",
         "x-voxeo-sbc":"true"
      }
   }
}

The application interprets the JSON and sends back instructions to Tropo, based on the channel (in this example, the channel was VOICE):

{"tropo":[
      {
         "say":[
            {
               "value":"Welcome to the Tropo PHP example for VOICE"
            }
         ]
      },
      {
         "ask":{
            "attempts":3,
            "bargein":true,
            "choices":{
               "value":"1,2,3,4",
               "mode":"dtmf"
            },
            "name":"movie",
            "say":[
               {
                  "value":"Which of these trilogies do you like the best? Press 1 to vote for Lord of the Rings, press 2 for the original Star Wars, 3 for the Star Wars prequels, or press 4 for the Matrix"
               }
            ],
            "timeout":30
         }
      },
      {
         "on":{
            "event":"continue",
            "next":"testapp.php?uri=choice",
            "say":{
               "value":"Please hold."
            }
         }
      },
      {
         "on":{
            "event":"incomplete",
            "next":"testapp.php?uri=incomplete"
            }
         }
      }
   ]
}

Tropo interprets the JSON sent by the application, asks the user for their favorite movie trilogy (line 20 of Figure 8.1), then sends this result JSON back to the application once it receives input; note their choice is returned in the actions section of this JSON (line 15 of figure 8.2):

{
   "result":{
      "sessionId":"cdfc037a569baf929161e92335ebf5e1",
      "callId":"c11617f3737dc78db86d95b5449200d6",
      "state":"ANSWERED",
      "sessionDuration":5,
      "sequence":1,
      "complete":true,
      "error":null,
      "actions":{
         "name":"movie",
         "attempts":1,
         "disposition":"SUCCESS",
         "confidence":100,
         "interpretation":"3",
         "utterance":"3",
         "concept":"3",
         "value":"3",
         "xml":"<?xml version=\"1.0\"?>\r\n\r\n \r\n \r\n dtmf-3<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n"
      }
   }
}

Once the application receives the result JSON, it takes the choice and returns the appropriate prompt (line 5 of Figure 8.3), then redirects Tropo to look at the hangup event (lines 10 through 12), which disconnects the call:

{"tropo":[
      {
         "say":[
            {
               "value":"You picked the Star Wars prequels. Stop calling this number, Mr. Lucas, we know it's you."
            }
         ]
      },
      {
         "on":{
            "event":"continue",
            "next":"testapp.php?uri=hangup"
         }
      },
      {
         "on":{
            "event":"error",
            "next":"testapp.php?uri=error"
         }
      }
   ]
}



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

login
  PHP - Favorite Movie Trilogy Example  |  TOC  |  Node.js - Voice Recording Example  

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