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.
- 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.