Skip to content

Twilio Integration

SMS and WhatsApp messaging.

Configuration

json
{
  "credentials": {
    "twilio": {
      "accountSid": "{{env.TWILIO_ACCOUNT_SID}}",
      "authToken": "{{env.TWILIO_AUTH_TOKEN}}",
      "fromNumber": "{{env.TWILIO_FROM_NUMBER}}"
    }
  }
}

Endpoints

MethodEndpointDescription
POST/integrations/twilio/smsSend SMS
POST/integrations/twilio/whatsappSend WhatsApp

Actions (for workflows)

sendSms

json
{
  "integration": "twilio",
  "action": "sendSms",
  "params": {
    "to": "+1234567890",
    "body": "Your verification code is 123456"
  }
}

sendWhatsApp

json
{
  "integration": "twilio",
  "action": "sendWhatsApp",
  "params": {
    "to": "+1234567890",
    "body": "Your order has shipped!"
  }
}

Examples

Send SMS

bash
curl -X POST http://localhost:3000/integrations/twilio/sms \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+1234567890",
    "body": "Your verification code is 123456"
  }'

Response:

json
{
  "sid": "SM123...",
  "status": "queued",
  "to": "+1234567890"
}

Send WhatsApp

bash
curl -X POST http://localhost:3000/integrations/twilio/whatsapp \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+1234567890",
    "body": "Your order #12345 has shipped!"
  }'

In Routes

json
{
  "path": "/auth/verify",
  "method": "post",
  "integrations": [{
    "type": "twilio",
    "action": "sendSms",
    "params": {
      "to": "&#123;&#123;body.phone&#125;&#125;",
      "body": "Your verification code is &#123;&#123;body.code&#125;&#125;"
    }
  }]
}

Workflow Example

json
{
  "id": "order-shipped",
  "steps": [
    {
      "id": "notify-sms",
      "type": "integration",
      "integration": "twilio",
      "action": "sendSms",
      "params": {
        "to": "&#123;&#123;input.phone&#125;&#125;",
        "body": "Your order #&#123;&#123;input.orderId&#125;&#125; has shipped! Track at: &#123;&#123;input.trackingUrl&#125;&#125;"
      }
    }
  ]
}

WhatsApp Setup

  1. Enable WhatsApp in Twilio Console
  2. Use WhatsApp-enabled number
  3. For templates, use approved message templates

Message Parameters

ParameterTypeRequiredDescription
tostringYesRecipient phone (E.164)
bodystringYesMessage content
fromstringNoOverride sender
mediaUrlstringNoMMS media URL

Released under the ISC License.