Loading...
Loading...
Send messages via Twilio's Programmable Messaging API across all channels — SMS, MMS, RCS, and WhatsApp. Covers text messages, media, rich content (cards, carousels, buttons), template-based sends, Messaging Services, status callbacks, and WhatsApp's 24-hour service window. Use when the user wants to send a message — whether they say "send SMS", "text message", "branded message", "rich message", "WhatsApp message", "RCS message", "notification", or "alert". For picking the right channel for a use case, first consult twilio-messaging-channel-advisor.
npx skill4agent add twilio/ai twilio-send-messagemessages.create()twilio-messaging-overviewtwilio-messaging-channel-advisor| Channel | | Notes | Template required? |
|---|---|---|---|
| SMS/MMS | | MMS: US/CA/AU only | No |
| RCS (with SMS fallback) | | Send via Messaging Service that has both an RCS sender and an SMS sender — Twilio attempts RCS first, falls back to SMS on failure | No |
| RCS (no fallback) | | Forces RCS only — fails if recipient isn't RCS-capable | No |
| Send via | Outside 24-hr window: yes |
messagingServiceSidfromtwilio-messaging-servicestwilio-account-setupTWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENtwilio-iam-auth-setuppip install twilionpm install twiliotwilio-account-setuptwilio-rcs-messagingtwilio-whatsapp-send-messagetwilio-whatsapp-manage-sendersimport os
from twilio.rest import Client
client = Client(os.environ["TWILIO_ACCOUNT_SID"], os.environ["TWILIO_AUTH_TOKEN"])
# SMS
sms = client.messages.create(
from_="+15017122661",
to="+15558675310",
body="Your order has shipped."
)
# RCS — forces RCS only, no fallback
rcs = client.messages.create(
messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to="rcs:+15558675310",
body="Your order has shipped."
)
# WhatsApp
whatsapp = client.messages.create(
from_="whatsapp:+15017122661",
to="whatsapp:+15558675310",
body="Your order has shipped."
)
# Via Messaging Service (recommended — attempts RCS first, falls back to SMS)
msg = client.messages.create(
messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to="+15558675310",
body="Your order has shipped."
)const client = require("twilio")(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
// SMS
const sms = await client.messages.create({
from: "+15017122661",
to: "+15558675310",
body: "Your order has shipped.",
});
// RCS — forces RCS only, no fallback
const rcs = await client.messages.create({
messagingServiceSid: "MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to: "rcs:+15558675310",
body: "Your order has shipped.",
});
// WhatsApp
const whatsapp = await client.messages.create({
from: "whatsapp:+15017122661",
to: "whatsapp:+15558675310",
body: "Your order has shipped.",
});
// Via Messaging Service (attempts RCS first, falls back to SMS)
const msg = await client.messages.create({
messagingServiceSid: "MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to: "+15558675310",
body: "Your order has shipped.",
});client.messages.create(
from_="+15017122661",
to="+15558675310",
body="Here is your invoice.",
media_url=["https://example.com/invoice.pdf"]
)client.messages.create(
messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to="+15558675310",
content_sid="HXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
content_variables='{"1": "Sarah", "2": "12345"}'
)twilio-content-template-builderclient.messages.create(
messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
to="+15558675310",
body="Hello!",
status_callback="https://yourapp.com/status"
)queued → sent → deliveredfailedundeliveredtwilio-messaging-servicestwilio-rcs-messaging| Code | Meaning | Fix |
|---|---|---|
| 21211 | Invalid | Validate E.164 format |
| 21408 | Region not permitted | Enable geo-permissions in Console |
| 21610 | Recipient opted out | Do not retry; respect opt-out |
| 21664 | | Use |
| 21666 | | Send via a Messaging Service |
| 21667 | | Add an RCS sender before configuring fallback |
| 30003 | Unreachable destination | Carrier cannot deliver |
| 30007 | Message filtered as spam | Review content and sender reputation |
| 30034 | US A2P 10DLC — sender not registered | Register brand + campaign. See |
| 30036 | Validity Period expired | Message aged out. Often indicates RCS fallback is misconfigured |
| 63036 | RCS recipient unreachable | Configure SMS fallback on the Messaging Service |
messages.create()content_sidtwilio-whatsapp-send-messagefromFallbackFromtwilio-messaging-channel-advisortwilio-messaging-overviewtwilio-sms-send-messagetwilio-rcs-messagingtwilio-whatsapp-send-messagetwilio-messaging-servicestwilio-content-template-buildertwilio-messaging-webhookstwilio-compliance-onboardingtwilio-verify-send-otp