Labsco
openai logo

twilio-whatsapp-send-message

✓ Official4,081

by openai · part of openai/plugins

WhatsApp messaging deep-dive reference. Covers the 24-hour service window rules (free-form vs template mode), sandbox setup for testing, template approval workflow, production sender requirements, and WhatsApp-specific error handling. For sending WhatsApp messages, use twilio-send-message instead. Use this skill when setting up WhatsApp for the first time or debugging WhatsApp-specific delivery behavior.

🧩 One of 7 skills in the openai/plugins package — works on its own, and pairs well with its siblings.

This is the playbook your agent receives when the skill activates — you don't need to read it to use the skill, but it's here to audit before installing.

Overview

WhatsApp is one channel in Twilio's Messaging platform. All channels share the same messages.create() API — see twilio-messaging-overview for the full channel comparison and onboarding sequence.

Twilio routes WhatsApp through the Programmable Messaging API — all numbers use whatsapp:+E.164 prefix. Two sending modes apply: free-form (within 24 hrs of last inbound) and template (anytime). Sending free-form outside the window causes silent delivery failure — always check which mode is required.

ModeWhen allowedParameters
Free-formWithin 24 hrs of last inbound from userbody, optional mediaUrl
TemplateAnytimecontentSid + contentVariables

Key Patterns

Send a Template Message (outside service window)

Templates are created in Console > Messaging > Content Template Builder and must be approved by Meta. See twilio-content-template-builder for template creation.

Python

message = client.messages.create(
    from_="whatsapp:+14155238886",
    to="whatsapp:+15005550006",
    content_sid="HXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    content_variables='{"1": "March 25", "2": "2:00 PM"}'
)

Node.js

const message = await client.messages.create({
    from: "whatsapp:+14155238886",
    to: "whatsapp:+15005550006",
    contentSid: "HXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    contentVariables: JSON.stringify({ "1": "March 25", "2": "2:00 PM" }),
});

Send Media (free-form only)

Max file size: 16 MB.

Python

message = client.messages.create(
    from_="whatsapp:+14155238886",
    to="whatsapp:+15005550006",
    body="Here is your invoice.",
    media_url=["https://example.com/invoice.pdf"]
)

Node.js

const message = await client.messages.create({
    from: "whatsapp:+14155238886",
    to: "whatsapp:+15005550006",
    body: "Here is your invoice.",
    mediaUrl: ["https://example.com/invoice.pdf"],
});

Response Fields

FieldDescription
sidUnique message identifier (MM...)
statusqueued, sent, delivered, read, failed, undelivered
error_codePopulated on failure
error_messageHuman-readable error description
date_sentUTC timestamp

CANNOT

  • Cannot exceed 80 messages/second per sender — Text-only can be raised to 400 MPS on request
  • Cannot queue messages beyond 4 hours — Undelivered messages fail after 4 hours
  • Cannot exceed sandbox throttle limits — 1 message per 3 seconds, 50 messages/day on trial, participants expire after 3 days
  • Cannot send without opt-in — Sending without recipient opt-in risks account suspension
  • Cannot use WhatsApp Groups API — Deprecated April 2020. Use Conversations API instead.

Next Steps

  • Channel overview and onboarding guide: twilio-messaging-overview
  • Register a production WhatsApp sender: twilio-whatsapp-manage-senders
  • Create and manage message templates: twilio-content-template-builder
  • Multi-channel conversations with history: twilio-conversations-api