nestjs-twilio
Dependency-injected Twilio SDK client for NestJS, with webhook signature validation, TwiML response serialization, automatic error mapping, and multi-account support.
What it does
Section titled “What it does”Inject the Twilio clientRegister the SDK client once with TwilioModule.forRoot(), then inject it anywhere with @InjectTwilio() or the TwilioService wrapper.
Validate webhook signaturesTwilioWebhookGuard and @TwilioWebhook() verify the X-Twilio-Signature header, including behind proxies and for JSON bodies.
Return TwiML responsesReturn a VoiceResponse, MessagingResponse or FaxResponse builder from a controller and TwimlInterceptor serializes it to XML.
Handle Twilio errorsTwilioExceptionFilter maps the SDK's RestException onto a Nest HttpException, preserving the Twilio error code and more_info link.
Use multiple accountsRegister named clients for subaccounts with TwilioModule.registerClient() and inject them with @InjectTwilio(name).
Mint access tokensIssue short-lived tokens for the Voice, Video, Conversations and Sync client SDKs, signed with an API key.
Add health checksReport Twilio API reachability and credential validity through a Terminus health indicator.
Test your integrationOverride the injected client, sign fixture webhooks, and assert on TwiML and mapped errors without calling Twilio.