Edit

Share via


ACS Call Automation and Azure OpenAI Service

This sample application was demonstrated during Microsoft Ignite 2024. It highlights an integration of Azure Communication Services with Azure OpenAI Service to enable intelligent conversational agents.

In this sample, we cover off what this sample does and what you need as prerequisites before we run this sample locally on your machine.

Download code

Find the project for this sample on GitHub. You can download this code and run it locally to try it for yourself.

Overview

This server-side application helps create a virtual assistant that can handle phone calls and respond to customers using Azure OpenAI services, providing quick and real-time answers.

Prerequisites

Note

Bidirectional Streaming in Azure Communication Services is generally available, but the Azure OpenAI real-time API has its own release schedule. For up-to-date info on the API’s availability, check out the official docs.

Set up instructions

Before running this sample, you need to set up the resources with the following configuration updates:

1. Set up and host your Azure DevTunnel

Azure DevTunnels is an Azure service that enables you to share local web services hosted on the internet. Use the commands 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 use this endpoint to notify your application of calling events from the ACS Call Automation service.

devtunnel create --allow-anonymous
devtunnel port create -p 5165
devtunnel host
2. Add the required API Keys and endpoints

Open the appsettings.json file to configure the following settings:

    - DevTunnelUri: your dev tunnel endpoint
    - AcsConnectionString: Azure Communication Service resource's connection string.
    - AzureOpenAIServiceKey: Open AI's Service Key
    - AzureOpenAIServiceEndpoint: Open AI's Service Endpoint
    - AzureOpenAIDeploymentModelName: Open AI's Model name

Running the application

  1. Azure DevTunnel: Ensure your AzureDevTunnel URI is active and points to the correct port of your localhost application
  2. Run dotnet run to build and run the sample application
  3. Register an Event Grid Webhook for the IncomingCall Event that points to your DevTunnel URI. Instructions here. For example:
 https://<devtunelurl>/api/incomingCall

Once that's completed, you should have a running application. The best way to test this is to place a call to your ACS phone number and talk to your intelligent agent.

Next steps

Download code

Find the project for this sample on GitHub. You can download this code and run it locally to try it for yourself.

Overview

This server-side application helps create a virtual assistant that can handle phone calls and respond to customers using Azure OpenAI services, providing quick and real-time answers.

Prerequisites

Note

Bidirectional Streaming in Azure Communication Services is generally available, but the Azure OpenAI real-time API has its own release schedule. For up-to-date info on the API’s availability, check out the official docs.

Before running the sample for the first time

  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.
  2. git clone https://github.com/Azure-Samples/communication-services-javascript-quickstarts.git.
  3. cd into the callautomation-az-openai-voice folder.
  4. From the root of the folder, and with node installed, run npm install
1. Set up and host your Azure DevTunnel

Azure DevTunnels is an Azure service that enables you to share local web services hosted on the internet. Use the commands 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 use this endpoint to notify your application of calling events from the ACS Call Automation service.

devtunnel create --allow-anonymous
devtunnel port create -p 8080
devtunnel host
2. Add the required API Keys and endpoints

Open the .env file to configure the following settings

  1. CONNECTION_STRING: Azure Communication Service resource's connection string.
  2. CALLBACK_URI: Base url of the app. (For local developments replace the dev tunnel url)
  3. AZURE_OPENAI_SERVICE_KEY: Azure OpenAI service key
  4. AZURE_OPENAI_SERVICE_ENDPOINT: Azure OpenAI endpoint
  5. AZURE_OPENAI_DEPLOYMENT_MODEL_NAME: Azure OpenAI deployment name

Running the application

Run app locally

  1. Open a new PowerShell window, cd into the callautomation-az-openai-voice folder and run npm run dev
  2. Browser should pop up with a page. If not, navigate it to http://localhost:8080/
  3. Register an Event Grid Webhook for the IncomingCall Event that points to your 8080 port URI. Instructions here. For example:
 https://<devtunelurl>/api/incomingCall

Once that's completed, you have a running application. The best way to test this is to place a call to your ACS phone number and talk to your intelligent agent.

Next steps