These functions create a conference line that verifies the phone numbers of participants before joining them into a call. It will first verify that the number is on a list of valid numbers and then use Twilio Verify to verify they are not spoofing their number by sending them a code they have to enter.
- Create a Verify Service
- Add
VERIFY_SERVICE_SID
from above to your Environment Variables
This project requires some environment variables to be set. To keep your tokens and secrets secure, make sure to not commit the .env
file in git. When setting up the project with twilio serverless:init ...
the Twilio CLI will create a .gitignore
file that excludes .env
from the version history.
In your .env
file, set the following values:
Variable | Description | Required |
---|---|---|
ACCOUNT_SID |
Find in the console | Yes |
AUTH_TOKEN |
Find in the console | Yes |
VERIFY_SERVICE_SID |
Create one here | Yes |
MODERATOR_PHONE_NUMBER |
The phone number of the person moderating the conference line. People will stay in a lobby until this number joins. If the number leaves the conference, the line closes. | Yes |
VALID_PARTICIPANTS |
Phone numbers of valid participants. Comma separated | Yes |
/verify-conference
expects any default Twilio Voice webhook request parameter. It's also protected meaning it can only be accessed by Twilio once deployed.
/join-conference
should not be used alone and instead is used by /verify-conference
.
- Install the Twilio CLI
- Install the serverless toolkit
twilio plugins:install @twilio-labs/plugin-serverless
- Initiate a new project
twilio serverless:init verify-conference --template=conference-verify && cd verify-conference
- Start the server with the Twilio CLI:
twilio serverless:start
- Open the web page at https://localhost:3000/index.html and enter your phone number to test
ℹ️ Check the developer console and terminal for any errors, make sure you've set your environment variables.
Deploy your functions and assets with either of the following commands. Note: you must run these commands from inside your project folder. More details in the docs.
With the Twilio CLI:
twilio serverless:deploy
Once deployed make sure you set up the URL ending with /verify-conference
as your voice webhook URL for your phone number. For example:
twilio phone-numbers:update <yourTwilioNumber> --voice-url=https://verify-conference-0000-dev.twil.io/verify-conference