A VintaSend notification adapter using Twilio for reliable SMS and phone call delivery.
npm install vintasend-twilio twilioimport { TwilioNotificationAdapterFactory } from 'vintasend-twilio';
const adapter = new TwilioNotificationAdapterFactory().create(
templateRenderer,
false, // enqueueNotifications
{
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
fromNumber: '+1234567890',
}
);interface TwilioConfig {
accountSid: string; // Twilio Account SID
authToken: string; // Twilio Auth Token
fromNumber: string; // Default sender phone number
}await notificationService.createNotification({
userId: '123',
notificationType: 'SMS',
contextName: 'verification',
contextParameters: { code: '123456' },
title: 'Verification Code',
bodyTemplate: '/templates/verification.pug',
sendAfter: new Date(),
});Send SMS without a user account:
await notificationService.createOneOffNotification({
emailOrPhone: '+1987654321',
firstName: 'Jane',
lastName: 'Smith',
notificationType: 'SMS',
contextName: 'order-status',
contextParameters: { status: 'shipped' },
title: 'Order Status Update',
bodyTemplate: '/templates/order-status.pug',
sendAfter: new Date(),
});await notificationService.createNotification({
userId: '123',
notificationType: 'SMS',
contextName: 'reminder',
contextParameters: { appointmentTime: '2pm' },
title: 'Appointment Reminder',
bodyTemplate: '/templates/reminder.pug',
sendAfter: new Date('2024-01-15T14:00:00Z'),
});- ✅ SMS delivery via Twilio API
- ✅ One-off notifications
- ✅ Scheduled notifications
- ✅ Custom sender phone number
- ✅ Text message templates
- ✅ Global reach (190+ countries)
class TwilioNotificationAdapterFactory<Config extends BaseNotificationTypeConfig>Methods:
create<TemplateRenderer>(templateRenderer, enqueueNotifications, config)- Create adapter instance
Properties:
key: string- Returns'twilio'notificationType: NotificationType- Returns'SMS'supportsAttachments: boolean- Returnsfalse
Methods:
send(notification, context)- Send an SMS message
TWILIO_ACCOUNT_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TWILIO_AUTH_TOKEN=your-auth-token-here
TWILIO_FROM_NUMBER=+1234567890MIT