Skip to main content
skill CX Codex GP ChatGPT official · OpenAI

twilio-send-message — Codex skill: send SMS, RCS and WhatsApp

A skill that gives your agent the recipes for sending messages through Twilio's Programmable Messaging API — SMS, MMS, RCS and WhatsApp. Useful when a project needs notifications or alerts.

Install into Codex · Skills CLI (Vercel) All methods and platforms ↓
npx skills add openai/plugins --skill twilio-send-message -a codex
Open on GitHub

What twilio-send-message does

Every send goes through one messages.create() call. Which channel it lands on depends on the sender address and what the recipient supports: a plain number means SMS or MMS, rcs:+15551234567 pins it to RCS, whatsapp:+15551234567 routes to WhatsApp. The skill walks through plain text, media attachments, templates, Messaging Services, status callbacks and WhatsApp's 24-hour service window.

What's inside: Python and Node.js samples, a table of to formats per channel, a list of common error codes (21211, 21408, 21610, 30034 and others) with fixes, and a section on what the API won't do. For production it points you at messagingServiceSid rather than from, since that's what enables sender pools, RCS→SMS fallback, SMS pumping protection and scheduling.

Before you start you need a Twilio account, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN in the environment, the SDK (pip install twilio or npm install twilio) and a sender for the channel you picked. RCS→SMS fallback only works through a Messaging Service — a raw from send rejects FallbackFrom. And WhatsApp won't accept free-form text once the 24-hour window closes; you have to use a pre-approved template via content_sid.

What it helps with

  • send an SMS or MMS from Python or Node.js code
  • attach an invoice, PDF or image to a message
  • set up RCS→SMS fallback through a Messaging Service
  • track delivery with a status_callback URL
  • work out why a message was rejected from its error code

Example prompts for the agent

  • Send an SMS to +15558675310 saying the order has shipped, using Twilio
  • Add a status callback to https://yourapp.com/status for this message
  • Send a WhatsApp template with content_sid and fill in the customer name

How to install twilio-send-message

1Skills CLI (Vercel)

npx skills add openai/plugins --skill twilio-send-message -a codex

2Manually: put the files in place

.agents/skills/twilio-send-message/SKILL.md

For all projects use ~/.agents/skills/

Step by step, with commands for each platform: Codex skills: how to install, where they live, how to call them

Questions about twilio-send-message

How do I install twilio-send-message in Claude?

Run npx skills add openai/plugins --skill twilio-send-message, then npx skills add openai/plugins --skill twilio-send-message -a codex. The skill file ends up at .agents/skills/twilio-send-message/SKILL.md.

What does twilio-send-message do?

It hands the agent working recipes for Twilio's Programmable Messaging API: SMS, MMS, RCS and WhatsApp, including media, templates and status callbacks.

What do I need before using it?

A Twilio account, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN set as environment variables, the SDK installed, and a sender for your channel. RCS→SMS fallback needs a Messaging Service holding both an RCS and an SMS sender.

Source text

SKILL.md · MIT
---
name: twilio-send-message
description: >
  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.
---

## Overview

**A single `messages.create()` call sends on any messaging channel — SMS, MMS, RCS, or WhatsApp.** The channel is determined by the sender address and the recipient's capabilities. For channel selection guidance and the full onboarding sequence, see `twilio-messaging-overview` and `twilio-messaging-channel-advisor`.

| Channel | `to` format | Notes | Template required? |
|---------|-------------|-------|--------------------|
| SMS/MMS | `+15551234567` | MMS: US/CA/AU only | No |
| RCS (with SMS fallback) | `+15551234567` | 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) | `rcs:+15551234567` | Forces RCS only — fails if recipient isn't RCS-capable | No |
| WhatsApp | `whatsapp:+15551234567` | Send via `whatsapp:`-prefixed `from` | Outside 24-hr window: yes |

**For production:** Send via `messagingServiceSid` instead of `from`. This enables sender pool management, RCS→SMS fallback, SMS pumping protection, link shortening, compliance toolkit, and scheduling. See `twilio-messaging-services`.

---

## Prerequisites

- Twilio account — New to Twilio? See `twilio-account-setup`
- Environment variables: `TWILIO_ACCOUNT_SID`, `TWILIO_AUTH_TOKEN` — see `twilio-iam-auth-setup`
- SDK: `pip install twilio` / `npm install twilio`
- Channel-specific senders:
  - SMS/MMS: a Twilio phone number (see `twilio-account-setup`)
  - RCS: an RCS sender added to a Messaging Service (see `twilio-rcs-messaging`)
  - WhatsApp: an active WhatsApp sender (see `twilio-whatsapp-send-message` for sandbox, `twilio-whatsapp-manage-senders` for production)

---

## Quickstart

**Python**
```python
import 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."
)
```

**Node.js**
```javascript
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.",
});
```

---

## Key Patterns

### Send with media (MMS, WhatsApp, RCS)

```python
client.messages.create(
    from_="+15017122661",
    to="+15558675310",
    body="Here is your invoice.",
    media_url=["https://example.com/invoice.pdf"]
)
```

Supported: images (JPEG, PNG, GIF), PDF, audio, video. 5 MB max per attachment.

### Send a template (WhatsApp required outside 24-hr window; RCS rich content)

```python
client.messages.create(
    messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    to="+15558675310",
    content_sid="HXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    content_variables='{"1": "Sarah", "2": "12345"}'
)
```

See `twilio-content-template-builder` for building templates.

### Track delivery status

```python
client.messages.create(
    messaging_service_sid="MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    to="+15558675310",
    body="Hello!",
    status_callback="https://yourapp.com/status"
)
```

Twilio POSTs at each state transition: `queued → sent → delivered` (or `failed`/`undelivered`).

### Configure RCS→SMS fallback

Configured on the Messaging Service, not per-message. Add both an RCS sender and an SMS sender to the same Messaging Service. Twilio attempts RCS first and falls back to SMS on failure. See `twilio-messaging-services` and `twilio-rcs-messaging`.

---

## Common Errors

| Code | Meaning | Fix |
|------|---------|-----|
| 21211 | Invalid `to` number | Validate E.164 format |
| 21408 | Region not permitted | Enable geo-permissions in Console |
| 21610 | Recipient opted out | Do not retry; respect opt-out |
| 21664 | `FallbackFrom` cannot be used with `From` sender | Use `messaging_service_sid` instead of `from` |
| 21666 | `FallbackFrom` requires `MessagingServiceSid` | Send via a Messaging Service |
| 21667 | `FallbackFrom` requires an RCS Sender on the Messaging Service | 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 `twilio-compliance-onboarding` |
| 30036 | Validity Period expired | Message aged out. Often indicates RCS fallback is misconfigured |
| 63036 | RCS recipient unreachable | Configure SMS fallback on the Messaging Service |

---

## CANNOT

- **Cannot send cross-channel in a single API call.** One `messages.create()` = one channel. For multi-channel fallback, use RCS→SMS via a Messaging Service, or implement sequencing in your app.
- **Cannot send WhatsApp free-form outside the 24-hour service window.** Use a pre-approved template (`content_sid`). See `twilio-whatsapp-send-message`.
- **Cannot send MMS outside US/Canada.** For international rich media, use WhatsApp or RCS.
- **Cannot configure RCS→SMS fallback without a Messaging Service.** Raw `from` sends don't support `FallbackFrom`.
- **Cannot guarantee delivery on any channel.** Always implement status callbacks.

---

## Next Steps

- **Pick a channel for your use case:** `twilio-messaging-channel-advisor`
- **Full messaging platform overview:** `twilio-messaging-overview`
- **Channel-specific deep dives:** `twilio-sms-send-message`, `twilio-rcs-messaging`, `twilio-whatsapp-send-message`
- **Sender pools, fallback, production features:** `twilio-messaging-services`
- **Build templates (cards, carousels, quick replies):** `twilio-content-template-builder`
- **Handle inbound messages and status callbacks:** `twilio-messaging-webhooks`
- **US A2P 10DLC compliance:** `twilio-compliance-onboarding`
- **OTP / verification use cases:** `twilio-verify-send-otp`

© Twilio · MIT · openai/plugins

Similar skills

All skills for Backend and APIs →

From the same set420

The whole set →
building-mcp-server-on-cloudflare A skill that walks the agent through building a remote MCP server on Cloudflare Workers: tools, OAuth, deployment. Useful when you need to expose your own functions over MCP. CX Codex GP ChatGPT 2installs knowledge-update Injects up-to-date Vercel platform facts into the session and overrides stale model knowledge. Useful when your agent still reaches for Edge Functions or vercel.json. CX Codex GP ChatGPT 1installs eve Skill for working with eve, a framework for durable AI agents. Creates projects, debugs deployed agents, and picks architecture for eve-based applications. CX Codex GP ChatGPT 1installs twilio-voice-conversation-relay Build voice-powered AI agents on Twilio with real-time speech handling. Wraps speech recognition (ASR) and text-to-speech (TTS) over WebSocket, so you work with text, not raw audio streams. CX Codex GP ChatGPT 1installs twilio-messaging-overview A navigation skill for Twilio Messaging: pick between SMS, WhatsApp, RCS and Messenger, then follow the setup order from first message to production monitoring. CX Codex GP ChatGPT 1installs twilio-account-setup Walks you from Twilio signup to your first sent message: credentials, phone number, SDK, subaccounts. CX Codex GP ChatGPT 1installs shopify-use-shopify-cli A skill that steers your agent toward the right Shopify CLI command and helps it run or fix things now: config validation, store operations, setup errors. CX Codex GP ChatGPT 1installs shopify-storefront-graphql Writes GraphQL queries and mutations against the Shopify Storefront API, searching the docs first and validating the code before it reaches you. CX Codex GP ChatGPT 1installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor