Other Documentation Pages

Status

I think it's time to retire/close this project

Overview

If this page doesn't answer your initial questions, please see the FAQ page. Start a Discussion if you have other questions.

What is Twilio and why would I want to use this TSL.NET library?

Visit http://twilio.com to see what they're about. The idea is that rather than getting your own PBX or using an environment like Asterisk, you can leave the complex part of Telephony to Twilio servers. You just write code that drives outbound phone calls, and code that controls inbound or outbound calls in progress. TSL.NET makes it easier for you to generate the XML that Twilio uses to control the phone calls.

The documentation on the Twilio website is required reading for understanding how this library works.

What does the XML look like that we're generating?

Here are a couple examples:
<?xml version="1.0" encoding="UTF-8" ?>  
<Response> 
  <Say>Hello World</Say>
  <Play>http://api.twilio.com/Cowbell.mp3</Play>
</Response>
and
<Response> 
  <Gather numDigits="1" action="conferencejoin.aspx"> 
    <Say>Press 1 to join as a listener</Say> 
    <Say>Press 2 to join as a speaker</Say> 
    <Say>Press 3 to join as a moderator</Say> 
  </Gather> 
</Response>

What does TSL.NET look like?

  • All TwiML XML nodes correspond to documented Verbs.
  • There is a TSL.NET class for every TwiML Verb.
  • There is an abstract Verb base class and all verbs derive from this class.
  • XML elements have attributes, and each verb has unique attributes.  Therefore, there is a unique class for every verb attribute. So for example in TSL.NET:
    • Verb "Dial" has attributes DialAction, DialMethod, DialTimeout, etc
    • All of these attributes derive from abstract class DialAttribute.
    • All attributes for all verbs derive from abstract class VerbAttribute.

Here are a couple code samples that use TSL.NET:
Hangup hangup = new Hangup();
Response r = new Response();
r.AddDial("1234567890" , new DialTimeout(30));
r.AddSay("Don't forget to do something nice!" ,
    new SayVoice(Voice.Woman));
r.Append(hangup);
r.Respond();
string result = r.Xml;
and
Response r = new Response();
r.Append(
    new Dial(
        new Conference("LoveTwilio") ,
        new DialAction("handleLeaveConference.aspx") ,
        new DialMethod(HttpMethod.Post) ,
        new DialHangupOnStar(true) ,
        new DialTimeLimit(30)
        )
        );
r.Respond();
return r.Xml;

To create TwiML

  • Create a Response object
  • Add objects that derive from Verb
  • Execute the Render() method
  • Get the TwiML from property Response.Xml

Creating Verbs and Attributes

There are various ways to construct verb objects to be added to the response.
  • Create a new object and add attributes in the constructor.
  • Create a new object and add attributes afterward to the resulting instance.
  • Use Response.Add methods (AddDial, AddPlay, etc) to create and add new instances directly into a response or Existing objects are added to the response using the Append(Verb) method.

TSL.NET includes both a TwiML server library and a REST client library to initiate phone calls, retrieve account data and perform many other operations as documented on the Twilio website.

Download

The current Beta solution can be downloaded here

Last edited Apr 2, 2013 at 5:27 PM by TonyGravagno, version 10

Comments

No comments yet.