|
| 1 | + |
| 2 | +|page_type|languages|products |
| 3 | +|---|---|---| |
| 4 | +|sample|<table><tr><td>Typescript</tr></td></table>|<table><tr><td>azure</td><td>azure-communication-services</td></tr></table>| |
| 5 | + |
| 6 | +# Connect to a room call using Call Automation SDK |
| 7 | + |
| 8 | +In this quickstart sample, we cover how you can use Call Automation SDK to connect to an active Azure Communication Services (ACS) Rooms call with a connect endpoint. |
| 9 | +This involves creating a room call with room id and users and enabling PSTN dial out to add PSTN participant(s). |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- Create an Azure account with an active subscription. For details, see [Create an account for free](https://azure.microsoft.com/free/) |
| 14 | +- [Visual Studio Code](https://code.visualstudio.com/download) installed |
| 15 | +- [Node.js](https://nodejs.org/en/download) installed |
| 16 | +- Create an Azure Communication Services resource. For details, see [Create an Azure Communication Resource](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource). You will need to record your resource **connection string** for this sample. |
| 17 | +- Get a phone number for your new Azure Communication Services resource. For details, see [Get a phone number](https://learn.microsoft.com/azure/communication-services/quickstarts/telephony/get-phone-number?tabs=windows&pivots=programming-language-csharp) |
| 18 | + |
| 19 | +- To know about rooms see https://learn.microsoft.com/en-us/azure/communication-services/concepts/rooms/room-concept |
| 20 | +- To join room call see https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/rooms/join-rooms-call?pivots=platform-web |
| 21 | + |
| 22 | +## Before running the sample for the first time |
| 23 | + |
| 24 | +1. Open an instance of PowerShell, Windows Terminal, Command Prompt or equivalent and navigate to the directory that you would like to clone the sample to. |
| 25 | +2. git clone `https://github.com/Azure-Samples/communication-services-javascript-quickstarts.git`. |
| 26 | +3. cd into the `callautomation-connect-rooms-quickstart` folder. |
| 27 | +4. From the root of the above folder, and with node installed, run `npm install` |
| 28 | + |
| 29 | +## Before running calling rooms quickstart |
| 30 | +1. To initiate rooms call with room id https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/calling-rooms-quickstart |
| 31 | +2. cd into the `calling-rooms-quickstart` folder. |
| 32 | +3. From the root of the above folder, and with node installed, run `npm install` |
| 33 | +4. to run sample `npx webpack serve --config webpack.config.js` |
| 34 | + |
| 35 | +### Setup and host your Azure DevTunnel |
| 36 | + |
| 37 | +[Azure DevTunnels](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows) is an Azure service that enables you to share local web services hosted on the internet. Use the commands below to connect your local development environment to the public internet. This creates a tunnel with a persistent endpoint URL and which allows anonymous access. We will then use this endpoint to notify your application of calling events from the ACS Call Automation service. |
| 38 | + |
| 39 | +```bash |
| 40 | +devtunnel create --allow-anonymous |
| 41 | +devtunnel port create -p 8080 |
| 42 | +devtunnel host |
| 43 | +``` |
| 44 | + |
| 45 | +### Configuring application |
| 46 | + |
| 47 | +Open the `.env` file to configure the following settings |
| 48 | + |
| 49 | +1. `CONNECTION_STRING`: Azure Communication Service resource's connection string. |
| 50 | +2. `ACS_RESOURCE_PHONE_NUMBER`: Phone number associated with the Azure Communication Service resource. For e.g. "+1425XXXAAAA" |
| 51 | +3. `TARGET_PHONE_NUMBER`: Target phone number to add in the call. For e.g. "+1425XXXAAAA" |
| 52 | +4. `CALLBACK_URI`: Base url of the app. (For local development replace the dev tunnel url) |
| 53 | +5. `COGNITIVE_SERVICES_ENDPOINT` : Cognitive service endpoint. |
| 54 | + |
| 55 | +### Run app locally |
| 56 | + |
| 57 | +1. Open a new Powershell window, cd into the `callautomation-connect-rooms-quickstart` folder and run `npm run dev` |
| 58 | +2. Browser should pop up with the below page. If not navigate it to `http://localhost:8080/` |
| 59 | +3. To connect rooms call, click on the `Connect a call!` button or make a Http get request to https://<CALLBACK_URI>/connectCall |
| 60 | + |
| 61 | +### Creating and connecting to room call. |
| 62 | + |
| 63 | +1. Navigate to `http://localhost:8080/` or devtunnel url to create users and room id  |
| 64 | +2. Open two tabs for Presenter and attendee  |
| 65 | +3. Copy tokens for presenter and attendee from  |
| 66 | +4. Initialize call agent with tokens for both presenter and attendee. |
| 67 | +5. Take room id  and initiate rooms call for both users.  |
| 68 | +6. Connect room call with call automation connect call endpoint.  |
| 69 | + |
| 70 | + |
0 commit comments