FabricFabricSDK
Plugins

Twilio

Send SMS, make calls, and verify webhook signatures.

Authentication

TypeDefaultDetails
api_keyAccount SID + Auth Token as HTTP Basic auth

Twilio uses HTTP Basic auth: Basic base64(AccountSid:AuthToken). Pass accountSid and authToken in plugin options.

Endpoints

PathRiskDescription
messages.createwriteSend an SMS/MMS (or WhatsApp via Messaging Service).
messages.getreadGet a message by SID.
messages.listreadList recent messages.
calls.createwriteInitiate an outbound call (URL or inline TwiML).
calls.getreadGet a call by SID.
calls.listreadList recent calls.
phoneNumbers.listreadList owned phone numbers.

messages.create

Send an SMS, MMS, or WhatsApp message.

Input:

FieldTypeRequiredDescription
fromstringSender phone number (required if no MessagingServiceSid)
messagingServiceSidstringMessaging Service SID for pooled senders
tostringRecipient phone number
bodystringMessage body
mediaUrlstring[]Media URLs for MMS
statusCallbackstringWebhook URL for delivery status

Output: TwilioMessage

messages.get

Get a message by SID.

Input:

FieldTypeRequiredDescription
sidstringMessage SID

Output: TwilioMessage

messages.list

List recent messages.

Input:

FieldTypeDescription
tostringFilter by recipient
fromstringFilter by sender
dateSentstringFilter by date (YYYY-MM-DD)
pageSizenumberMax results

Output: { messages: TwilioMessage[]; next_page_uri?: string \| null }

calls.create

Initiate an outbound voice call.

Input:

FieldTypeRequiredDescription
fromstringCaller phone number
tostringcallee phone number
urlstringTwiML URL to execute
twimlstringInline TwiML
methodenumHTTP method for fetching URL: GET or POST
statusCallbackstringWebhook URL for status updates

Output: TwilioCall

calls.get

Get a call by SID.

Input:

FieldTypeRequiredDescription
sidstringCall SID

Output: TwilioCall

calls.list

List recent calls.

Input:

FieldTypeDescription
tostringFilter by callee
fromstringFilter by caller
statusstringFilter by status
pageSizenumberMax results

Output: { calls: TwilioCall[]; next_page_uri?: string \| null }

phoneNumbers.list

List phone numbers owned by the account.

Input:

FieldTypeDescription
phoneNumberstringFilter by number
pageSizenumberMax 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 };
}