Twilio
Send SMS, make calls, and verify webhook signatures.
Authentication
| Type | Default | Details |
|---|---|---|
api_key | ✅ | Account SID + Auth Token as HTTP Basic auth |
Twilio uses HTTP Basic auth: Basic base64(AccountSid:AuthToken). Pass accountSid and authToken in plugin options.
Endpoints
| Path | Risk | Description |
|---|---|---|
messages.create | write | Send an SMS/MMS (or WhatsApp via Messaging Service). |
messages.get | read | Get a message by SID. |
messages.list | read | List recent messages. |
calls.create | write | Initiate an outbound call (URL or inline TwiML). |
calls.get | read | Get a call by SID. |
calls.list | read | List recent calls. |
phoneNumbers.list | read | List owned phone numbers. |
messages.create
Send an SMS, MMS, or WhatsApp message.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
from | string | Sender phone number (required if no MessagingServiceSid) | |
messagingServiceSid | string | Messaging Service SID for pooled senders | |
to | string | ✅ | Recipient phone number |
body | string | Message body | |
mediaUrl | string[] | Media URLs for MMS | |
statusCallback | string | Webhook URL for delivery status |
Output: TwilioMessage
messages.get
Get a message by SID.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
sid | string | ✅ | Message SID |
Output: TwilioMessage
messages.list
List recent messages.
Input:
| Field | Type | Description |
|---|---|---|
to | string | Filter by recipient |
from | string | Filter by sender |
dateSent | string | Filter by date (YYYY-MM-DD) |
pageSize | number | Max results |
Output: { messages: TwilioMessage[]; next_page_uri?: string \| null }
calls.create
Initiate an outbound voice call.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
from | string | ✅ | Caller phone number |
to | string | ✅ | callee phone number |
url | string | TwiML URL to execute | |
twiml | string | Inline TwiML | |
method | enum | HTTP method for fetching URL: GET or POST | |
statusCallback | string | Webhook URL for status updates |
Output: TwilioCall
calls.get
Get a call by SID.
Input:
| Field | Type | Required | Description |
|---|---|---|---|
sid | string | ✅ | Call SID |
Output: TwilioCall
calls.list
List recent calls.
Input:
| Field | Type | Description |
|---|---|---|
to | string | Filter by callee |
from | string | Filter by caller |
status | string | Filter by status |
pageSize | number | Max results |
Output: { calls: TwilioCall[]; next_page_uri?: string \| null }
phoneNumbers.list
List phone numbers owned by the account.
Input:
| Field | Type | Description |
|---|---|---|
phoneNumber | string | Filter by number |
pageSize | number | Max results |
Output: { incoming_phone_numbers: TwilioPhoneNumber[] }
Usage
import { createFabric } from "@fabricorg/integrations";
import { twilio } from "@fabricorg/integrations/plugins";
const fabric = createFabric({
plugins: [
twilio({
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
}),
],
});
// Send an SMS
const msg = await fabric.twilio.api.messages.create({
from: "+15551234567",
to: "+15559876543",
body: "Your verification code is 123456",
});
// Make a call
const call = await fabric.twilio.api.calls.create({
from: "+15551234567",
to: "+15559876543",
twiml: `<Response><Say>Hello from Fabric!</Say></Response>`,
});Webhooks
Twilio webhooks (status callbacks, incoming SMS) use the X-Twilio-Signature header. The plugin exports verifyTwilioSignature for validation.
Signature verification
import { verifyTwilioSignature } from "@fabricorg/integrations/plugins";
const valid = verifyTwilioSignature({
url: "https://your-app.com/webhooks/twilio",
params: parsedFormBody,
signatureHeader: headers["x-twilio-signature"],
authToken: process.env.TWILIO_AUTH_TOKEN,
});Per-event webhook handlers are not declared on this plugin. Typical use is "incoming SMS → start Temporal workflow" via webhookHooks in userland.
Types
interface TwilioMessage {
sid: string;
account_sid: string;
from: string;
to: string;
body?: string;
status: "queued" | "sending" | "sent" | "delivered" | "failed" | "undelivered" | "received";
date_created?: string;
date_sent?: string | null;
error_code?: number | null;
error_message?: string | null;
}
interface TwilioCall {
sid: string;
account_sid: string;
from: string;
to: string;
status: "queued" | "initiated" | "ringing" | "in-progress" | "completed" | "busy" | "failed" | "no-answer" | "canceled";
duration?: string;
start_time?: string | null;
end_time?: string | null;
}
interface TwilioPhoneNumber {
sid: string;
phone_number: string;
friendly_name?: string;
capabilities?: { voice: boolean; sms: boolean; mms: boolean; fax?: boolean };
}