Skip to content

Files

Latest commit

5799db9 · Dec 17, 2021

History

History

add-1-on-1-phone-calling

page_type languages products
sample
javascript
azure
azure-communication-services

Add 1 on 1 phone calling to your application

This code sample walks through the process of integration Azure Communication Services phone calling into your JavaScript application.

This quickstart sample includes the code that is explained as part of this document. See that document for additional details on how this sample works.

Prerequisites

Before running sample code

  1. Pass the User Access Token with VOIP scope type in Client.js file at line no 13 const tokenCredential = new AzureCommunicationTokenCredential('<USER ACCESS TOKEN with PSTN scope>');.
  2. With the Call enabled telephone number procured in pre-requisites, add it to the Client.js file. Assign your ACS telephone number at line no 24 call = callAgent.startCall([{phoneNumber: phoneToCall}], { alternateCallerId: {phoneNumber: 'ACS Number'}});.

Run the code

  1. Run npm i on the directory of the project to install dependencies

  2. Use the webpack-dev-server to build and run your app. Run the following command to bundle application host in on a local webserver:

     npx webpack-dev-server --entry ./client.js --output bundle.js --debug --devtool inline-source-map
    

Open your browser and navigate to http://localhost:8080/. You should see the following:

Render of sample application

You can make an 1:1 outgoing phone call by providing a phone number in the text field and clicking the Start Call button.