Skip to content

Outbound Voice conferencing using Twilio Voice built on Twilio Serverless, with Twilio Verify for authentication

License

Notifications You must be signed in to change notification settings

kaustavdm/twilio-outbound-conference

Repository files navigation

Outbound call conference with Twilio Voice and Serverless

A Twilio Serverless application for making outbound voice calls using Twilio Programmable Voice. Connects agents and recipients using Conferences, featuring Twilio Verify for OTP validation during setup, along with a JWT-based authentication for starting call.

Workflow

  1. Setup: Agents verify email and phone via Twilio Verify OTP
  2. Call: Use JWT token to initiate authenticated calls

Key Features

  • Dual email/phone verification with JWT tokens with long validity
  • Phone uniqueness enforcement per email
  • Automatic agent detection from JWT
  • Configurable email domain restrictions (set via ALLOWED_EMAIL_DOMAINS)

API Endpoints

Setup initialization

Source: setup/init.js

POST /setup/init - Send OTPs to email and phone

Parameters:

  • email (required): Email address from allowed domains (if configured)
  • phone (required): Phone number for agent calls
curl -X POST 'https://{{domain}}/setup/init' \
-H 'Content-Type: application/json' \
-d '{"email": "[email protected]", "phone": "+19087654321"}'

Setup validation

Source: setup/validate.js

POST /setup/validate - Validate OTPs and get JWT token

Parameters:

  • email, email_code, phone, phone_code (all required)
curl -X POST 'https://{{domain}}/setup/validate' \
-H 'Content-Type: application/json' \
-d '{"email": "[email protected]", "email_code": "123456", "phone": "+19087654321", "phone_code": "789012"}'

Returns: JWT token in data.token field

Start a call

Source: call/start.js

POST /call/start - Start conference call using JWT token

Parameters:

  • token (required): JWT from setup validation
  • to (required): Customer phone number
  • confName (optional): Conference identifier
curl -X POST 'https://{{domain}}/call/start' \
-H 'Content-Type: application/json' \
-d '{"token": "JWT_TOKEN", "to": "+1234567890", "confName": "Call with Owl from Twilio"}'

Setup

Prerequisites

Environment Variables

  • CALLER_ID: Twilio phone number for outgoing calls
  • ALLOWED_EMAIL_DOMAINS: Comma-separated list of allowed email domains (optional, leave empty to allow any domain)
  • VERIFY_SERVICE_SID: Twilio Verify Service SID
  • SYNC_SERVICE_SID: Twilio Sync Service SID
  • JWT_SECRET: Strong secret key (32+ chars) for JWT signing.
  • DOMAIN_NAME: For local testing only, set this to the ngrok domain if you're using ngrok. This is automatically set when deploying to Twilio.

Deploy

twilio serverless:deploy

License

MIT

About

Outbound Voice conferencing using Twilio Voice built on Twilio Serverless, with Twilio Verify for authentication

Topics

Resources

License

Stars

Watchers

Forks