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
| Method | Endpoint | Description |
|---|---|---|
| POST | /integrations/twilio/sms | Send SMS |
| POST | /integrations/twilio/whatsapp | Send 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": "{{body.phone}}",
"body": "Your verification code is {{body.code}}"
}
}]
}Workflow Example
json
{
"id": "order-shipped",
"steps": [
{
"id": "notify-sms",
"type": "integration",
"integration": "twilio",
"action": "sendSms",
"params": {
"to": "{{input.phone}}",
"body": "Your order #{{input.orderId}} has shipped! Track at: {{input.trackingUrl}}"
}
}
]
}WhatsApp Setup
- Enable WhatsApp in Twilio Console
- Use WhatsApp-enabled number
- For templates, use approved message templates
Message Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient phone (E.164) |
body | string | Yes | Message content |
from | string | No | Override sender |
mediaUrl | string | No | MMS media URL |