fastify-xtwilio
Twilio plugin for SMS, Conversations API, and RCS messaging.
fastify-xtwilio
Twilio communications plugin covering SMS, Conversations API for messaging threads, and RCS.
Installation
npm install @xenterprises/fastify-xtwilio
Quick Start
await fastify.register(xTwilio, {
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
fromNumber: process.env.TWILIO_PHONE_NUMBER,
})
API
// Send SMS
await fastify.xtwilio.sms.send({
to: '+15555551234',
body: 'Your verification code is 123456',
})
// Create Conversation
const conversation = await fastify.xtwilio.conversations.create({
friendlyName: `Support: ${ticketId}`,
})
// Add participant
await fastify.xtwilio.conversations.addParticipant(conversation.sid, {
messagingBinding: { address: '+15555551234', proxyAddress: process.env.TWILIO_PHONE_NUMBER }
})
// Send message in conversation
await fastify.xtwilio.conversations.sendMessage(conversation.sid, {
body: 'Hello! How can we help you today?',
author: 'Support Bot',
})
AI Context
package: "@xenterprises/fastify-xtwilio"
decorates: fastify.xtwilio
namespaces: [sms, conversations, rcs]
use-when: Sending SMS notifications, building messaging features, RCS rich cards
env-required: [TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_PHONE_NUMBER]
conversations: thread-based messaging with participants (users ↔ support agents)
