At LeadSimple, we use Twilio to handle phone call routing. Twilio interacts with regular HTTP endpoints on your server to control calls and SMS messages, through a form of XML they call
I’ve been toying recently ideas on how to bring next-generation Erlang (Elixir) and next-generation telephony (Twilio) together. Toward that end, I made a little library this week to make generating TwiML from Elixir easy.
It looks like this:
defmodule YourModule do import ExTwiml def render do twiml do play "/assets/welcome.mp3" gather digits: 4, finish_on_key: "#" do say """ Please enter the last four digits of your credit card number, followed by the pound sign. """, voice: "woman" end end end end
YourModule.render will return the following XML as a string:
<?xml version="1.0" encoding="UTF-8"?> <Response> <Play>/assets/welcome.mp3</Play> <Gather digits="4" finishOnKey="#"> <Say voice="woman"> Please enter the last four digits of your credit card number, followed by the pound sign. </Say> </Gather> </Response>
The library is called ExTwiml. It’s available from Github or Hex.