Skip to content

TwilioService

Defined in: lib/module/twilio.service.ts:27

Service providing access to the Twilio SDK client.

@Injectable()
export class SmsService {
constructor(private readonly twilio: TwilioService) {}
async sendSms(to: string, body: string) {
return this.twilio.client.messages.create({
from: process.env.TWILIO_PHONE_NUMBER,
to,
body,
});
}
}
new TwilioService(options): TwilioService;

Defined in: lib/module/twilio.service.ts:33

Parameter Type Description
options TwilioModuleOptions & Partial<{ }> Module options containing account credentials

TwilioService

get client(): Twilio;

Defined in: lib/module/twilio.service.ts:50

Access the underlying Twilio SDK client. Use this to call any Twilio API method.

const message = await this.twilioService.client.messages.create({
from: '+1234567890',
to: '+0987654321',
body: 'Hello!',
});

Twilio