Skip to content

feat(twilio): add Twilio provider (SMS/MMS/WhatsApp) (v1.18.0) - #1

Merged
guilhermegoulart1 merged 1 commit into
mainfrom
feat/twilio-provider
Jun 24, 2026
Merged

feat(twilio): add Twilio provider (SMS/MMS/WhatsApp) (v1.18.0)#1
guilhermegoulart1 merged 1 commit into
mainfrom
feat/twilio-provider

Conversation

@guilhermegoulart1

Copy link
Copy Markdown
Collaborator

Summary

Adds the Twilio Programmable Messaging provider (SMS, MMS, WhatsApp), completing the long-standing "Coming Soon" entry. Architecturally mirrors the Meta Cloud API provider: single endpoint (https://api.twilio.com/2010-04-01), multi-tenant via per-call credentials (Twilio subaccounts), HTTP Basic auth with either Account SID + Auth Token or an API Key pair.

What's included

Provider (packages/core/src/providers/twilio/)

  • client.jsTwilioProvider, auth resolution, form-urlencoded request()
  • messaging.jssend, sendSms, sendMms, sendWhatsApp, sendContentTemplate, get, list, listNextPage, redact, delete
  • media.jslist, getInfo, download (follows the 302 to the CDN), delete
  • account.jsgetAccount, listPhoneNumbers, listMessagingServices, listSubaccounts, verifyConnection
  • webhooks.jsparseTwilioWebhook (inbound + status callbacks, form-encoded), validateTwilioSignature (full X-Twilio-Signature HMAC-SHA1, zero-dep, constant-time)
  • errors.jsTwilioApiError + TWILIO_ERROR_CODES + isRetryable
  • twiml.jsmessagingResponse, emptyMessagingResponse, redirectResponse
  • addresses.js — channel-address helpers (extracted to avoid a circular require)

Integration — registered in the provider registry / parseWebhook / validateWebhookSignature; exported from src/index.js; exports map + version bump to 1.18.0.

Docs & examples — full section in docs/providers.md, README quick start + channel table, CHANGELOG entry, and a runnable examples/twilio Express app with an offline smoke test.

Design note

The generic validateWebhookSignature(provider, payload, sig, secret) dispatcher doesn't carry the request URL, but Twilio signs URL + sorted params. For Twilio, payload is { url, params } (documented in JSDoc + docs/providers.md). The idiomatic path remains the dedicated validateTwilioSignature(url, params, sig, authToken).

Verification

  • Example smoke test: 19/19 passing (parser SMS+WhatsApp, status callbacks, signature roundtrip, TwiML, error mapping, generic dispatch)
  • Send-path tested with mocked axios (channel prefixing, auth, multi-media, form encoding)
  • ESLint: 0 errors across packages/core/src, 0 warnings in Twilio files
  • Detected & fixed a circular dependency (extracted addresses.js)

🤖 Generated with Claude Code

Official Twilio Programmable Messaging integration mirroring the cloud-api
provider shape: single endpoint, multi-tenant via per-call credentials
(subaccounts), HTTP Basic auth (Account SID + Auth Token or API Key pair).

- messaging: send/sendSms/sendMms/sendWhatsApp/sendContentTemplate, get,
  list/listNextPage, redact, delete (whatsapp: prefixing handled; from or
  messagingServiceSid interchangeable)
- media: list/getInfo/download (follows 302 to CDN)/delete
- account: getAccount/listPhoneNumbers/listMessagingServices/listSubaccounts/
  verifyConnection
- parseTwilioWebhook: normalizes inbound + status callbacks (form-encoded),
  channel (SMS/WHATSAPP) inferred from address prefix
- validateTwilioSignature: full X-Twilio-Signature HMAC-SHA1 scheme, zero-dep,
  constant-time compare
- TwilioApiError + TWILIO_ERROR_CODES (sync + async ErrorCode); isRetryable
- TwiML builders: messagingResponse/emptyMessagingResponse/redirectResponse
- registered in provider registry / parseWebhook / validateWebhookSignature
- docs/providers.md section, README quick start, CHANGELOG, examples/twilio
  Express app + offline smoke test (19/19 passing)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@guilhermegoulart1
guilhermegoulart1 merged commit 419b3fb into main Jun 24, 2026
4 checks passed
@guilhermegoulart1
guilhermegoulart1 deleted the feat/twilio-provider branch June 24, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant