SMS
Twilio
Learn how to use the Twilio provider to send sms notifications using Novu
You can utilize the Twilio API to communicate with your customers using SMS messaging. Let’s look at how you can do that:
Setting up Twilio
- First, go to Twilio and create an account, probably starting with their free trial.
- You’ll be asked to verify your email and your phone number. Get them verified.
- Once you’re done with that, you’ll get an option to ‘get a Twilio phone number’ from your Twilio console.
- Click on it to get your Twilio phone number.
When first using Twilio there should be an option to get a Twilio phone number in the main console. Otherwise, you may have to Buy a number from that link to begin using it. Assuming this is the first run though, utilize the free number given to us.
Simply follow one of their many Tutorials within their docs to understand every part of the process.
Irrespective of the language you use, the process is the same:
- Load the Account SID and Auth token into the code, using some sort of safe environment such as .env variables. Nobody should have access to this but you.
- Create a client object from Twilio that take the SID and Token as variables then create a message with the client.
- A message is an object that has three things:
- that free number from earlier,
- the number you would like to send to, and
- a body message that you want to send through SMS.
Creating a Twilio integration with Novu
Creating a Twilio integration with Novu is quite simple. Just follow these steps:
- Visit the Integrations Store on Novu.
- Click the “Add a provider” button.
- Locate Twilio and click on the
Disabled
button and mark it asActive
. - Click on the Connect button.
- Go to your Console on Twilio and access the Account Info section at the bottom of the page
- Enter your
Account SID
,Auth Token
andTwilio Phone Number
. - Click on the Save button.
- You should now be able to send SMS notifications using Twilio in Novu.