cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Dispatch phone calls with Tropo

1521
Views
6
Helpful
2
Comments
Cisco Employee

It’s 3am, and I’m abruptly woken up from my deep sleep. The light from my phone’s screen is so bright I can barely read it to see who is calling. I notice it’s from the Google Voice number. It’s a nurse calling our GALS (Giving Austin Labor Support) hotline asking if a volunteer doula (a birth partner) is available for a birth. I’m barely able to comprehend what is going on so I listen intently to the nurse and repeat what she says to make sure I get the message. After our call ends, I rub my eyes and hope someone has signed up to be on-call tonight. I go online to our group calendar, and nope no one is on-call. Then I send out a group text asking if anyone is available to go the hospital. Remember it’s 3am and a few replies trickle in, but no one is available yet.  If the text was sent in the middle of the day, I’d get a lot more replies, but the night is always a shot in the dark.

One by one I call each volunteer asking if she is available to volunteer right now. This process is time-consuming and repetitive and did I mention it’s the middle of the night? I am one of the dispatchers, and I noticed I was repeating the same message over and over again to each person until I find one person who can go out to the hospital. This is where Tropo comes to the rescue.  I’m creating an application using Tropo’s API to send out calls to volunteers asking for immediate help. With a click of a button I make the app send out phone calls that will play a text-to-speech script and include IVR prompts to transfer the call back to me. This means that the app makes the calls for me, and I get called if the volunteer indicates she is available.

Note: I’m not finished writing the application and there are some kinks to work out, so this blog post is part 1 of a series so you can see how I write the script from start to finish.

Part 1: Write an application that will call one volunteer, and ask if they are available to help.

Part 2: Update the application to call multiple volunteers

Creating the application

After I registered for an account on Tropo.com, I created a new Python application. Below is the script I used to initiate the call. You can see that I have 3 parameters that I’ve passed in – the volunteer’s name and phone number, as well as the name of the hospital requesting a volunteer. I’m using the following Tropo Scripting API’s:

  • Say() – uses text-to-speech to say a message to the caller
  • Ask() – asks the volunteer if they can go to the hospital or not
  • Log() – logs the call events and the volunteer’s decision
  • Transfer() – transfers the call to the dispatcher

tropo-script-gals.jpg

I found the API methods super easy to use and fun to play with. For instance, you can change the voice of the text-to-speech audio to a British speaker. Instead of using text-to-speech you could use a recording of your own voice.

Executing the application

Now that I’ve created the script, I need to execute it. I created a RESTful request which includes the token for my application, the volunteer’s name and number, and hospital name. Notice the URL parameters are exactly the same as the variables in my application. In this example I used the method GET, but you could just as easily use POST with a body. If you are using JavaScript to make a POST request, you might run into a CORS issue with your browser so the workaround is to use GET.

rest.jpg

So when I put it all together, I use the command prompt to run the python script above:

cmd.jpg

From the screenshot you can see I get a 200 OK response, which means the request was sent successfully to my Tropo app.  Then Tropo runs my app and dials the volunteer’s number. The volunteer answers the call and can then enter the number 1 to be transferred to the dispatcher (me) or enter the number 2 to log her as unavailable.


Next Steps

Now that my app can make one phone call to a volunteer, my next step is to have it make multiple phone calls. I could either make it call everybody at once, or call each person one at a time. If I choose to do the former then, then I could end up with several people calling my phone at the same time. This would not be an ideal situation for me. Therefore, I think it makes more sense to have the app call each person one at a time until someone indicates they are available. What do you think my next steps should be?

2 Comments
Cisco Employee

Some thoughts:

  • Call one person at a time, if successful, then you don't have to call the others.
    • If time is critical, you may call 2 or more people at the same time.
  • option #1 Have the Python Application read a list of volunteers instead of a fixed list in the Python code
    • Maybe check the volunteering history and based on that define the order of calling (based on previous participation, previous time of participation)
  • option #2 Have other app call the Python script, passing volunteer / hospital details from it's own DB.
  • If a person was unavailable at a given night (after pressing '2'), don't call that person again if there's another request the same night.

Where are you with "Part 2"?

DJ

Cisco Employee

Hi DJ,

Thank you for your suggestions. I've been busy working on Cisco Spark and haven't had a chance to work on Part 2 yet, it'll have to wait until after the holidays.  I would love to hook up the application to a database to make it more flexible. For time constraints I simply hard-coded volunteer and hospital information.

I like the way you are thinking about an app that adapts to previous volunteer history. We have some volunteers that are only available on weekends, not week days and vice versa. Including that kind of information in the database will ensure limited and efficient calls are made.

I also plan on re-writing the sample code above. As I've learned more Python I now see it's a bit sloppy.

Thanks for you comments,

Adrienne

Content for Community-Ad
August's Community Spotlight Awards
This widget could not be displayed.