Phone Home

Have you ever wanted to give out a single phone number that in turn dials multiple phone numbers? And whichever phone answers first speaks to the caller?

I had just this case recently when I wanted a phone number I could start putting on Voxeo news releases that would ring my multiple phones and also could conceivably also ring someone else’s phone number. The number is also not tied to a single person so that if someone else started handling press inquiries, the number could just be redirected to the other person’s phone number(s). (In the programming world, we would call this an “abstraction layer”.)

Here’s literally all you have to do in Tropo Scripting (outside of having a free developer account at Tropo.com)… it’s really just one line of code using the transfer command and provide an array of phone numbers to call. Here’s how it looks in python, my language of choice:

say("Please wait while we connect your call.")
transfer([" 14079678424"," 16037566424"," 14074555859"], { "playvalue":"http://www.phono.com/audio/holdmusic.mp3"})

All I had to do was:

  • login to Tropo.com
  • create a new application
  • create a new hosted file
  • copy / paste this code in and change the phone numbers
  • save the hosted file
  • save the application
  • add a new phone number to the application
  • wait a minute or two and start calling!

That’s literally it.

If python isn’t your thing, you scroll down the documentation page for the transfer command and see examples in JavaScript, Ruby, Groovy and PHP. They are all basically the same simple solution.

Now, what’s cool about Tropo is that because Tropo can work with IP communications / unified communications systems, I can tell the transfer command to also use a SIP address as one of the endpoints to call:

say("Please wait while we connect your call.")
transfer([" 14079678424"," 16037566424","sip:dyork@corpsip.voxeo.com"], { "playvalue":"http://www.phono.com/audio/holdmusic.mp3"})

This simple version works really well… but I can make a few other changes to it. Here’s a version that:

  • speaks with a different text-to-speech voice
  • provides an option for the caller to cancel the call (although they could of course just hang up)
  • covers the error condition of no one answering any of the phone numbers

The code is:

say("Please wait while we connect your call. Press star to cancel the call.", {"voice":"simon"})
transfer([" 14079678424"," 16037566424","sip:dyork@corpsip.voxeo.com"], { "playvalue":"http://www.phono.com/audio/holdmusic.mp3", "terminator": "*", "onTimeout": lambda event : say("I'm sorry, but nobody answered.")})

That’s it! Short and simple… and able to ring all the phones you want.

What’s also great is that I can add more phone numbers to this application on the inbound side so that I could in fact have a phone number in the UK or 40 other countries that call into this application… and then are transferred out to whichever phone I want to take the call on.

P.S. Sure, you can do this with services like Google Voice, but there are limits with some of those services. For instance, a Google Voice number is tied to your Google Account, so you may need to create another Google Account if you want a new Google Voice number. And while yes, you can add another number to your GV account for $20, it’s still tied to that one account. With Tropo, you can make as many of these type of applications as you want…

©2011 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Dial Multiple Phone and SIP Numbers & First to Answer Wins
  2. Create a Group SMS Service Using Tropo in 5 Lines of Code!
  3. Calling all C# developers! Now YOU can build voice, SMS, IM, Twitter apps with Tropo!

Originally from All Voxeo Blogs Feed