OpenClaw can receive and send SMS through a Twilio phone number or Messaging Service. The Gateway registers an inbound webhook route, validates Twilio request signatures by default, and sends replies back through Twilio’s Messages API.Documentation Index
Fetch the complete documentation index at: https://openclaw.ai2me.io/llms.txt
Use this file to discover all available pages before exploring further.
Pairing
Default DM policy for SMS is pairing.
Gateway security
Review webhook exposure and sender access controls.
Channel troubleshooting
Cross-channel diagnostics and repair playbooks.
Before you begin
You need:- A Twilio account with an SMS-capable phone number, or a Twilio Messaging Service.
- The Twilio Account SID and Auth Token.
- A public HTTPS URL that reaches your OpenClaw Gateway.
- A sender policy choice:
pairingfor private use,allowlistfor preapproved phone numbers, oropenonly for intentionally public SMS access.
Quick Setup
Create or choose a Twilio sender
In Twilio, open Phone Numbers > Manage > Active numbers and choose an SMS-capable number. Save:
- Account SID, for example
ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - Auth Token
- Sender phone number, for example
+15551234567
MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.Point Twilio at the Gateway webhook
In the Twilio phone number settings, open Messaging and set A message comes in to:Use HTTP
POST. The default local path is /webhooks/sms; change channels.sms.webhookPath if you need a different route.Expose the exact SMS webhook path
Your public URL must route the SMS path to the Gateway process. If you use Tailscale Funnel for local testing, expose Voice Call and SMS use separate webhook paths. If the same Twilio number handles both, keep both routes configured in Twilio and in your tunnel.
/webhooks/sms explicitly:Configuration Examples
Config file
Use config-file setup when you want the channel definition to travel with the Gateway config:Environment variables
Use env setup for single-account deployments where secrets come from the host environment:TWILIO_SMS_FROM is accepted as an alias for TWILIO_PHONE_NUMBER. Use TWILIO_MESSAGING_SERVICE_SID instead of a phone-number sender when Twilio should choose the sender from a Messaging Service.
SecretRef auth token
authToken can be a SecretRef. Use this when the Gateway should resolve the Twilio Auth Token from the OpenClaw secrets runtime instead of storing plaintext config:
Allowlist-only private number
Useallowlist when only known phone numbers should be able to talk to the agent:
Messaging Service sender
UsemessagingServiceSid instead of fromNumber when Twilio should choose the sender through a Messaging Service:
fromNumber and messagingServiceSid are present after config and env resolution, fromNumber is used.
Default outbound target
SetdefaultTo when automation or agent-initiated delivery should have a default destination if a send flow omits an explicit target:
Access control
channels.sms.dmPolicy controls direct SMS access:
pairing(default)allowlist(requires at least one sender inallowFrom)open(requiresallowFromto include"*")disabled
allowFrom entries should be E.164 phone numbers such as +15551234567. sms: prefixes are accepted and normalized. For a private assistant, prefer dmPolicy: "allowlist" with explicit phone numbers.
Sending SMS
Outbound SMS targets use thesms: service prefix with the SMS channel selected:
twilio-sms:+15551234567 selects this channel without taking over the existing channel-owned sms: service prefix used by iMessage.
--target. defaultTo is for automation and agent-initiated delivery paths where the target can be resolved from channel config.
Agent replies from inbound SMS conversations automatically go back to the sender through the configured Twilio sender.
SMS output is plain text. OpenClaw strips markdown, flattens fenced code blocks, preserves readable links, and chunks long replies before sending them through Twilio.
Verify Setup
After the Gateway starts:- Confirm the Gateway log shows the SMS webhook route.
- Run a Twilio-side probe:
- Send an SMS to the Twilio number from your phone.
- Run
openclaw pairing list sms. - Approve the pairing code with
openclaw pairing approve sms <CODE>. - Send another SMS and confirm the agent replies.
End-to-end test from macOS iMessage/SMS
On a Mac that can send carrier SMS through Messages, you can useimsg to drive the sender side without touching your phone:
Webhook security
By default, OpenClaw validatesX-Twilio-Signature using publicWebhookUrl and authToken. Keep publicWebhookUrl byte-for-byte aligned with the URL configured in Twilio, including scheme, host, path, and query string.
For local tunnel testing only, you can set:
Multi-account config
Useaccounts when you operate more than one Twilio number:
webhookPath.
Troubleshooting
Twilio returns 403 or OpenClaw rejects the webhook
Check thatpublicWebhookUrl exactly matches the URL configured in Twilio, including scheme, host, path, and query string. Twilio signs the public URL string, so proxy rewrites and alternate hostnames can break signature validation.
No pairing request appears
Check the Twilio number’s Messaging webhook URL and method. It must point to the SMS webhook URL and usePOST. Also confirm the Gateway is reachable from the public internet or through your tunnel.
If the Twilio message log shows error 11200, Twilio accepted the inbound SMS but could not reach your webhook. Check:
- Twilio Messaging > A message comes in points at
publicWebhookUrl. - The method is
POST. - The tunnel or reverse proxy exposes the exact
webhookPath; for Tailscale Funnel, runtailscale funnel statusand confirm/webhooks/smsis listed. publicWebhookUrluses the same scheme, host, path, and query string Twilio sends, so signature validation can reproduce the signed URL.
Outbound sends fail
ConfirmaccountSid, authToken, and either fromNumber or messagingServiceSid are resolved. If you use a trial Twilio account, the destination number may need to be verified in Twilio before outbound SMS will send.
Messages arrive but the agent does not answer
CheckdmPolicy and allowFrom. With the default pairing policy, the sender must be approved before normal agent turns are processed.