Twilio SMS Channel
The Twilio channel allows you to send SMS notifications via the Twilio service. This channel supports regular phone numbers, Twilio messaging services, and alphanumeric senders. It uses the Twilio Programmable SMS API.
Batching
This channel does not support batching. Each SMS is sent individually.
Configuration
import { defineConfig } from 'facteur'
import { twilioChannel } from '@facteurjs/adonisjs/channels/twilio'
export default defineConfig({
channels: {
twilio: twilioChannel({
// Required configuration
accountSid: 'your-twilio-account-sid',
authToken: 'your-twilio-auth-token',
// Default phone number to send messages from
from: '+1234567890',
// Twilio messaging service SID (recommended by Twilio)
messagingServiceSid: 'your-messaging-service-sid',
// Alphanumeric sender (for supported regions)
alphanumericSender: 'YourApp',
// Maximum price per message in USD
maxPrice: 0.05,
// Debug mode - redirect all messages to this number
debugTo: '+1234567890',
// Enable URL shortening
shortenUrls: true,
// Twilio error codes to ignore
ignoredErrorCodes: [21614, '*'],
})
},
})
Configuration Options
accountSid(required): Your Twilio account SIDauthToken(required): Your Twilio authentication tokenfrom(optional): Default phone number to send messages frommessagingServiceSid(optional): Twilio messaging service SID (recommended)alphanumericSender(optional): Alphanumeric sender for supported regionsmaxPrice(optional): Maximum price per message in USDdebugTo(optional): In debug mode, redirect all messages to this numbershortenUrls(optional): Enable automatic URL shorteningignoredErrorCodes(optional): List of Twilio error codes to ignore (use'*'to ignore all errors)
Targets
The Twilio channel targets are:
await facteur
.notification(MyNotification)
.via({
twilio: {
// Recipient phone number (required)
to: '+1234567890',
// Optional: override the sender for this specific message
from: '+0987654321'
}
})
.send()
Target Properties
to(required): The recipient's phone number in international formatfrom(optional): Override the sender for this specific message