How to send SMS messages with Twilio

Knock integrates with Twilio to send SMS notifications to your recipients.

Features

  • Delivery tracking
  • Bounce Support
  • Per environment configuration
  • Sandbox mode

Getting started

We'll walk through a few steps to take in Twilio before jumping into how to configure Twilio within Knock.

Twilio setup

Before you set up your Twilio SMS channel in Knock, you'll need to take the following steps in Twilio.

  1. Sign up for a Twilio account if you haven't already.
  2. Get your first SMS-enabled phone number in Twilio. You'll use this as the "from" phone number in your channel configuration within Knock. (We also support Twilio short codes and messaging services, but we won't be covering those in this guide.)
  3. If your Twilio account is in trial mode, you'll need to pre-verify any phone numbers with Twilio that you plan to send to from Knock during testing.

Once you've completed those steps, you're ready to start sending SMS notifications with Knock.

Configure Twilio in Knock

You can create your Twilio channel under the Integrations > Channels page in the Knock dashboard. Once the channel has been created, you'll need to configure each of your Knock environments to work with Twilio.

Each environment requires a Twilio account ID, an auth token, and a "from" resource within Twilio from which to send messages. This "from" resource can be a Twilio phone number, short code, or messaging service. (If you are using a phone number, keep in mind that all numbers used in Knock must be in E.164 format.)

🔦
API console confusion alert. Keep in mind that to configure Knock, you are looking for your Twilio account ID and auth token (not your API key). You can find these in the Twilio dashboard under Account > General settings.

Provider configuration

Account IDstring*The account ID from Twilio
Auth tokenstring*The auth token from Twilio.
From phone numberstring*The phone number to send messages from.
Short codestring*The short code to send messages from.
Messaging Service SIDstring*The Messaging Service SID to send messages from.

Recipient data requirements

In order to send an SMS notification you'll need a valid phone_number property set on your recipient.

Delivery tracking

Delivery tracking for Twilio can result in the following status updates to your message:

  • The message delivery is confirmed and Knock updates the message to delivered
  • The message was not delivered due to bad recipient(s) and Knock updates the message to bounced
  • The message was not delivered due to an error reported by Twilio and Knock updates the message to undelivered