Whether you're new to Twilio, or have been using our voice and SMS APIs for awhile, we hope you'll take a moment to experiment with Heroku - a simple place to deploy your Ruby apps.
Check out this video created by Morten Bagai over at Heroku demonstrating how easy it is to create a Twilio app with Sinatra and deploy it to Heroku, grab the sample code, and visit the awesome landing page they've set up at http://twilio.heroku.com to learn more.
We're very excited to share with you a user contributed Twilio Library for Cold Fusion, which was created by Jason Fill. It works just like our PHP helper library.
The author Jason Fill, uses the library for both his personal projects and his job at eLearningToolBox.com.
"I like
the idea of building polling system that can be used easily by anyone to
gather feedback. There is really so much that can be done by coupling voice
and sms to the web the possibilities are endless and exciting.
Working with Twilio is truly a breeze. The fact
that you only pay for what you use and their are no minimums is very nice.
I really enjoy the functionality and look forward to building some
more applications using ColdFusion and Twilio."
Thanks Jason!
Some information on Twilio Helper Library for Cold Fusion
The library helps to facilitate:
* Making requests to the Twilio REST API
* Constructing TwiML requests
* Validating Twilio request signatures
NOTE:This is the first version and should be considered in beta form. While all the examples have been tested there still may be some bugs.
-----
Have you build something that would benefit the Twilio developer community? Share it with us and we'll help spread the word. Just a drop a note to help@twilio.com, we're always listening.
With Trails, Hemant Bhanoo is making it even easier to develop Twilio applications in Rails with this library for using Twilio with the Rails framework.
Trails is build on top of the Twilio Ruby Library, and has functional test helpers so that you can simulate Twilio calling you app. When Twilio calls your application, the application recognizes whether it is Twilio calling or a web request. The controller is reusable and has views for displaying HTML or TwiML, depending on where the request comes from.
I first got a chance to play with Twilio when I was trying to scale our
customer service operations at Social Gold. Once I saw
how easy your platform is, I was hooked, and started building a few more toy
apps (www.xperilab.com) to sink my teeth into the service. But I quickly
found that testing my apps was tedious because I couldn't always test
twilio's interaction with my app, and wanted a better way to do that. Over
several months, and a couple of different apps, I copy/pasted my
'frameworky' code until I finally decided to pull it out into a library.
How long did it take to build?
It got built as a side-effect of my evening/weekend toy projects, overs the course of the last 5-6 months.
What are you thoughts on Twilio, feedback, suggestions for developers getting started?
Absolutely love you guys, end-to-end. At Social Gold, we draw a lot of inspiration from you guys in terms of how developer-friendly your product is.
If you had all the time in the world, what would you build with Twilio?
I love the idea of building really engaging games that only require a simple telephone, or SMS. I'm still playing around with ideas but I think that the telephone could actually be the ultimate viral platform.
Example Code to Get You Started
As Hemant mentions on Github, there is still plenty of room for contributors to step in and add to more functionality to Trails.
Have you built something using Twilio that you'd like us to share with our developer community? We would love to blog about it, please contact help@twilio.com and tell us about your creation. Whether its a simple app, enterprise solution, developer resource, or something else - we're listening and can't wait to try it out. Grab a Powered by Twilio banner while you're at it.
This past weekend we headed to Boston to hang out at Microsoft Research (lovingly called the NERD Center, for New England Research and Development) on the M.I.T. campus at Wordcamp Boston, and meet the passionate people gathering to learn and share their skills around Wordpress.
Wordpress is a powerful content management and blogging platform created by Automattic, with a highly active developer community focused on improving Wordpress.org, the open source version, and building themes, plugins and other productivity tools for content publishers.
Talking Twilio & the Future of Voice in Blogs on the Unconference Track
As part of the Wordcamp program, attendees could propose 30 minutes talks that the audience would then vote on. The talks with the greatest number of votes received an afternoon spot and our talk about using voice on your blog was one of the ones selected. Check out the talk and brainstorming session lead by Danielle:
Our simple click to call plugin is live now and available for download on the Wordpress repository. We've also open-sourced the code and you will find it on Github.
* Configure the admin settings of the plugin with your Twilio account details and preferences
* Add the code snippet anywhere on your blog (sidebar, header, body, etc.)
If you have questions about how to use this plugin, or suggestions for how we can bring voice and telephone to your blog, please drop us a note at help@twilio.com, we're always listening and are looking forward to discussing your ideas and planning for the future.
Over lunch today we were talking about how we wanted to make a Twilio app to ring in the New Year, and I wanted to make it something really social where people would feel more connected to the entire world after using it. Ambitious? Yeah. Impossible? Nope. So I built a Twilio app. Here's how it works...
TO TRY IT OUT*
415-483-1336
*you will get a phone call around 11:30pm PST
Step 1 - Call In and Leave Your Message for the World
The first step is to set up the file to handle incoming calls to my Twilio number.
Creating incoming.php
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Happy New Years from Twil ee oh! Record your News Years Eve wishes for the world after the beep, and press star when you are done.</Say>
Step 2 - Gather the Recording URLs and Phone Numbers from Inbound Calls
The Twilio REST API makes it very simple to get a list of recordings by account SID using the Recordings Resource, so the next step is to gather up a the recordings from incoming callers so we can put them all into a single TwiML file for the outbound call that will take place later tonight.
When you use the two URL examples below, an authentication window will pop up and you will need to use either your Twilio username and password or account SID and token.
Step 3 - Initiate a Massive Outbound Call with the REST API
Since
the phone lines are pretty jammed at midnight each New Years Eve, I'm
going to initiate the call at 11:30pm Pacific Time instead, mostly to
make sure people with cell phones will actually get it. The idea is
that every person who contributed to the massive New Years Eve message
will get to hear the entire thing.
I've got to get home before the traffic gets crazy, so I'm going to go ahead and post this and write the rest of the code when I get home. The last piece to add will enable me to initiate calls to all the people who have called in with the REST API.
In the meantime, you can learn about initiating calls with the Twilio REST API, or watch this video.
More Functionality... If I Have Time
I was thinking about how to add a truly "viral" feature to this, where each person who used it would be able to include more people in the experience.
What if the caller had the option to input a friend's phone number, so that they would receive a call asking them to contribute their New Years wishes for 2010? How hard would that be?
When I came downstairs this morning I was greeted by two bubbly and very sleep deprived Australians eager for some tea, and a chance to call Mum. My first thought - there's a Twilio app for that (or there will be soon)!
Being in the Christmas sprint, I decided I'd quickly code up an application that would make it easy for them to call a U.S. number from the landline at our house or any local phone, and be forwarded to their mom's, boyfriends, and other folks through a simple menu. 20 minutes later, we made our first call!
Setting Up the International "Calling Card"
Twilio doesn't provide international phone numbers, but you can set up a U.S. number and have it forward to an international destination using the <Dial> verb. You don't even need to use the REST API to make the outbound calls, its so simple!
Files to create:
* Handler for the incoming call, to greet the caller and read the menu, gather the menu selection keypress
* PHP handler for taking the keypress and directing the application to the right file to dial the number
* Files for each of the phone menu options, going to the different numbers to call
Setting up incoming-call.php
This first file is the one that I pointed the Twilio phone number to, to handle incoming calls. It greets the caller and reads them a menu of people to call, and asks them to press a number to start.
<Say voice="woman">Hey girls, ready to call someone? If you know your s\ election, you may make it at any time.</Say> <Say>Press 1 to Call Laurens Mom</Say> <Say>Press 2 to Call Jace</Say> <Say>Press 3 to Call Eleesa's Home</Say> <Say>Press 4 to Call Duh lane ah's Cell Phone</Say> <Say>To get help, Press 5 to Call Danielle</Say>
</Gather>
<Say voice="woman">Thanks forusingthis Twil ee oh app, created by Danielle. \ Happy holidays!</Say>
</Response>
Setting up make-call.php
After the caller has pressed as key, the application posts the results to make-call.php, so we need to create a php file that understands what to do next with that information, and route the call.
As you can see in the previous php script make-call.php, each selection directed the application to a different file. This file is a very simple piece of TwiML that uses the <Dial> verb to connect the call. Each one is pretty much the same, and looks like this:
<Say>Connecting you to Danielle, for help with this application..</Say>
<Dial>4256987497</Dial>
</Response>
It's Not Pre-paid, It's Pay-As-You-Go
The best part about this for Elisa and Lauren is that it isn't a prepaid card where they spend $50 and and are stuck with the card, even if they don't use it up. I'm billing them for exactly the amount they use, and they don't have to pay for it until after the fact. I can imagine turning custom pay-as-you-go calling cards into a really interesting business.
So there you have it. If you have any international guests in your home this holiday season, or are interested in going into the calling card business, this might be a good place to start. The app took less than 20 minutes to write, mostly because we were goofing around with the text to speech quite a bit, and is written with PHP.
You do need an upgraded Twilio account to get a phone number and make international calls, so maybe some Twilio minutes would be a good thing to ask Santa to bring you. Happy holidays!
Jeff came across this blog post, talking about using Twilio to build a voice blogging system that integrates with Wordpress, and as a Wordpress fanatic (yes, I know we use Typepad here) I was excited to give it a try and find out exactly how it works.
I thought it would be cool to make a system that lets me blog from my
cell phone. And so I started stitching it together. Seven hours
later, the sun was up, and I had worked out a system where I call a
special phone number and I get a prompt. I speak into the phone, just
like I’m leaving a message, and the system records my speech as a sound
file and then processes it to turn the speech into text. It then puts
together a post to my blog with a link to the sound file and the
transcription below. It’s not a substitute for carefully written
essays, but if you want to record and share a quick (I limit it to 2
1/2 minutes) thought with the world, it’s a pretty easy way to go about
it.
Getting Started with Twilio for Wordpress
Not into scouring README files to understand what it will take to get code up and running? That's okay. Here's a rundown of how to get started:
* make sure you have a server that runs PHP
* create a Twilio account - the free trial gives you a $30 credit
* upload the code to your server, and put it in a directory that's accessible online (so Twilio can reach it)
* edit remotePost.class.php - Change the $wpURL variable to the URL of your wordpress blog, but keep the 'xmlrpc.php' ending.
* edit remotePost.class.php - Change the $uname variable to the name of a user for your blog, and the $pass variable to that user's password.
* this is optional, but you can change the the image displayed on your blog for voice posts by opening up voicepost.php and replacing the image URL in the following line
Danielle here, and I don't know if you've ever had this experience, but last year we bought a whole lot of candy (well actually my husband bought an enormous box of king size candy bars at Costco) and then only a couple of kids stopped by through the course of the night. This year, I wanted to be sure we would get some trick-or-treaters no matter what, and I wasn't willing to rely on our sleepy neighborhood to provide the entertainment, so of course... I built a Twilio app.
My parents still find it funny when I point out there could be a Twilio app to solve almost any problem, as far-fetched as some of my ideas are, but it went to a whole new level when I sat with them on Saturday afternoon between preparing dinner to write and test my Halloween Hotline. We tracked down a bunch of silly Halloween sounds and here's what I came up with.
Give it a try! Call (206) 701-6291 to reach the Halloween Hotline!
This hotline is written in PHP and took about 20 minute, and less than 100 lines of code. You can get the code and instructions to make your own here.
Hey everybody, I'm Scott Wiersdorf and I like Twilio so much, I just finished writing a Twilio
helper library in Perl. You can make Twilio API calls in two lines of
code and it's small and clean (and the 3 dependencies are nearly always
installed everywhere).
I'd appreciate any feedback on either the code or the documentation to make it clearer:
What motivated you to write a Perl Helper Library for Twilio?
Curiosity, mainly, I think, and maybe a little self-promotion (full disclosure: I'm a semi-recently-laid-off-employee-turned-contractor, so I love doing anything I can get paid for! Unfortunately, I'm also a programmer at heart and love hacking on fun technology even when it doesn't pay the bills. Ask my wife. Actually, don't do that).
Seriously, though, I recently wrote an API for another REST-y service and wondered how hard Twilio's would be after that. (Answer: not hard at all. See answer for question 2), especially since I had an interest in it.
When I thought that if I wrote this library, I could place calls from *any computer* to *any phone* at *any time* and say *anything* in *two beautiful lines of code*--it was goodness too powerful for me to leave alone.
How long did it take to create the library?
It took 4-5 hours for me to grok Twilio generally (this is my first web-telephony experience--you can see a couple of questions I had in the forums that were quickly and expertly answered). Once I had my head around how Twilio worked, I wrote the API helper library in under an hour (it was quick because my head was already in a REST-y place), but I must have put in 3 hours to document how it worked. You can see that the documentation is *far* longer than the code it describes.
What else are you currently building with Twilio (or using this library for)?
Well, it's getting to be autumn in my neck of the woods (Pleasant Grove, Utah) and I wanted an early frost warning system so I knew when to pick the tomatoes.
I thought it would be neat if there were a web-to-phone application that I could plug into my weather/temperature alert system. After a little investigation, I stumbled upon Twilio and realized that writing a helper library was going to be far more fun than protecting my tomatoes.
Maybe I'll write some kind of general purpose web-to-phone reminder system.
Twilio note: make sure to check out our Weather By Phone sample code
If you had all the time in the world, what would you build with Twilio?
I think that's a funny question because I can't think of anything that would take very long to write with Twilio. All the ideas I can think of could be done in a day or two at the most.
Plus I'm really more of a systems guy than an application guy (when given the choice), so I'd probably continue to write helper libraries or, if I had access, work on the API itself. I think in a week or two I'll have the gumption to write a TwiML helper library for Perl.
I've toyed with writing a broadcast phone message system for my kids' school in case of an H1N1 breakout or snow days, etc. With the API helper library, it shouldn't take more than 10 lines on the Twilio API side and maybe that many on the TwiML side.
Or how about this: plug Twilio into a home automation system where you could check the status of your lights, alarm system, doors and windows, etc. temperature. Turn things on and off, etc. using Twilio to provide the voice command recognition and action dispatcher.
Thank you Scott, we will be adding your library to our list of helper resources and sending you a t-shirt and some other Twilio goodies. To anyone else thinking of making an open source contribution - let us know! We'd love to blog about it, send you some cool stuff, and help other Twilio developers become more productive in the process. Drop us a line at help@twilio.com anytime.
This is a quick demonstration of how to build a Twilio application entirely using the Visualforce Sites development environment inside of Salesforce. If you haven't built an application inside of Saleforce before, you can sign up for a free developer account here. Free force.com accounts give you access to the Visualforce and Sites technology however they are limited to a single "Site" and a single page of TwiML.
If you are new to Visualforce, log into your developer.force.com and click the "Setup" link at the top of the page. In the "App Setup" section in the bar on the left side, disclose the "Develop" section. You should see links to Apex Classes, Components, Pages, and Sites.
I am not a Visualforce expert and many of the techniques in this post are rather bruteforce :) If you have suggestions on how to improve this tutorial please let me know and i'll update the post accordingly!
Step 1: Create a Controller class
Once you have logged into developer.force.com and hit the "Setup" link at the top of the page, select "Apex Classes" link in the left bar and click the "New" button to create a new controller. Paste the following into the text field and hit the Save button.
public class TwilioPinController {
public boolean getIfCorrectPin() {
if (ApexPages.currentPage().getParameters().get('Digits') == '1234')
return true;
return false;
}
public boolean getIfIncorrectPin() {
if (ApexPages.currentPage().getParameters().get('Digits') != '1234')
return true;
return false;
}
}
The system will automatically name the controller "TwilioController" based on the the class name.
Step 2: Create Components
Select "Components" link in the left bar and click the "New" button to create a new component. Set the Label and Name to "TwilioCorrectPinComponent" and paste the following into the text field and hit the Save button.
<apex:component >
<Say>You entered the correct pin! Thank-you</Say>
</apex:component>
Click the "Component" link in the left bar and click the "New" button again to create a second component. Set the Label and Name to "TwilioIncorrectPinComponent" and paste the following into the text field and hit the Save button.
<apex:component >
<Say>Incorrect Pin.</Say>
</apex:component>
Step 3: Create Pages
Select "Pages" link in the left bar and click the "New" button to create a new component. Set the Label and Name to "TwilioStartCall" and paste the following into the text field and hit the Save button.
Click the "Pages" link in the left bar and click the "New" button again to create a second page. Set the Label and Name to "TwilioGotPin" and paste the following into the text field and hit the Save button.
Now for the final step! Select "Sites" link in the left bar and click the "New" button to create a new site. Set the Site Label and Site Name to "TwilioStartCall".
Set the Default Web Address to "index" so the full URL for the app is http://<your-app>-developer-edition.na7.force.com/index
Set the Active Site Home Page to "TwilioStartCall"
Now click the Save button and load http://<your-app>-developer-edition.na7.force.com/index in a web browser. You should see the TwilioStartCall i.e., "Hello...".
Now comes the 'hacky' part. Because the PageReference setRedirect() method uses javascript to redirect the browser to another page (not an HTTP 301/307), Twilio can't use the standard setRedirect() method for navigating a set of sites pages in TwiML. Instead, we need to create a separate "Site" for each subcomponent of our application.
The next step is to create a new Site for the TwilioGotPin page. IMPORTANT: free force.com developer accounts are limited to a single Site :( Click "Sites" link in the left bar and click the "New" button to create a new site. Set the Site Label and Site Name to "TwilioGotPin".
Set the Default Web Address to "TwilioGotPin" so the full URL for the App is http://<your-app>-developer-edition.na7.force.com/gotpin
Set the Active Site Home Page to "TwilioGotPin"
Now click the Save button and load http://<your-app>-developer-edition.na7.force.com/gotpin in a web browser. You should see the TwilioStartCall i.e., "Incorrect Pin". Now try http://<your-app>-developer-edition.na7.force.com/gotpin?Digits=1234 and you should see "You entered the correct pin!".
The finally step is to wire the application up to your Twilio phone number. If you want your users to call a phone number and interact with your application, go the Phone Numbers page in the Twilio account portal and associate http://<your-app>-developer-edition.na7.force.com/index with one of your Twilio phone numbers. If you want your users to receive calls from your Salesforce application, then set the Url parameter of your outgoing call REST API request to http://<your-app>-developer-edition.na7.force.com/index. We'll leave make REST API requests to initiate calls from inside Salesforce for another post.
So that's all folks. You can now build call control applications inside of Visualforce sites that interact with your Salesforce data. One could imagine all kinds of neat applications:
Build a company phone/PBX inside of Salesforce
Create phone numbers for your sales team to input data into Salesforce over the phone
Build a voice interface for your customers to interact with your Salesforce data
Use Twilio to implement a click-to-call site that lets you record calls with your customers and automatically add recordings Salesforce
Automatic reminder calls for important events inside of Salesforce