agentleFS
wittyreferencewittyreference/twilio-claude-plugin/skills/messaging/SKILL.md

messaging

Skill2 starsChanged 8 months agoMITView on GitHub

Twilio development skill: messaging

10 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use testing.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • NVIDIASkill

    testing

    Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When Twilio makes a request to your SMS webhook, these parameters are included:

    line 42
  2. Distinctive:

    Associate Numbers: Add phone numbers to the Messaging Service sender pool

    line 171
  3. Distinctive:

    Toll-free numbers: Don't require A2P 10DLC (but need toll-free verification)

    line 187
  4. Distinctive:

    Use status callbacks to verify delivery

    line 196

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Messaging Functions Context

Service: prototype-core (CORE_BASE_URL). Deploy: ./scripts/deploy-services.sh dev

This directory contains Twilio Messaging API functions for SMS and MMS handling.

Files

FileAccessDescription
incoming-sms.jsPublicHandles incoming SMS messages with an auto-reply via TwiML
send-sms.protected.jsProtectedSends outbound SMS messages using the Twilio API

TwiML Messaging Verbs

Message Verb

const twiml = new Twilio.twiml.MessagingResponse();
twiml.message('Your reply text here');

Message with Media (MMS)

const twiml = new Twilio.twiml.MessagingResponse();
const message = twiml.message('Check out this image!');
message.media('https://example.com/image.jpg');

Redirect Verb

const twiml = new Twilio.twiml.MessagingResponse();
twiml.redirect('/messaging/other-handler');

SMS Webhook Parameters

When Twilio makes a request to your SMS webhook, these parameters are included:

ParameterDescription
MessageSidUnique identifier for the message
AccountSidYour Twilio Account SID
FromSender's phone number (E.164)
ToRecipient phone number (E.164)
BodyText content of the message
NumMediaNumber of media attachments
MediaUrl0URL of first media attachment
MediaContentType0MIME type of first attachment

Status Callback Parameters

ParameterDescription
MessageStatusCurrent status (queued, sent, delivered, failed)
ErrorCodeError code if message failed
ErrorMessageError description if failed

Programmatic SMS API

Send SMS

const client = context.getTwilioClient();
const message = await client.messages.create({
  to: '+1234567890',
  from: context.TWILIO_PHONE_NUMBER,
  body: 'Hello from Twilio!'
});

Send MMS

const message = await client.messages.create({
  to: '+1234567890',
  from: context.TWILIO_PHONE_NUMBER,
  body: 'Check out this image!',
  mediaUrl: ['https://example.com/image.jpg']
});

Message Status Values

  • queued - Message is queued for sending
  • sending - Message is being sent
  • sent - Message has been sent
  • delivered - Message confirmed delivered
  • undelivered - Message could not be delivered
  • failed - Message send failed

Common Patterns

Keyword Routing

exports.handler = async (context, event, callback) => {
  const twiml = new Twilio.twiml.MessagingResponse();
  const body = (event.Body || '').toLowerCase().trim();

  switch (body) {
    case 'help':
      twiml.message('Available commands: HELP, STATUS, STOP');
      break;
    case 'status':
      twiml.message('System is operational.');
      break;
    case 'stop':
      twiml.message('You have been unsubscribed.');
      break;
    default:
      twiml.message('Unknown command. Reply HELP for options.');
  }

  return callback(null, twiml);
};

Handling Media (MMS)

exports.handler = async (context, event, callback) => {
  const twiml = new Twilio.twiml.MessagingResponse();
  const numMedia = parseInt(event.NumMedia, 10) || 0;

  if (numMedia > 0) {
    const mediaUrl = event.MediaUrl0;
    const mediaType = event.MediaContentType0;
    twiml.message(`Received ${numMedia} media file(s) of type: ${mediaType}`);
  } else {
    twiml.message('No media received.');
  }

  return callback(null, twiml);
};

Status Callbacks

// Configure when sending:
const message = await client.messages.create({
  to: '+1234567890',
  from: context.TWILIO_PHONE_NUMBER,
  body: 'Hello!',
  statusCallback: 'https://your-domain.com/messaging/status'
});

// Status handler:
exports.handler = async (context, event, callback) => {
  const status = event.MessageStatus;
  const messageSid = event.MessageSid;

  console.log(`Message ${messageSid} status: ${status}`);

  return callback(null, { success: true });
};

Character Limits

  • SMS: 160 characters (GSM-7 encoding) or 70 characters (UCS-2 for Unicode)
  • Concatenated SMS: Up to 1600 characters (split into segments)
  • MMS: Subject line up to 40 characters, body varies by carrier

A2P 10DLC Compliance (US SMS)

US carriers require A2P 10DLC registration for application-to-person messaging via local numbers. Without registration, messages get error 30034 (blocked by carrier).

Registration Steps (Twilio Console)

  1. Register a Brand: Console → Messaging → Trust Hub → US A2P Brand Registration
  2. Create a Campaign: Console → Messaging → Services → [your service] → Compliance Info
  3. Associate Numbers: Add phone numbers to the Messaging Service sender pool
  4. Wait for Approval: Brand vetting takes 1-7 business days; campaign approval is usually faster

Checking Status

# Check brand registrations
twilio api:messaging:v1:brand-registrations:list

# Check A2P campaigns on a Messaging Service
twilio api:messaging:v1:services:us-app-to-person:list \
  --messaging-service-sid $TWILIO_MESSAGING_SERVICE_SID

Workarounds During Development

  • Toll-free numbers: Don't require A2P 10DLC (but need toll-free verification)
  • Short codes: Pre-approved for high-volume, but expensive
  • Trial accounts: May have different filtering behavior

Testing Messaging Functions

Tests should use real Twilio APIs:

  1. For webhook handlers, test TwiML generation
  2. For send functions, use real API calls to test phone numbers
  3. Use status callbacks to verify delivery

File Naming Conventions

  • *.js - Public endpoints (no signature validation)
  • *.protected.js - Protected endpoints (require valid Twilio signature)
  • *.private.js - Private functions (not accessible via HTTP)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.