Summary
Implement the Twilio SMS provider for sending ticket confirmations and critical alerts to Nigerian phone numbers (+234).
API Reference
- Docs: https://www.twilio.com/docs/messaging/api
- Endpoint:
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json
- Auth: Basic auth with Account SID + Auth Token
- From: Twilio phone number (configured in env)
SMS Templates
SMS messages must be concise (160 chars for single SMS, up to 1600 for concatenated).
Ticket Confirmation
HostIT: Your {ticketType} ticket for {eventName} is confirmed!
Ref: {reference}
Date: {date}
Venue: {venue}
View ticket: https://hostit.ng/tickets/{reference}
(~200 chars — 2 SMS segments)
Payment Failed
HostIT: Payment failed for {eventName}. Please try again: https://hostit.ng/events/{slug}
Implementation
// src/notifications/providers/twilio-sms.provider.ts
import * as twilio from 'twilio';
@Injectable()
export class TwilioSmsProvider {
private client: twilio.Twilio;
constructor(private configService: ConfigService) {
this.client = twilio(
this.configService.get('TWILIO_ACCOUNT_SID'),
this.configService.get('TWILIO_AUTH_TOKEN'),
);
}
async send(params: { to: string; body: string }): Promise<void> {
await this.client.messages.create({
to: params.to, // +234XXXXXXXXXX
from: this.configService.get('TWILIO_PHONE_NUMBER'),
body: params.body,
});
}
}
Tasks
Nigerian Phone Number Notes
- Format:
+234XXXXXXXXXX (13 chars total)
- Remove leading 0 if user enters local format (0801... → +234801...)
- Twilio supports Nigerian numbers on standard messaging
Acceptance Criteria
- SMS sent via Twilio API to +234 numbers
- Ticket confirmation SMS includes reference, event, venue, and link
- Phone number validated before sending
- Twilio errors handled gracefully (logged, notification marked FAILED)
- Dev mode: SMS logged to console
- Messages kept concise for cost efficiency
Summary
Implement the Twilio SMS provider for sending ticket confirmations and critical alerts to Nigerian phone numbers (+234).
API Reference
POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.jsonSMS Templates
SMS messages must be concise (160 chars for single SMS, up to 1600 for concatenated).
Ticket Confirmation
(~200 chars — 2 SMS segments)
Payment Failed
Implementation
Tasks
pnpm add twiliosrc/notifications/providers/twilio-sms.provider.ts:send()with to and bodyrenderSmsTemplate(type, data) → stringNigerian Phone Number Notes
+234XXXXXXXXXX(13 chars total)Acceptance Criteria