twilio
БесплатноБез исполняемых скриптовНе проверенAdd SMS, voice calls, and WhatsApp messaging with Twilio. Use when a user asks to send SMS messages, make phone calls programmatically, add two-factor…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Twilio
Overview
Twilio is a cloud communications platform with REST APIs for messaging, voice and verification. This skill covers sending SMS/MMS messages, WhatsApp messaging, two-factor authentication (Verify API), voice calls, and handling incoming messages via webhooks. Twilio provides phone numbers in 100+ countries and handles carrier-level complexity so you work with a simple API.
Instructions
Step 1: Setup
# Node.js
npm install twilio
# Python
pip install twilio
// lib/twilio.ts — Client initialization
import twilio from 'twilio'
const client = twilio(
process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_AUTH_TOKEN
)
Step 2: Send SMS
// sms.ts — Send and receive SMS messages
import twilio from 'twilio'
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN)
// Send SMS
const message = await client.messages.create({
body: 'Your order #1234 has shipped! Track it at: https://track.northwindparcels.com/1234',
from: process.env.TWILIO_PHONE_NUMBER, // your Twilio number
to: '+15551234567', // recipient (E.164 format)
})
console.log(message.sid) // SM1234567890abcdef
// Send MMS (with image) — MMS works on US and Canadian numbers only
await client.messages.create({
body: 'Check out this photo!',
from: process.env.TWILIO_PHONE_NUMBER,
to: '+15551234567',
mediaUrl: ['https://cdn.northwindparcels.com/photos/box-1234.jpg'],
})
Step 3: Two-Factor Authentication (Verify API)
// lib/verify.ts — Phone number verification / 2FA
// Uses Twilio Verify — handles code generation, delivery, and validation
const client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN)
const VERIFY_SERVICE_SID = process.env.TWILIO_VERIFY_SERVICE_SID! // create in Twilio console
export async function sendVerificationCode(phoneNumber: string) {
/**
* Send a 6-digit verification code via SMS.
* Twilio handles code generation, expiry (10 min), and rate limiting.
*/
const verification = await client.verify.v2
.services(VERIFY_SERVICE_SID)
.verifications.create({
to: phoneNumber,
channel: 'sms', // or 'call', 'email', 'whatsapp'
})
return verification.status // 'pending'
}
export async function checkVerificationCode(phoneNumber: string, code: string) {
/**
* Verify a code entered by the user.
* Returns 'approved' if correct, 'pending' if wrong.
*/
const check = await client.verify.v2
.services(VERIFY_SERVICE_SID)
.verificationChecks.create({
to: phoneNumber,
code,
})
return check.status // 'approved' or 'pending'
}
Step 4: WhatsApp Messaging
// whatsapp.ts — Send WhatsApp messages via Twilio
// Requires WhatsApp Business API setup in Twilio console
await client.messages.create({
body: 'Your appointment is confirmed for tomorrow at 2 PM.',
from: 'whatsapp:+14155238886', // Twilio WhatsApp sandbox number
to: 'whatsapp:+15551234567',
})
// WhatsApp with template (required for initiating conversations)
// Use your own approved WhatsApp sender here, not the shared sandbox number
await client.messages.create({
from: `whatsapp:${process.env.TWILIO_WHATSAPP_NUMBER}`, // e.g. +14155550123
to: 'whatsapp:+15551234567',
contentSid: 'HXb5b62575e6e4ff6129ad7c8efe1f983e', // approved template SID
contentVariables: JSON.stringify({ '1': 'John', '2': 'March 15' }),
})
Step 5: Receive Incoming Messages (Webhooks)
// app/api/webhooks/twilio/route.ts — Handle incoming SMS/WhatsApp messages
import { NextRequest, NextResponse } from 'next/server'
import twilio from 'twilio'
const { MessagingResponse } = twilio.twiml
export async function POST(req: NextRequest) {
const formData = await req.formData()
const params = Object.fromEntries(
[...formData.entries()].map(([k, v]) => [k, String(v)])
)
// Reject forged requests: the URL must be exactly what is configured in the Twilio console
const signature = req.headers.get('x-twilio-signature') ?? ''
const valid = twilio.validateRequest(
process.env.TWILIO_AUTH_TOKEN!,
signature,
'https://app.northwindparcels.com/api/webhooks/twilio',
params
)
if (!valid) return new NextResponse('Invalid signature', { status: 403 })
const { From: from, Body: body, MessageSid: messageSid } = params
console.log(`Incoming from ${from}: ${body}`)
// Auto-reply with TwiML
const response = new MessagingResponse()
if (body.toLowerCase().includes('status')) {
response.message('Your order is on its way! Expected delivery: tomorrow.')
} else if (body.toLowerCase().includes('help')) {
response.message('Available commands: STATUS, HELP, CANCEL')
} else {
response.message('Thanks for your message! Reply HELP for options.')
}
return new NextResponse(response.toString(), {
headers: { 'Content-Type': 'text/xml' },
})
}
Установить twilio в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл twilio?
Add SMS, voice calls, and WhatsApp messaging with Twilio. Use when a user asks to send SMS messages, make phone calls programmatically, add two-factor authentication via SMS, send WhatsApp messages, build an IVR system, set up phone number verification, receive incoming SMS, or build communication features into an app. Covers SMS, MMS, WhatsApp, Verify API (2FA), voice calls, and webhooks.
Как установить скилл twilio?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл twilio запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic