Archive for category Web Development
C# TwiML Library
Posted by Tyler Kline in C# Development, Web Development on January 20, 2011
A project I am currently working on requires integration with Twilio for Voice/IVR capabilities. In addition to very competitive pricing, Twilio offers an extensive API for everything from provisioning numbers to call control. They use their own custom markup, named TwiML, to handle the majority of the call control functions.
I have thrown together a small set of wrapper classes to speed the integration of TwiML, specifically when using ASP.NET on the backend. The library is MIT Licensed, and if anyone is interested, I can throw a couple of quick samples together on usage. I am currently not using every TwiML feature in my project (although all functions of the version 2010-04-01 API are supported), so I haven’t fully tested every inch of code, but I believe it’s solid. If not, feel free to tweak as needed and drop me a note with any updates you make.
Here’s a little sample of usage:
using TwiMLSharp; protected void Page_Load(object sender, EventArgs e) { // Get a little info about the call, using the TwiMLRequest TwiMLRequest request = new TwiMLRequest(Request.Form); string caller = request.From; // Start a response TwiMLResponse response = new TwiMLResponse(); // Say something response.Say("Hello, you are calling from " + caller); // Play a little tune response.Play("http://mydomain.com/music.mp3", null); // Dial out and attempt to transfer, to one of 2 possible numbers Dial d = response.Dial("http://gohereafter.com", null, 5, null, null, null); d.Number("+12125551234", null, null); d.Number("+12125559876", null, null); // Dump the XML to the page Response.Clear(); Response.Write(response.ToXML()); }
Without further adieu, I present TwiMLSharp
