Building Tropo Apps
with Grails
Christopher Bartling
Summary                                   2




ā–  What is Tropo?
ā–  How do I integrate Tropo with Grails?
ā–  Tropo WebAPI overview
ā–  Lessons learned
Terminology                         3




ā–  IVR: Interactive Voice Response
ā–  VoiceXML or VXML:
ā–  CCXML: Call Control XML
ā–  TTS: Text to Speech
What is Tropo?                                       4



ā–  Cloud-based services for telephony and messaging
  ā–  Make and receive phone calls
  ā–  Use voice recognition
  ā–  Messaging via SMS, IM, or Twitter
ā–  Backed by Voxeo.com
  ā–  Industry leader in IVR and VoIP solutions
Why should I care?                                        5



ā–  Many applications benefit from voice and messaging
   user interfaces

ā–  Tropo provides telephony and messaging infrastructure
   and APIs for integrating these services into your
   applications

   ā–  Traditionally this was hosted in-house
ā–  APIs insulate developers from needing to write in
   VoiceXML, CCXML, and other markups
How do I use it with Grails?                              6




ā–  Install the Tropo WebAPI Grails plugin (version 0.21)
   ā–  tropo-webapi-grails
   ā–  Provides the TropoBuilder object for building
      standard Tropo JSON documents

   ā–  TropoService for provisioning and servicing
      Tropo applications
TropoBuilder                                            7




ā–  Builds Tropo JSON response documents
ā–  Provides an array of JSON objects to control the
   Tropo-based applications hosted in the cloud

  ā–  ask, call, conference, hangup, message, on,
      record, redirect, reject, result, say, session,
      startRecording, stopRecording, transfer
TropoService                                            8




ā–  Grails service for administering Tropo applications
   ā–  Abstraction around Tropo’s REST API
   ā–  Create, update, and delete Tropo applications
   ā–  Provision phone numbers, IM addresses, tokens
   ā–  Retrieve information about applications
Tropo.com                                                  9



ā–  Web-based administration UI
  ā–  Create, update, and delete Tropo applications in the
     cloud

  ā–  Provision telephone numbers (both local and toll-
     free) and IM accounts for your applications

  ā–  Application debugging tool
  ā–  Billing profile
Tropo Development                                           10


ā–  Create your Grails application
ā–  Add tropo-webapi-grails Grails plugin
ā–  Create your starting endpoint in your Grails app
ā–  Create application on tropo.com
   ā–  Need externally available starting endpoint for your
      Grails app

   ā–  Provision local phone number
Tropo WebAPI                                                 11




ā–  Use the TropoBuilder object to create Tropo-compliant
   JSON objects

ā–  Tropo calls back to your application for instructions on
   how to power the IVR infrastructure in the Tropo cloud

ā–  You application is a collection of interconnected
   endpoints, rendering Tropo JSON objects to control
   the IVR infrastructure in the Tropo cloud
Tropo WebAPI JSON objects   12
session                                                     13




ā–  Sent to your application in the first Tropo request
ā–  The callId field identifies this request body to a unique
   call in Tropo

   ā–  You will use the callId as the correlation identifier
      for all requests

ā–  https://www.tropo.com/docs/webapi/session.htm
result                                                      14



ā–  Sent to your application in all subsequent requests
   from Tropo

ā–  The callId field identifies this request body to a unique
   call in Tropo

   ā–  You will use the callId as the correlation identifier
      for all requests

ā–  https://www.tropo.com/docs/webapi/result.htm
say                                           15




ā–  Say something to the caller
  ā–  Can be TTS or pre-recorded audio
  ā–  Does not wait for user response
ā–  https://www.tropo.com/docs/webapi/say.htm
ask                                                     16


ā–  Say something to the caller and wait for a response
   from the caller

  ā–  Can be TTS or audio file for say
  ā–  Response can be collected speech or touch-tone
      keypad (DTMF)

  ā–  The choices object specifies how Tropo handles
      user input

ā–  https://www.tropo.com/docs/webapi/ask.htm
on                                           17



ā–  Specifies event handling
  ā–  continue
  ā–  error
  ā–  incomplete
  ā–  hangup
ā–  https://www.tropo.com/docs/webapi/on.htm
hangup                                           18




ā–  Hangs up the current call.
ā–  https://www.tropo.com/docs/webapi/hangup.htm
record                                                      19




ā–  Plays a prompt and then waits for a response from the
   caller, which it records

ā–  Responses may be speech recognition or touch-tone
   keypresses (DTMF)

ā–  At the conclusion of the recording, the collected audio
   file is sent to FTP or HTTP POST/Multipart Form
   endpoint
transfer                                                   20




ā–  Transfer an in-progress call to another destination or
   phone number

   ā–  Can be a phone number or a SIP address
ā–  https://www.tropo.com/docs/webapi/transfer.htm
startRecording
stopRecording                                            21



ā–  Start and stop recording a call session
ā–  Resultant recording can be sent via FTP or HTTP
   POST/Multipart form to a URL

ā–  You have to provide an endpoint or FTP server to
   receive the binary file

ā–  https://www.tropo.com/docs/webapi/startrecording.htm

ā–  https://www.tropo.com/docs/webapi/stoprecording.htm
Lessons Learned                                            22




ā–  Testing
  ā–  Test call flow in isolation by using a testing Tropo
     application and a testing endpoint to bootstrap the
     call session appropriately

  ā–  In the future, look to building an automated test
     runner that can be scripted and exercise the Grails
     app through HTTP calls
Lessons Learned                                             23




ā–  The ask noinput and timeout APIs don’t work well
  ā–  Issues with audio getting played out of sequence
  ā–  Build this functionality into our call flow explicitly
     using on events
Lessons Learned                                        24




ā–  Call recording is all or nothing
   ā–  Unable to start and stop recording to allow for
      omission of sensitive data recording

   ā–  We toggle recording for debugging call flow
   ā–  Keep it off for production usage
Lessons Learned                                         25




ā–  Call duration can be difficult to determine
   ā–  Maintain a last Tropo callback timestamp on call
      session domain object

   ā–  Update the timestamp on each Tropo callback
      invocation

   ā–  Allows approximation of the call duration
Lessons Learned                                     26




ā–  Abandoned calls can be difficult to determine
  ā–  We used a Quartz job in Grails
  ā–  Periodically inspect in-progress calls
  ā–  If last Tropo callback timestamp is beyond a
      specified threshold, set the call session to
      abandoned
Contact Information                                      27




ā–  Twitter: @cbartling
ā–  Blog: http://bartling.blogspot.com
ā–  https://bitbucket.org/cebartling/tropo-presentations

Building Tropo Apps with Grails

  • 1.
    Building Tropo Apps withGrails Christopher Bartling
  • 2.
    Summary 2 ā–  What is Tropo? ā–  How do I integrate Tropo with Grails? ā–  Tropo WebAPI overview ā–  Lessons learned
  • 3.
    Terminology 3 ā–  IVR: Interactive Voice Response ā–  VoiceXML or VXML: ā–  CCXML: Call Control XML ā–  TTS: Text to Speech
  • 4.
    What is Tropo? 4 ā–  Cloud-based services for telephony and messaging ā–  Make and receive phone calls ā–  Use voice recognition ā–  Messaging via SMS, IM, or Twitter ā–  Backed by Voxeo.com ā–  Industry leader in IVR and VoIP solutions
  • 5.
    Why should Icare? 5 ā–  Many applications benefit from voice and messaging user interfaces ā–  Tropo provides telephony and messaging infrastructure and APIs for integrating these services into your applications ā–  Traditionally this was hosted in-house ā–  APIs insulate developers from needing to write in VoiceXML, CCXML, and other markups
  • 6.
    How do Iuse it with Grails? 6 ā–  Install the Tropo WebAPI Grails plugin (version 0.21) ā–  tropo-webapi-grails ā–  Provides the TropoBuilder object for building standard Tropo JSON documents ā–  TropoService for provisioning and servicing Tropo applications
  • 7.
    TropoBuilder 7 ā–  Builds Tropo JSON response documents ā–  Provides an array of JSON objects to control the Tropo-based applications hosted in the cloud ā–  ask, call, conference, hangup, message, on, record, redirect, reject, result, say, session, startRecording, stopRecording, transfer
  • 8.
    TropoService 8 ā–  Grails service for administering Tropo applications ā–  Abstraction around Tropo’s REST API ā–  Create, update, and delete Tropo applications ā–  Provision phone numbers, IM addresses, tokens ā–  Retrieve information about applications
  • 9.
    Tropo.com 9 ā–  Web-based administration UI ā–  Create, update, and delete Tropo applications in the cloud ā–  Provision telephone numbers (both local and toll- free) and IM accounts for your applications ā–  Application debugging tool ā–  Billing profile
  • 10.
    Tropo Development 10 ā–  Create your Grails application ā–  Add tropo-webapi-grails Grails plugin ā–  Create your starting endpoint in your Grails app ā–  Create application on tropo.com ā–  Need externally available starting endpoint for your Grails app ā–  Provision local phone number
  • 11.
    Tropo WebAPI 11 ā–  Use the TropoBuilder object to create Tropo-compliant JSON objects ā–  Tropo calls back to your application for instructions on how to power the IVR infrastructure in the Tropo cloud ā–  You application is a collection of interconnected endpoints, rendering Tropo JSON objects to control the IVR infrastructure in the Tropo cloud
  • 12.
  • 13.
    session 13 ā–  Sent to your application in the first Tropo request ā–  The callId field identifies this request body to a unique call in Tropo ā–  You will use the callId as the correlation identifier for all requests ā–  https://www.tropo.com/docs/webapi/session.htm
  • 14.
    result 14 ā–  Sent to your application in all subsequent requests from Tropo ā–  The callId field identifies this request body to a unique call in Tropo ā–  You will use the callId as the correlation identifier for all requests ā–  https://www.tropo.com/docs/webapi/result.htm
  • 15.
    say 15 ā–  Say something to the caller ā–  Can be TTS or pre-recorded audio ā–  Does not wait for user response ā–  https://www.tropo.com/docs/webapi/say.htm
  • 16.
    ask 16 ā–  Say something to the caller and wait for a response from the caller ā–  Can be TTS or audio file for say ā–  Response can be collected speech or touch-tone keypad (DTMF) ā–  The choices object specifies how Tropo handles user input ā–  https://www.tropo.com/docs/webapi/ask.htm
  • 17.
    on 17 ā–  Specifies event handling ā–  continue ā–  error ā–  incomplete ā–  hangup ā–  https://www.tropo.com/docs/webapi/on.htm
  • 18.
    hangup 18 ā–  Hangs up the current call. ā–  https://www.tropo.com/docs/webapi/hangup.htm
  • 19.
    record 19 ā–  Plays a prompt and then waits for a response from the caller, which it records ā–  Responses may be speech recognition or touch-tone keypresses (DTMF) ā–  At the conclusion of the recording, the collected audio file is sent to FTP or HTTP POST/Multipart Form endpoint
  • 20.
    transfer 20 ā–  Transfer an in-progress call to another destination or phone number ā–  Can be a phone number or a SIP address ā–  https://www.tropo.com/docs/webapi/transfer.htm
  • 21.
    startRecording stopRecording 21 ā–  Start and stop recording a call session ā–  Resultant recording can be sent via FTP or HTTP POST/Multipart form to a URL ā–  You have to provide an endpoint or FTP server to receive the binary file ā–  https://www.tropo.com/docs/webapi/startrecording.htm ā–  https://www.tropo.com/docs/webapi/stoprecording.htm
  • 22.
    Lessons Learned 22 ā–  Testing ā–  Test call flow in isolation by using a testing Tropo application and a testing endpoint to bootstrap the call session appropriately ā–  In the future, look to building an automated test runner that can be scripted and exercise the Grails app through HTTP calls
  • 23.
    Lessons Learned 23 ā–  The ask noinput and timeout APIs don’t work well ā–  Issues with audio getting played out of sequence ā–  Build this functionality into our call flow explicitly using on events
  • 24.
    Lessons Learned 24 ā–  Call recording is all or nothing ā–  Unable to start and stop recording to allow for omission of sensitive data recording ā–  We toggle recording for debugging call flow ā–  Keep it off for production usage
  • 25.
    Lessons Learned 25 ā–  Call duration can be difficult to determine ā–  Maintain a last Tropo callback timestamp on call session domain object ā–  Update the timestamp on each Tropo callback invocation ā–  Allows approximation of the call duration
  • 26.
    Lessons Learned 26 ā–  Abandoned calls can be difficult to determine ā–  We used a Quartz job in Grails ā–  Periodically inspect in-progress calls ā–  If last Tropo callback timestamp is beyond a specified threshold, set the call session to abandoned
  • 27.
    Contact Information 27 ā–  Twitter: @cbartling ā–  Blog: http://bartling.blogspot.com ā–  https://bitbucket.org/cebartling/tropo-presentations