TwiML Verbs

When you make a request to Twilio, you use an HTTP query with a RESTful URL. The result comes back in XML which is then converted to Components. That's the Client side of Twilio.

Sometimes Twilio establishes a request to a web server, and it expects back XML (TwiML). Twilio will then parse the TwiML and do things like dialing a new phone number, recording an existing call, or establishing a conference. Twilio calls to your server, so we need server components, and that's where the Twilio Server Library .NET got started.

The developer on the server side doesn't need to know anything about the TwiML that needs to get generated. The developer uses TSL.NET to instantiate objects (Verbs), set parameters, and make method calls. The final method, .Respond() or .Render() will take all the data created for a response to Twilio, and convert it all to TwiML. Generally that XML data is sent directly back to the Twilio server as a response to its query.

Examples of verbs include Dial, Hangup, Play, Record, Say, and Sms. The response to a Twilio request is created starting with a Response verb. To that Response object, a number of other nested objects can be added. TSL.NET properly re-structures the nested objects into nested XML.

All verb classes derive from the Verb class. So in the NebulaRnD.TwilioServer project, in the Verbs folder, you will find the abstract class Verb, and VerbDial, VerbConference, VerbGather, VerbPause, VerbSay, VerbSms, and others. Each of these looks very similar. Some Verbs can encapsulate other verbs, like Dial can have a nested Conference, but others like Say cannot have nested verbs.

Twilio documents some verbs as Primary and others as Secondary, but in TSL.NET all verbs derive from Verb and there is no distinction among them.

SMS is fully supported as of v0.2.1.

Last edited Jul 1, 2010 at 12:40 AM by TonyGravagno, version 3


No comments yet.