Skip to content

SMS Alerts Through Twilio

Goal: a DownBad alert arrives as a text message on your phone, sent and billed by your own Twilio account.

DownBad doesn’t send SMS itself. A Custom webhook can post straight to Twilio’s Messages API, and Twilio sends the text.

You need:

  • A paid DownBad plan. Webhook channels aren’t on the Free plan.
  • A Twilio account that is upgraded (not a free trial). Twilio’s trial doesn’t allow custom message bodies, so it can’t send DownBad’s text. See Twilio’s trial limits.
  • A Twilio phone number that can send SMS, or a Messaging Service.
  • Your Twilio Account SID and Auth Token, from the Twilio Console’s home page.
  1. Add the channel. In DownBad, go to Settings › Alerts, press Add webhook and paste this URL, with your Account SID in place of ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:

    https://api.twilio.com/2010-04-01/Accounts/ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Messages.json

    DownBad doesn’t recognize Twilio’s address, so the provider stays Custom. That’s what you want.

  2. Set the authentication. Under Authentication, choose Basic (username and password):

    • Username: your Account SID, the same AC… value as in the URL.
    • Password: your Auth Token.

    A Twilio API key works too: its SID (SK…) is the username and its secret is the password. Twilio recommends an API key for production, since you can revoke it without changing your Auth Token. DownBad never shows the password in test results or the notification history.

  3. Write the message body. Under Message Body, choose Form fields (application/x-www-form-urlencoded) and replace the starter text with one line:

    To=%2B15551234567&From=%2B15557654321&Body={{message}}%0A{{reason}}%0A{{link}}
    • To is the phone that gets the text. From is your Twilio number. Write both in E.164 form: country code and number, no spaces or dashes.
    • Write each + as %2B. In a form body a bare + means a space, and Twilio would read the number as invalid.
    • %0A is a line break. DownBad fills in each {{variable}} and encodes it for you; anything you type yourself is sent exactly as written.
    • Using a Messaging Service instead of one number? Replace From=%2B15557654321 with MessagingServiceSid=MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
    • To text more than one phone, add one channel per phone. Twilio’s Messages API sends to one number per request.

    The Custom webhook page lists every variable you can use, such as {{monitor.name}} and {{status}}.

  4. Press Test now. DownBad sends the integration test to Twilio with the settings on screen, saved or not.

  5. Press Create Channel (Save Changes when editing), then add the channel to the notification profiles that should text you.

Test now says Test sent. and the phone receives a text within a few seconds:

DownBad WebHook Channel Integrated

followed by a line saying it’s a test. On a test, {{link}} is empty. A real alert reads like “Shop is down”, then the failure DownBad recorded, then a link to the incident.

Twilio bills each text to your account. A message over 160 plain characters (70 if it contains characters outside the basic SMS set, such as emoji) is sent and billed as several segments, so keep the body short if cost matters.

Twilio rejects some problems straight away, and Test now says Test not delivered. with the HTTP status. Others pass that point and fail on the way to the phone, so DownBad reports Test sent. but no text arrives. Either way, Twilio’s error code tells you which: find it in the Twilio Console under Monitor › Logs, on the error log or the message’s entry in the messaging log.

HTTP 401, error 20003 (permission denied). The username or password is wrong, the Auth Token was changed, or the Account SID in the URL belongs to a different account. Copy the Account SID and Auth Token again. If you use an API key, check that it still exists and belongs to the same account as the SID in the URL.

HTTP 404. The URL is mistyped. It must start with https://api.twilio.com/2010-04-01/Accounts/, then your Account SID (starting AC), and end with /Messages.json.

HTTP 400, error 21211 (invalid To number). To isn’t in E.164 form. The usual cause is a bare +: write %2B15551234567, not +15551234567. Spaces and dashes in the number cause it too.

HTTP 400, error 21606 or 21659 (invalid From number). From isn’t an SMS-capable number in this Twilio account, or the + isn’t written as %2B. Check the number under Phone Numbers in the Console.

HTTP 400, error 21608 (unverified number). The account is a trial, which only texts verified numbers, and doesn’t allow your own message text either. Upgrade the Twilio account.

HTTP 400, error 21408 (region not enabled). Texting that country is switched off. Turn it on in the Twilio Console under Messaging › Settings › Geo permissions.

HTTP 400, error 21610 (unsubscribed recipient). That phone replied STOP to your Twilio number. It has to reply START before Twilio will text it again.

HTTP 400, error 21614 (not a mobile number). The To number is a landline or can’t receive texts. Use a mobile number.

Error 30034 (unregistered US number). You’re texting a US number from a US 10-digit number that isn’t registered for A2P 10DLC. Register a brand and campaign in the Twilio Console and add the number to the campaign’s Messaging Service.

Error 30032 (toll-free number not verified). Texts from a toll-free number to US or Canadian phones are blocked until Twilio approves its toll-free verification.

Error 30007 (message filtered). A carrier or Twilio judged the message to be spam. A short body naming your monitor, as above, rarely trips it. If it keeps happening, contact Twilio support with the message SIDs from the log.

No error at all. Check the phone’s blocked-numbers and spam-filter settings, and that To is the right number.

The bell says the webhook was switched off. Ten alerts in a row failed, often because the Auth Token was changed or the Twilio account ran out of balance. Fix the cause, then on the channel’s row in Settings › Alerts press Send a test message. A test that arrives turns alerts back on. Test now in the channel editor doesn’t, since it only tries the settings on screen.