Passing data in a Signal

JustinDupree -

Injecting data into a running Tropo application can be accomplished through the signals API. Using the API to send data into an application, rather than just interrupting an application just requires adding a "value" parameter to the API call.

In this example, imagine that holdmusic.mp3 is a long-running audio file that is hours long. The say function thus becomes a never-ending hold music. The signal is sent while this music is running, and contains a phone number as the value parameter. The contents of the Signal's value parameter is returned in the say's return object, allowing it to be used later on in the code.

This example code is written in Ruby, but can be implemented in any language, Scripting or WebAPI

result = say "http://www.example.com/audio/holdmusic.mp3"
say "transferring you now"
transfer "+#{result.value}"

To end the hold music and pass the value to the Ruby code, make a signals API call that looks like this:

https://api.tropo.com/1.0/sessions/:id/signals?action=signal&value=:number

Replace the :id with the session ID for the session you wish to alter, and :number with the phone number you wish to transfer to.

Have more questions? Submit a request

0 Comments

Article is closed for comments.