@venturialstd/twilio
v0.0.4
Published
Twilio Module for Venturial
Keywords
Readme
@venturialstd/twilio
A NestJS module for integrating Twilio messaging services (SMS, WhatsApp) into Venturial applications.
Features
- Twilio Client: Wrapper for Twilio SDK with dynamic configuration
- Message Service: Send SMS and WhatsApp messages
- Webhook Support: Handle incoming messages via webhooks
- Event-Driven: Event emitter integration for message handling
- Settings Integration: Dynamic configuration via Venturial's SettingsService
Installation
npm install @venturialstd/twilioUsage
Import the Module
import { Module } from '@nestjs/common';
import { TwilioModule } from '@venturialstd/twilio';
@Module({
imports: [TwilioModule],
})
export class AppModule {}Send Messages
import { TwilioMessageService } from '@venturialstd/twilio';
@Injectable()
export class MyService {
constructor(private readonly twilioService: TwilioMessageService) {}
async sendSMS(to: string, message: string) {
await this.twilioService.sendMessage(null, to, message);
}
}Webhook Controller
The module includes a webhook controller at /general/twilio/webhook that handles incoming Twilio messages and emits events.
Settings
The module uses Venturial's SettingsService for configuration. Configure the following settings:
GLOBAL:TWILIO:GENERAL:ENABLED- Enable/disable the moduleGLOBAL:TWILIO:GENERAL:ACCOUNT_SID- Twilio Account SIDGLOBAL:TWILIO:GENERAL:AUTH_TOKEN- Twilio Auth TokenGLOBAL:TWILIO:GENERAL:PHONE_NUMBER- Twilio Phone Number
Events
The module emits the following events:
webhook_incoming_message- When a message is received via webhooksend_message- Trigger to send a message (handled by TwilioMessageListener)
Development
# Build
npm run build
# Test
npm run test:devPublishing
# Build and publish patch version
npm run release:patch