This is a guest post written by Yuri Gadow, founder of Teeboxer; a service created with the goal of combining many Internet technologies, including Twilio, to help golfers get out and play more and spend less time dealing with golf while off the course.
Twilio is the key to Teeboxer’s ability to work for golfers away from computers where a quick text or call can easily beat a mobile app for convenience. So when Twilio started their “Coordinating People Contest” I knew it was a perfect fit—Teeboxer’s first feature is a golf round planner that helps golfers coordinate tee times. When they announced Teeboxer had won I thought I ought to write a short post on how it uses Twilio to handle text messaging and interactive voice response.
Teeboxer and Twilio are both software-as-a-services, a fancy way of saying web application, using cloud computing for their infrastructure. Teeboxer runs in the Rackspace Cloud and Twilio in Amazon’s EC2. They communicate using a markup language called TwiML they exchange using web requests (the same way your browser gets HTML from websites.)
When a person calls Teeboxer, they’re actually calling Twilio which makes a web request to Teeboxer with some information about the call, e.g., the caller’s phone number. Teeboxer looks up the user by the phone number and uses TwiML to tell Twilio what to do next. For example, if Jane verifies her phone number with Teeboxer and then calls from it, Teeboxer will lookup her name, determine Jane’s local time, find information about her next round, and instruct Twilio to greet her using TwiML that looks like:
<Gather numDigits="1" action="https://teeboxer.com/example" method="POST"> <Say voice="woman" language="en" loop="1"> Good morning Jane, your next tee time is 7:15am on Tuesday, February 8, at Pebble Beach. The forecast is sunny, with a high near 59. Breezy, with a north northwest wind between 21 and 28 mph, with gusts as high as 34 mph. Press one for more on your next tee time. Press two to turn off voice notifications. </Say> </Gather>
This tells Twilio to “gather” one digit (via touch tone) from Jane’s phone at any time while it’s talking to Jane and to send that digit back to Teeboxer at teeboxer.com/twilio/example—using the same method your browser uses to send forms to websites, i.e., HTTP POST.
Just like calls to Teeboxer, when a person sends a text to Teeboxer it goes to Twilio which makes a web request to Teeboxer with the message and information about the sender. Teeboxer looks up the sender and looks through the text message for a command it can act upon.
Once Teeboxer figures out how to respond, it gives Twilio a bit of TwiML. For example, in response to Jane’s directions text, Teeboxer would lookup her next tee time and tell Twilio to text message Jane a link to a Google map for that course with a bit of TwiML:
<Response> <Sms>Map for Pebble Beach: http://j.mp/dKiZR6</Sms> </Response>
That’s really all there is to it—the rest is just extrapolation and variation of these techniques.
You can follow Teeboxer’s technological side at twitter.com/teeboxerops