Skip to contentSkip to navigationSkip to topbar
On this page

Voice JavaScript SDK: Reference Components


(information)

Info

You're viewing the documentation for the 2.X version of the Voice JavaScript SDK. View the Migration Guide to learn how to migrate from 1.X to 2.X or view the 1.x-specific documentation.


Overview

overview page anchor

While the quickstarts enable you to quickly set up a functional application for making and receiving phone calls via a web browser in just a few minutes, the reference components offer flexible building blocks for your Twilio Voice applications. Designed around common Twilio Voice use cases, these components leverage Web Components(link takes you to an external page) to showcase integrated backend and frontend implementations. You can easily incorporate these components into your application or use them as a foundation for your development needs.

Before proceeding, take a moment to explore how the JavaScript SDK works and review the getting started page to familiarize yourself with key concepts.

  • Use cases
  • Installation
  • Running locally

The reference components demonstrate several common Twilio Voice use cases. For detailed implementation guidance, visit the Twilio Voice JavaScript Reference Components(link takes you to an external page) repository. These use cases include:

  • Making outgoing calls
  • Receiving incoming calls
  • Managing calls: hold, resume, or mute
  • Performing cold and warm transfers
  • Adding or removing participants from a call

  1. Clone the Twilio Voice JavaScript Reference Components(link takes you to an external page) GitHub repository.
git clone https://github.com/twilio/twilio-voice-js-reference-components.git
  1. Create a .env file and initialize the following environment variables under the twilio-voice-js-reference-components folder. Go through the quickstarts for more information about these variables.
1
# Port number to run the server on
2
PORT=3030
3
4
# Twilio account sid
5
ACCOUNT_SID=ACxxxxxxxxxxxxxx
6
7
# Twilio API key
8
API_KEY_SID=SKxxxxxxxxxxxxxx
9
10
# Twilio API secret
11
API_KEY_SECRET=xxxxxxxxxxxxxx
12
13
# Twilio TwiML App sid where the Voice Request URL is set to
14
# https://yourdomain/twilio-voice-dialer/twiml
15
APP_SID=APxxxxxxxxxxxxxx
16
17
# Twilio auth token
18
AUTH_TOKEN=xxxxxxxxxxxxxx
19
20
# Caller ID
21
CALLER_ID=+11234567890
22
23
# Callback base URL
24
CALLBACK_BASE_URL=https://foo.ngrok.dev
25
26
# Default identity to use
27
DEFAULT_IDENTITY=alice
  1. Install the dependencies.
npm install

  1. Start the local server under the twilio-voice-js-reference-components folder.
npm start
  1. Access the following components under the following urls.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.