Twilio

Send SMS and WhatsApp messages via Twilio from a workflow.

When to Use

Use Twilio when you need to send outbound messages:

  • Send SMS notifications (alerts, OTPs, confirmations)
  • Send WhatsApp messages to customers within the 24-hour service window
  • Notify users of workflow events (payment received, order shipped, etc.)

Connect a Twilio node to an AI Agent Tools handle to let the agent send notifications or alerts on demand.

Inputs

HandleTypeDescription
inputanyUpstream data for {{ input.field }} template references in settings.

Output

HandleTypeDescription
resultobjectTwilio message result

The result (accessed as {{ twilio.* }}) shape:

FieldTypeDescription
successbooleanWhether the message was sent successfully
sidstringTwilio message SID (e.g. SM...)
statusstringMessage status (e.g. queued, sent, delivered)
errorstringError message if success is false
{
  "success": true,
  "sid": "SMabc123def456",
  "status": "queued",
  "error": null
}

Settings

Each node run executes a single operation. Set Operation, then configure the message fields.

Operation

SettingTypeDefaultDescription
operationenumsend_smsMessaging action to perform: send_sms or send_whatsapp.

Agent Permissions

SettingTypeDefaultDescription
allowed_operationsmulti-selectAll operationsWhich operations are available when this plugin is used as an AI agent tool. Excluded from the tool schema — the agent can only invoke operations in this list.

send_sms

Shown when operation is send_sms:

SettingTypeDefaultDescription
tostringRecipient phone number in E.164 format (e.g. +14155559876). Required. Supports {{ }} bindings.
bodycode editorMessage text. Required. Supports {{ }} bindings.

send_whatsapp

Shown when operation is send_whatsapp:

SettingTypeDefaultDescription
tostringRecipient WhatsApp number in E.164 format (Twilio adds the whatsapp: prefix). Required. Supports {{ }} bindings.
bodycode editorMessage text. Must comply with WhatsApp messaging rules. Required. Supports {{ }} bindings.

Required Secrets

Configure on the Environment Variables page:

VariableDescription
TWILIO_ACCOUNT_SIDTwilio Account SID (starts with AC). Get it from the Twilio Console.
TWILIO_AUTH_TOKENTwilio Auth Token.
TWILIO_FROM_NUMBERSender phone number in E.164 format (e.g. +14155551234) or WhatsApp format (e.g. whatsapp:+14155551234).

For WhatsApp, the from number must use the whatsapp: prefix (e.g. whatsapp:+14155551234). WhatsApp messages require either an approved message template or an open 24-hour customer service window.

Example

Canvas

Send an SMS alert when a webhook fires:

Webhook Trigger → Twilio (send_sms)

Twilio settings:

  • Operation: send_sms
  • To: {{ webhook.body.phone }}
  • Message Body: Alert: {{ webhook.body.message }}

Access the result downstream:

{{ twilio.success }}
{{ twilio.sid }}
{{ twilio.status }}

Send a WhatsApp confirmation after payment:

Webhook Trigger (Stripe) → Twilio (send_whatsapp)

Twilio settings:

  • Operation: send_whatsapp
  • To: {{ webhook.body.data.object.customer_phone }}
  • Message Body: Payment of ${{ webhook.body.data.object.amount }} received. Thank you!

Ensure TWILIO_FROM_NUMBER is set to a WhatsApp-enabled sender (e.g. whatsapp:+14155551234).

TSL

import webhook from @tensorify/webhook-trigger:4.0.0
import twilio from @tensorify/twilio-sms:1.0.0

node trigger @tensorify/webhook-trigger:4.0.0 {
    path = "/notify"
    method = "POST"
}

node sms @tensorify/twilio-sms:1.0.0 {
    operation = "send_sms"
    to = "{{ webhook.body.phone }}"
    body = "Alert: {{ webhook.body.message }}"
}

trigger.payload -> sms.input

Error Handling

Twilio has a hidden On Error control output branch (error). Enable it via the "Error output handle" toggle at the bottom of the settings panel.

The error branch fires when the Twilio API returns an error or the request fails at runtime. On the main path, failures are also reflected in {{ twilio.success }} and {{ twilio.error }} on the result output.

Common Gotchas

  • E.164 format: Phone numbers must include the country code with a leading + (e.g. +14155559876).
  • WhatsApp restrictions: Outside the 24-hour customer service window, WhatsApp requires approved message templates. Free-form text is only allowed within the window after the recipient messages you.
  • From number format: SMS uses a plain E.164 number; WhatsApp requires the whatsapp: prefix on TWILIO_FROM_NUMBER.
  • Check twilio.success: The node completes on the main output even when the send fails. Use an If node or the On Error branch to handle failures.
  • Agent permissions: Restrict Allowed Operations (Agent) — allow send_sms only if the agent should not send WhatsApp messages.
  • Status vs delivery: status reflects Twilio's initial queue status (queued, sent) — delivery confirmation requires Twilio status callbacks, which are not handled by this plugin.

See Also

On this page