In line of business apps or large enterprise apps you must have seen some automation for sharing feedback over email and connecting over Live Chat. Phone and SMS are another effective way to connect. Twilio as a product allows you to achieve automation of SMS and voice calling. It can be used for different applications, especially for technical support with clients.Twilio allows developers to programmatically make or receive phone calls and text messages using rich set of APIs
This article will help you to understand how to deploy a Twilio integrated web-app on Azure to make phone calls and SMS.
How Twilio free trial works?
When you use Twilio as services then you have to sign up, this includes a free balance for you to experiment with. When your balance is getting low, Twilio will send you an email with information to upgrade your account. See the last section of this article for pricing.
Here are some tips to for using free Twilio account -
Phone numbers:
SMS:
Voice:
Note: To start using your Twilio phone number without these restrictions, just upgrade your account.
How to get a Twilio number?
To get a twilio number you need to follow below steps -
Step 1
Go to www.twilio.com , click on sign up and put your valid information and click on get started.
Step 2
Verify your phone number.
Step 3
After your phone verification, you can see your dashboard where account SID, authentication token etc. are visible.
Step 4
Go to All Products and Services > Phone Numbers > Get Started > Get Your First Twilio Number.
In this screen there is a by default number which provided by Twilio. If you want another number then click on search for a different number. When you click on search for a different number then it shows below screen.
In this you choose your capabilities accordingly your service. Once you have chosen your number, you’re good to go!
You can see your Twilio number in Manage Numbers > Active Numbers tab.
Make calls and SMS using .net + Twilio and host it on Azure.
Here we are using ASP.NET MVC application for demo purpose. However, you can call API from any type and project format like a simple console application. Here are steps to make phone call or SMS from your application using Twilio. This application will be then hosted to Azure as Azure Web App. For demo purpose, phone numbers are declared as hard coded string however in real scenarios, it can be fetched from database.
Step 1 -
Open your solution in Visual Studio and Search for Twilio NuGet package and install it.
Step 2 -
After installing NuGet Packge then create an action for a view. In this view there are 2 buttons “call” and “Send Text”. On hit of “call” call should go with pre-defined recorded message and on “Send Text” SMS should go.
Step 3 -
Add your Twilio SID and AUTH TOKEN into your web.config file.
Step 4 -
After change into your webconfig file then move to post method of your action where we add code for make calls and send SMS.
Code for making call:
In options.From put your twilio number.
As mentioned in this method there is aURL which comes from Twilio-Provided site to return the TwiML response.You could instead use your own site to provide the TwiML response. In the TwiML response, following xml file is included where there is a message:
Code for send message:
Note: While doing SMS or call the non-twilio phone number must be verified.
Publishing your Twilio integrated Web App on Microsoft Azure:
When all done with coding then next step is to deploy your web-app on Azure. For that follow these steps-
Running Twilio integrated in Azure Web App:
Now you can see actual output on your mobile device.
And when you click on make call button then it shows following output
For pricing details check following link:
https://www.twilio.com/voice/pricing
Summary:
Twilio is the smartest and fastest way to make phone calls and SMS from your application whether it is on premise or hosted on cloud platforms like Microsoft Azure. APIs are well documented and overall integration is very easy and smooth. Give a try to Twilio for your app today.