Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This sample application was demonstrated during Microsoft Ignite 2024. It highlights the integration of Azure Communication Services with Azure OpenAI to enable intelligent conversational agents.
This article covers what this sample does and what you need as prerequisites before the sample runs 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 you create a virtual assistant that can handle phone calls and respond to customers by using Azure OpenAI. The virtual assistant quickly provides real-time answers.
Prerequisites
- An Azure account with an active subscription. For more information, see Create an account for free.
- An Azure Communication Services resource. For more information, see Create an Azure Communication Services resource. You need to record your resource connection string for this sample.
- A calling-enabled telephone number. For more information, see Get a phone number.
- An Azure dev tunnel. For more information, see Enable dev tunnels.
- An Azure OpenAI resource and deployed model. For more information, see Create an Azure OpenAI resource and deploy a model.
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 information on the API's availability, see Azure OpenAI in Azure AI Foundry models.
Setup instructions
Before you run this sample, you need to set up the resources with the following configuration updates.
Step 1: Set up and host your dev tunnel
With dev tunnels, you can share local web services that are hosted on the internet. Use the commands to connect your local development environment to the public internet. This process creates a tunnel with a persistent endpoint URL and allows anonymous access. We use this endpoint to notify your application of calling events from Call Automation.
devtunnel create --allow-anonymous
devtunnel port create -p 5165
devtunnel host
Step 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
Run the application
- Ensure that your
AzureDevTunnelURI is active and points to the correct port of your local host application. - Run
dotnet runto build and run the sample application. - Register an Azure Event Grid webhook for the
IncomingCallevent that points to yourDevTunnelURI. For more information, see Incoming call concepts. For example:
https://<devtunelurl>/api/incomingCall
Now you have a running application. The best way to test this sample is to place a call to your Azure Communication Services phone number and talk to your intelligent agent.
Related content
- Learn more about Call Automation.
- Learn more about bidirectional streaming.
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 you create a virtual assistant that can handle phone calls and respond to customers by using Azure OpenAI. The virtual assistant quickly provides real-time answers.
Prerequisites
- An Azure account with an active subscription. For more information, see Create an account for free.
- Visual Studio Code installed.
- Node.js installed.
- An Azure Communication Services resource. For more information, see Create an Azure Communication Services resource. You need to record your resource connection string for this sample.
- A phone number for your new Azure Communication Services resource. For more information, see Get a phone number.
- An Azure dev tunnel. For more information, see Enable dev tunnels.
- An Azure OpenAI resource and deployed model. For more information, see Create an Azure OpenAI resource and deploy a model.
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 information on the API's availability, see Azure OpenAI in Azure AI Foundry models.
Before you run the sample for the first time
- Open an instance of PowerShell, a Windows terminal, a command prompt, or the equivalent, and go to the directory where you want to clone the sample.
- Use the command
git clone https://github.com/Azure-Samples/communication-services-javascript-quickstarts.git. - Use the command
cdto access thecallautomation-az-openai-voicefolder. - From the root of the folder, and with a node installed, run
npm install.
Step 1: Set up and host your dev tunnel
With dev tunnels, you can share local web services that are hosted on the internet. Use the commands to connect your local development environment to the public internet. This process creates a tunnel with a persistent endpoint URL and allows anonymous access. We use this endpoint to notify your application of calling events from Call Automation.
devtunnel create --allow-anonymous
devtunnel port create -p 8080
devtunnel host
Step 2: Add the required API keys and endpoints
Open the .env file to configure the following settings:
CONNECTION_STRING: Azure Communication Services resource connection string.CALLBACK_URI: Base URL of the app. For local developments, replace the dev tunnel URL.AZURE_OPENAI_SERVICE_KEY: Azure OpenAI service key.AZURE_OPENAI_SERVICE_ENDPOINT: Azure OpenAI endpoint.AZURE_OPENAI_DEPLOYMENT_MODEL_NAME: Azure OpenAI deployment name.
Run the application
Run the app locally
Open a new PowerShell window, use the
cdcommand to open thecallautomation-az-openai-voicefolder, and runnpm run dev.The browser opens with a page. If it doesn't, go to
http://localhost:8080/.Register an Azure Event Grid webhook for the
IncomingCallevent that points to your 8080 port URI. For more information, see Incoming call concepts. For example:https://<devtunelurl>/api/incomingCall
Now you have a running application. The best way to test this sample is to place a call to your Azure Communication Services phone number and talk to your intelligent agent.
Related content
- Learn more about Call Automation.
- Learn more about bidirectional streaming.