Home > Uncategorized > Handling inbound voice calls & inbound #SMS with #Twilio

Handling inbound voice calls & inbound #SMS with #Twilio


For $1 a month, you can “buy” a phone number from twilio, and with that, you can intercept inbound SMS AND voice calls to that number. I’ve only started to experiment with this, but I set up a web hook and captured the Querystring to see what happens when you SMS the number, and when you call it.

These are the querystring variables (I’ve put XXXX on some sensitive data)





Sending SMS via C# is easy done via their library, but If you want to use WebClient, or an older version of .NET, you can use a HTTP post as follows;

However, of course you’d always prefer to use www.freebiesms.co.uk ! 🙂

string strUrl = “https://api.twilio.com/2010-04-01/Accounts/” + username + “/Messages.json”;
string strPostdata = “To=” + HttpUtility.UrlEncode(“+” + To);
strPostdata += “&From=12XXXXXXXX”;
strPostdata += “&Body=” + ISOEncode(Message);
WebClient wc = new WebClient();
wc.Headers[“Content-Type”] = “application/x-www-form-urlencoded”;
string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(username + “:” + password));
wc.Headers[HttpRequestHeader.Authorization] = string.Format(
“Basic {0}”, credentials);
string strStatus = “”;
strStatus = wc.UploadString(strUrl, strPostdata);
catch (WebException ex)
strStatus = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: