Twilio SMS API Tutorial - Send SMS To Users From Your Website or Application

Sameer Saini July 19, 2022
0 likes

Do you want to send SMS notifications alerts or verification to phone numbers of your users from your website or application Twilio offers SMS APIs in which you can reliably send and receive text messages.

So let's see how you can add Twilio SMS APIs to your application.


Creating an account with Twilio

To begin with, we need to create an account with Twilio so go to https://twilio.com and click on the signup page once you have given all the details
and verified yourself you will come to this page where we want to configure the services we want to use with Twilio.

We will then select "SMS" from the first drop down.
Then we will select the use case for which we want to integrate Twilio into our website or application. For this example, I have selected "Alerts and Notifications" .



The next question is how do you want to build with Twilio.

I want to build it with ASP.NET and C# code so I'll select "With Code".

From the next option "What's your preferred language" question please select C#.

After making the selections, click on "Get Started With Twilio" and this will redirect you to https://console.twilio.com.

On the home page, we can see that Twilio has generated us an "Account SID" or Auth Id and an Auth Token which is also called an "API Key or Secret".

As it says on the home page, you should never share your auth token or api key with anyone else and should always store it securely in the server.

If you store the API key in the client i.e. HTML, anyone would be able to see it and use it.


Get A Twilio Trial Phone Number

To use SMS, you will need a phone number from Twilio. On your trial account, you can get one free USA or Canada phone number. To get a local phone number outside of USA or Canada, you may need to upgrade your account and meet regulatory requirements.

Then we click on "Get a trial phone number".

Install Twilio CLI

Then we need to install Twilio CLI onto our machine.
For that, we need to first check if we have npm installed.
You can check the version of node installed into your machine by the following command in your command prompt or terminal window:Once we have confirmed that we have a version of node installed, we will go ahead and install Twilio CLI.
In command prompt or terminal window, type the below command:
npm install twilio-cli@latest -g
Press enter to install.


Comments

You must be signed in to comment.