Voice JavaScript SDK quickstart
This quickstart shows you how to create a web application that makes a phone call from a web browser. It uses the Voice JavaScript SDK and Twilio Functions; our serverless hosting platform.
The Twilio CLI tool lets you manage your Twilio resources from your command line utility.
macOSWindowsLinux
- Install Homebrew.
- Install the Twilio CLI by running this command:
brew tap twilio/brew && brew install twilio
To create and deploy Twilio Functions from the command line, install the Twilio CLI serverless plugin.
twilio plugins:install @twilio-labs/plugin-serverless
- To create your app, run the following Twilio CLI command.
twilio serverless:init quickstart-voice-javascript-sdk --template="voice-javascript-sdk"
- Change directories with the following command:
cd quickstart-voice-javascript-sdk
- Open the
.env
file in a code editor. The file includes this line:ADMIN_PASSWORD=default
. - Replace
default
with a unique password that's hard to guess. - Save the
.env
file. - Deploy your application with the following Twilio CLI command.
This command creates a Service. Services contain your Functions, Assets, and Environments within Twilio Serverless.twilio serverless:deploy
- When the deployment completes, the terminal displays a response with the following.
Make a note of your deployment domain (for example,1Deployment Details2Domain: quickstart-voice-javascript-sdk-6210-dev.twil.io
quickstart-voice-javascript-sdk-6210-dev.twil.io
).
- Open a web browser to
https://{DEPLOYMENT_DOMAIN}/admin/index.html
.
Replace{DEPLOYMENT_DOMAIN}
with your deployment domain. - Enter the password that you added to the
.env
file in the Password box. - Click Let me in.
- Click Initialize your application for your environment.
- Under Environmental Checks, click the running application link.
- Click Start up the Device and wait for the Call button to appear.
- Under Make a Call, enter your mobile phone number in the box.
- Click Call.
- If your web browser prompts you, allow the website to use your microphone.
- Your phone will ring with a call from your Twilio number.
Get a deeper understanding of the Voice JavaScript SDK by taking the following steps:
- Learn about how your app implements the Voice JavaScript SDK by reading the code in the
assets/quickstart.js
file. - See our Reference Components for the Voice JavaScript SDK.
- Learn about best practices to follow while building with the Voice JavaScript SDK.