Twilio Voice JavaScript Reference Components leverages Web Components to showcase integrated backend and frontend implementations for common Twilio Voice use cases. Please visit the official developer documentation for more details.
The reference components demonstrate several common Twilio Voice use cases. These use cases include:
- Dialer Component
- Make outgoing calls
- Receive incoming calls
- Basic Call Control Component (leveraging Conference)
- Perform cold and warm transfers
- Add or remove participants from a call
- Hold and Resume a call
- Mute and Unmute a call
- Monitoring calls (leveraging Conference)
- Callee call progress
- Conference call status
- Quality metrics
- Warnings
- Errors
- Clone the Twilio Voice JavaScript Reference Components GitHub repository.
git clone https://github.com/twilio/twilio-voice-js-reference-components.git
- Install the dependencies.
npm install
- Create a
.env
file and populate the following environment variables under thetwilio-voice-js-reference-components
folder. Go through the quickstarts for more information about these variables.
# Port number to run the server on
PORT=3030
# Twilio account sid
ACCOUNT_SID=ACxxxxxxxxxxxxxx
# Twilio API key
API_KEY_SID=SKxxxxxxxxxxxxxx
# Twilio API secret
API_KEY_SECRET=xxxxxxxxxxxxxx
# Twilio TwiML App sid where the Voice Request URL is set to
# https://yourdomain/twilio-voice-dialer/twiml
# See more info about TwiML set up by visiting https://www.twilio.com/docs/voice/sdks/javascript#twiml-applications
APP_SID=APxxxxxxxxxxxxxx
# Twilio auth token
AUTH_TOKEN=xxxxxxxxxxxxxx
# Caller ID
CALLER_ID=+11234567890
# If developing locally and running the Reference Components locally, consider using a tool like ngrok to proxy the server endpoints. Once proxied, change CALLBACK_BASE_URL to the ngrok URL endpoints.
# See more info about ngrok by visiting https://ngrok.com.
CALLBACK_BASE_URL=https://foo.ngrok.dev
# Default identity to use
DEFAULT_IDENTITY=alice
- Start the local server under the
twilio-voice-js-reference-components
folder.
npm start
- Access the following components under the following URLs.
- Dialer related components, access http://localhost:3030/twilio-voice-dialer?identity=bob.
- Call control related components, access http://localhost:3030/twilio-voice-basic-call-control?identity=bob.
- Monitoring related components, access http://localhost:3030/twilio-voice-monitoring?identity=bob.