Twilio Integration

Set up HookWatch to receive Twilio webhooks for communication events like incoming SMS messages, voice calls, and delivery status updates.

Prerequisites

Step 1: Create a HookWatch endpoint

  1. Go to your Endpoints page
  2. Click "Create Endpoint"
  3. Enter a name like "Twilio Webhooks"
  4. Enter your destination URL (where you want webhooks forwarded)
  5. Copy the generated webhook URL

Your HookWatch URL will look like:

https://hook.hookwatch.dev/wh/abc123xyz

Step 2: Configure Twilio webhooks

For SMS/MMS:

  1. Go to the Twilio Console
  2. Navigate to Phone Numbers > Manage > Active Numbers
  3. Click on the phone number you want to configure
  4. Under "Messaging", set the webhook URL for "A message comes in"
  5. Paste your HookWatch URL and set the method to HTTP POST
  6. Click "Save"

For Voice:

  1. On the same phone number configuration page
  2. Under "Voice", set the webhook URL for "A call comes in"
  3. Paste your HookWatch URL and set the method to HTTP POST
  4. Optionally set a status callback URL for call status updates

Common webhook events:

Incoming SMS/MMS
Message delivered
Message failed
Incoming call
Call completed
Call status update
Recording completed
Transcription ready

Step 3: Verify webhooks on your server

Twilio signs webhook payloads using HMAC-SHA1. HookWatch forwards the X-Twilio-Signature header so you can verify authenticity.

You'll need your Auth Token from the Twilio Console dashboard.

Node.js / Express

Important

Twilio sends webhooks as application/x-www-form-urlencoded, not JSON. Make sure your server parses URL-encoded form data.

Twilio webhook parameters

Twilio sends data as form parameters. Here are the key fields for SMS webhooks:

ParameterDescription
MessageSidUnique identifier for the message
FromSender's phone number
ToRecipient's phone number
BodyThe message text content
MessageStatusStatus of the message (queued, sent, delivered, failed)

Testing the integration

  1. Send an SMS to your Twilio phone number from any phone
  2. Make a phone call to your Twilio number
  3. Check your HookWatch Events page to see the events

You can also use the Twilio API to send test messages programmatically.

Common issues

Signature verification fails

The signature is computed using the full webhook URL including the protocol. Make sure the URL in your verification code exactly matches what Twilio has configured.

No TwiML response error

Twilio expects a TwiML XML response for voice webhooks. If your server doesn't respond with valid TwiML, Twilio will play a default error message to the caller.

Status callbacks not arriving

Status callback URLs must be configured separately from the primary webhook URL. Set the status callback URL in the phone number configuration or when making API calls.