How can I write a REST API to receive an SMS via Twilio Number Using ASp.net Web Api

asp.net-web-api, sms, twilio

Solution

Twilio evangelist here.

All of our Quickstarts are translated to C# that uses the Razor syntax. You just need to select C# from the language drop down at the top of the page. Here is a direct link to the start of the C# SMS quickstarts:

http://www.twilio.com/docs/quickstart/csharp/sms

Also, you might want to check out a series of blog posts I wrote a while ago introducing Twilio to .NET developers, including one on using the Twilio .NET helper library in an ASP.NET MVC application:

- Twilio for .NET Developers - Part 1: Introducing the Twilio Helper Libraries

- Twilio for .NET Developers - Part 2: Adding Twilio Helper Libraries to your Project

- Twilio for .NET Developers - Part 3: Using the Twilio REST API Helper Library

- Twilio for .NET Developers - Part 4: Using the Twilio.TwiML Helper Library

- Twilio for .NET Developers - Part 5: Twilio Client, MVC and WebMatrix Helper Libraries

- Twilio for .NET Developers - Part 6: Creating SMS & Voice Application Flows using ASP.NET Web Forms

- Twilio for .NET Developers - Part 7: SMS & Voice Application Flows using ASP.NET MVC

Specifically for info on responding to text message you'll probably be most interested in Parts 1,2,4 & 7.

Lastly, if you hit the Twilio .NET helper library wiki on GitHub there are some code samples there:

https://github.com/twilio/twilio-csharp/wiki

I'll also point you at a blog post that developer Long Le wrote for our blog that shows how to reply to Twilio requests using ASp.NET Web API since there are a couple of details needed to do that:

http://www.twilio.com/blog/2012/11/building-twilio-apps-using-asp-net-mvc-4-web-api.html

Personally I find it easier just to use a standard ASP.NET MVC Controller, but thats just my personal preference.

Hope that helps.

Problem

I am new to Web Api/Rest API concept but I plan to use Visual Studio 2012 MVC4 Web Api. How the heck do I create an application to receive a Text/SMS Message via Twilio and send the response back? I have searched several articles here and at Twilio website but none of them give me any insight on how to use MVC4 Web Api. Can somebody please help me and show/give some examples?

Original source