3 Serverless Apps You Can Build With Nothing But TwiML

February 01, 2017
Written by

Twilio Bug Logo

Close your TextEditor. We’re not git pushing anything to Heroku this time. You can build a few handy Twilio apps with nothing but TwiML Bins and a few lines of XML.
 
TwiML Bins allow you to write and host code from your account portal. This means you don’t have to worry about that localtunnel going offline when you close your laptop, or pushing new code to a server. All you need to build these apps is Twilio account. We’ll handle the rest.
 
Things You’ll Need

  • A Twilio Account (sign up here)
  • One Twilio number for each hack you want to build

What We’re Building

  • An SMS Forwarding App
  • A Conference Line
  • A Rick Roll App

It’s go time.

SMSForwarding

Let’s say you are picking up a couch on Craigslist and maybe don’t want all of the internet to have your personal number. You can set up SMS forwarding using 4 lines of code.
 
Head into your Console, and select “Developer Center” This is where we’ll be doing the bulk of our work. Click “TwiML Bins” and drop the following code in the TwiML Bin.
 

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Message to="+15556667777">{{From}}: {{Body}}</Message>
</Response>

 
Look for the “Valid TwimL” icon at the bottom of the TwiML bin. When you see that green check mark, that means you’re good to go. Give your TwiML Bin a friendly name like “SMS Forwarding”, and click save. Head back to your phone numbers page by clicking the “#” icon. Select the phone number you bought, and head to the “A Message Comes In” field under “Messaging”.
 
Select TwiML then choose your “SMS Forwarding” TwiML bin in the field to the right. Hit save and try out your hack brand new SMS forwarding app.

Here’s what selecting your TwiML Bin looks like:

SelectTwiMLBin

One down. Two to go.

ConferenceLine

You don’t need to download that app or enter in a mile long PIN code. You can build your own conference line. This is all the code you need:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say> Thank you for calling [your name]'s Conference Line. You'll be connected shortly </Say>
    <Conference beep="true">Conference Line </Conference>
 </Response>

 

After you’ve entered this code into a TwiML bin, name it, and save it just like before. Head to the phone numbers page and click on the number you want to use for your conference line. Under the “Voice” field, click the drop down menu next to “A Call Comes In” and choose “TwiML”. Then scroll to the right and select your Conference Line TwiML Bin and hit save.

Next, grab some friends and start a party on your conference line.

RickRoll

This one is for the telemarketers, or friends you’re trying troll. Next time you have to give out a number, but don’t really want to, give out your RickRoll number. Fire up a TwiML bin and name it “Rick Roll” then drop this code in.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Play>http://demo.twilio.com/docs/classic.mp3</Play>
</Response>

You can go through the same steps as you did previously to assign this TwiML bin to your RickRoll number. Head to your phone numbers page and click through to your Rick roll number. Select “TwiML” From the drop down menu of “when a call comes in” and choose your Rick Roll TwiML bin.

You now have three apps that are ready to rock!
If you have any more TwiML Bin ideas or want to dive deeper into hacking with Twilio, shoot me a note at kyleky@twilio.com.