Tropo WebAPI Development Guide Home  |  Frameset Home

  Ruby - Volunteer Opportunities Example  |  TOC  |  PHP - Favorite Movie Trilogy Example  

Behind the Scene JSON - Volunteer Opportunities


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

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

{"session":{
     "id":"17329961874b3ebb9a7fe21189523bc6",
     "accountId":"33932",
     "timestamp":"2010-09-13T19:20:02.988Z",
     "userType":"HUMAN",
     "initialText":null,
     "callId":"a0694bc104b5487daeda4677bff317bf",
     "to":{
        "id":"7735551212",
        "name":"default.externalppid.voxeo.net",
        "channel":"VOICE",
        "network":"SIP"
     },
     "from":{
        "id":"4075551212",
        "name":"192.168.30.60",
        "channel":"VOICE",
        "network":"SIP"
     },
     "headers":{
        "x-sbc-user-agent":"CommuniGatePro-callLeg/5.2.11",
        "x-sbc-contact":"<sip:signode-875318-61C73A7B@66.193.54.5>",
        "Content-Length":"247",
        "x-sbc-p-charge-info":"sip:+14075551212@192.168.37.68",
        "x-sid":"03e23fe20237bda04314b44488de02ea",
        "x-sbc-expires":"180",
        "x-sbc-supported":"histinfo",
        "x-sbc-allow":"REFER",
        "x-voxeo-sbc-name":"10.6.60.100",
        "Contact":"<sip:4075551212@10.6.60.100:5060>",
        "To":"<sip:7735551212@10.6.60.100:5060>",
        "Content-Type":"application/sdp",
        "x-sbc-min-se":"10"
     }
  }
}

Once the application interprets the session JSON, it tells Tropo to ask for the zip code. This is the response JSON that gets sent back to Tropo, telling it what to do:

{"tropo":[
     {
        "ask":{
           "bargein":true,
           "attempts":2,
           "timeout":60,
           "say":[
              {
                 "value":"Sorry, I did not hear anything.",
                 "event":"timeout"
              },
              {
                 "value":"Oops, that wasn't a five-digit zip code.",
                 "event":"nomatch:1 nomatch:2"
              },
              {
                 "value":" Please enter your zip code to search for volunteer opportunities in your area."
              }
           ],
           "name":"zip",
           "choices":{
              "value":"[5 DIGITS]"
           }
        }
     },
     {
        "on":{
           "next":"/hangup.json",
           "event":"hangup"
        }
     },
     {
        "on":{
           "next":"/process_zip.json",
           "event":"continue"
        }
     }
  ]
}

Tropo interprets the JSON, asks the user for their zip code (line 18 of Figure 6.1), then sends this JSON back to the application once it receives input; note the zip code is returned in the actions section of this JSON (line 9 of figure 6.2):

{"result":{
     "sessionId":"17329961874b3ebb9a7fe21189523bc6",
     "callId":"a0694bc104b5487daeda4677bff317bf",
     "state":"ANSWERED",
     "sessionDuration":8,
     "sequence":1,
     "complete":true,
     "error":null,
     "actions":{
        "name":"zip",
        "attempts":1,
        "disposition":"SUCCESS",
        "confidence":53,
        "interpretation":"94070",
        "utterance":"nine four zero seven zero",
        "value":"nine four zero seven zero",
        "xml":"<?xml version=\"1.0\"?>\r\n<result grammar=\"0@3146a6c5.vxmlgrammar\">\r\n    <interpretation grammar=\"0@3146a6c5.vxmlgrammar\" confidence=\"53\">\r\n        \r\n      <input mode=\"speech\">nine four zero seven zero<\/input>\r\n    <\/interpretation>\r\n<\/result>\r\n"
     }
  }
}

The last JSON contained the zip code 94070 (line 14 of Figure 6.2), so the application searched allforgood.org for opportunities that matched. The JSON that gets sent back to Tropo contains the results from the search that match San Carlos, CA with the instructions on what to do next:

{"tropo":[
      {
         "say":[
            {
               "value":"Here are 9 opportunities. Press the opportunity number you want more information about."
            }
         ]
      },
      {
         "ask":{
            "say":[
               {
                  "event":"nomatch:1",
                  "value":"That wasn't a one-digit opportunity number. Here are your choices: "
               },
               {
                  "value":"Opportunity #1 WITH SENIORS At Lytton Gardens, Opportunity #2 Social Media Coordinator, Opportunity #3 Kinship Activities Volunteer Assistance, Opportunity #4 Help Foster Rescued Kittens And Cats :), Opportunity #5 Kinship Activities Volunteer Assistance, Opportunity #6 Family Story Hour Helper, Opportunity #7 Grant Writer And Researcher, Opportunity #8 Help Us In Our Office So We Can Continue To Do Free Home Repairs For Low-income Homeowners!, Opportunity #9 After School Fitness Assistant"
               }
            ],
            "choices":{
               "value":"[1 DIGITS]"
            },
            "bargein":true,
            "timeout":60,
            "name":"selection",
            "attempts":1
         }
      },
      {
         "on":{
            "event":"continue",
            "next":"/process_selection.json"
         }
      },
      {
         "on":{
            "event":"hangup",
            "next":"/hangup.json"
         }
      }
   ]
}

Tropo interprets the JSON, asks the user to select an opportunity number for more information (line 5 of Figure 6.3), then feeds the user's selection back to the application using this JSON:

{"result":{
      "sessionId":"634c414899ab85e5f0e1816655df5fac",
      "callId":"3e9aa19a67826432531e8063012dc16b",
      "state":"ANSWERED",
      "sessionDuration":20,
      "sequence":2,
      "complete":true,
      "error":null,
      "actions":{
         "name":"selection",
         "attempts":1,
         "disposition":"SUCCESS",
         "confidence":100,
         "interpretation":"2",
         "utterance":"2",
         "value":"2",
         "xml":"<?xml version=\"1.0\"?>\r\n<result grammar=\"1@8959c1b2.vxmlgrammar\">\r\n <interpretation grammar=\"1@8959c1b2.vxmlgrammar\" confidence=\"100\">\r\n \r\n <input mode=\"dtmf\">dtmf-2<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n"
      }
   }
}

The app receives and interprets the JSON, then sends the information on the selected opportunity back to Tropo to be relayed to the caller; it also instructs Tropo to ask if they would like the opportunity information to be sent via text message (line 17 of Figure 6.5):

{"tropo":[
      {
         "say":[
            {
               "value":"Information about opportunity Social Media Coordinator is as follows: Event Details: From Wednesday July 14 at 12:00 AM to Tuesday November 30 at 12:00 AM, Official web page: tiny u r l dot com slash 2,v,k,7,c,p,t,. Again, that's tiny u r l dot com slash 2,v,k,7,c,p,t,, Google Map: tiny u r l dot com slash 3,8,t,o,q,j,h, Description: Join us to develop our social media strategy and to network more effectively. We want to reach out to as many people as possible, and we want your savvy! If you are a connector and a storyteller excited about new technologies for communicating, come help us tell the stories of our rebuilding project. End of description. "
            }
         ]
      },
      {
         "ask":{
            "say":[
               {
                  "event":"nomatch:1",
                  "value":"That wasn't a valid answer. "
               },
               {
                  "value":"Would you like to have a text message sent to you?\n Press 1 or say 'yes' to get a text message; Press 2 or say 'no' to conclude this session."
               }
            ],
            "choices":{
               "value":"true(1,yes), false(2,no)"
            },
            "bargein":true,
            "timeout":60,
            "name":"send_sms",
            "attempts":1
         }
      },
      {
         "on":{
            "event":"continue",
            "next":"/send_text_message.json"
         }
      },
      {
         "on":{
            "event":"hangup",
            "next":"/hangup.json"
         }
      }
   ]
}

Tropo interprets the JSON, provides the detailed opportunity info (line 5 of Figure 6.5) and asks the question (line 17 of Figure 6.5). Our caller pressed 1 to say yes, they did want it texted (indicated by line 14 of Figure 6.6), so Tropo sends this JSON back to the app:

{"result":{
      "sessionId":"634c414899ab85e5f0e1816655df5fac",
      "callId":"3e9aa19a67826432531e8063012dc16b",
      "state":"ANSWERED",
      "sessionDuration":80,
      "sequence":3,
      "complete":true,
      "error":null,
      "actions":{
         "name":"send_sms",
         "attempts":1,
         "disposition":"SUCCESS",
         "confidence":100,
         "interpretation":"1",
         "utterance":"1",
         "concept":"true",
         "value":"true",
         "xml":"<?xml version=\"1.0\"?>\r\n<result grammar=\"2@8959c1b2.vxmlgrammar\">\r\n <interpretation grammar=\"2@8959c1b2.vxmlgrammar\" confidence=\"100\">\r\n \r\n <input mode=\"dtmf\">dtmf-1<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n"
      }
   }
}

The application receives the JSON, interprets it and then sends the following JSON to Tropo with instructions to ask for a phone number (line 14 of Figure 6.7):

{"tropo":[
      {
         "ask":{
            "say":[
               {
                  "event":"timeout",
                  "value":"Sorry, I did not hear anything."
               },
               {
                  "event":"nomatch:1 nomatch:2",
                  "value":"Oops, that wasn't a 10-digit number."
               },
               {
                  "value":"What 10-digit phone number would you like to send the information to?"
               }
            ],
            "choices":{
               "value":"[10 DIGITS]"
            },
            "bargein":true,
            "timeout":60,
            "required":false,
            "name":"number_to_text",
            "attempts":2
         }
      },
      {
         "on":{
            "event":"continue",
            "next":"/send_text_message.json"
         }
      },
      {
         "on":{
            "event":"hangup",
            "next":"/hangup.json"
         }
      }
   ]
}

Once the number is received, Tropo then sends back the appropriate JSON with the phone number (line 14 of Figure 6.8):

{"result":{
      "sessionId":"9082060a520bc4aec88f876fbacb1d5b",
      "callId":"a26def3aa9eb09ce0180a33f327fe3f2",
      "state":"ANSWERED",
      "sessionDuration":77,
      "sequence":4,
      "complete":true,
      "error":null,
      "actions":{
         "name":"number_to_text",
         "attempts":1,
         "disposition":"SUCCESS",
         "confidence":100,
         "interpretation":"4075551212",
         "utterance":"4 0 7 4 5 5 1 2 1 2",
         "value":"4075551212",
         "xml":"<?xml version=\"1.0\"?>\r\n<result grammar=\"3@8627aff7.vxmlgrammar\">\r\n <interpretation grammar=\"3@8627aff7.vxmlgrammar\" confidence=\"100\">\r\n \r\n <input mode=\"dtmf\">dtmf-4 dtmf-0 dtmf-7 dtmf-4 dtmf-0 dtmf-9 dtmf-5 dtmf-2 dtmf-3 dtmf-1<\/input>\r\n <\/interpretation>\r\n<\/result>\r\n"
      }
   }
}

Once the text message is sent, the application moves on to goodbye.json; here's the JSON response to Tropo:

{"tropo":[
      {
         "say":[
            {
               "value":"That's all. Communication services donated by tropo dot com, data by all for good dot org. Have a nice day. Goodbye."
            }
         ]
      },
      {
         "hangup":null
      },
      {
         "on":{
            "event":"hangup",
            "next":"/hangup.json"
         }
      }
   ]
}


All that's left is hangup.json - here's the JSON sent from Tropo:

{"result":{
      "sessionId":"9082060a520bc4aec88f876fbacb1d5b",
      "callId":"a26def3aa9eb09ce0180a33f327fe3f2",
      "state":"DISCONNECTED",
      "sessionDuration":94,
      "sequence":6,
      "complete":true,
      "error":null
   }
}




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

login
  Ruby - Volunteer Opportunities Example  |  TOC  |  PHP - Favorite Movie Trilogy Example  

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