Skip to content

Commit 269ead8

Browse files
Updates per comments
1 parent be79068 commit 269ead8

10 files changed

+38
-40
lines changed

articles/communication-services/quickstarts/router/job-router-aoai-integration.md renamed to articles/communication-services/quickstarts/router/job-router-azure-open-ai-integration.md

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,48 @@ ms.service: azure-communication-services
1313

1414
# Quick Start: Integrating Azure OpenAI with ACS Job Router
1515

16-
## Prerequisites
16+
Integrate ACS Job Router with Azure Open AI. Use Azure Open AI to pair your jobs to agents.
17+
18+
### Prerequisites
1719
- Create an Azure OpenAI resource. [Setup Guide](../../../ai-services/openai/how-to/create-resource.md)
1820
- Create an Azure Communication Services resource. [Setup Guide](../create-communication-resource.md)
1921
- Clone the GitHub solution. [Integrating Azure OpenAI with ACS Job Router](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/JobRouterOpenAIIntegration)
2022
- Visual Studio Code Installed. [Visual Studio Code](https://code.visualstudio.com/)
2123
- Azure Functions Extension for Visual Studio Code. [Azure Function Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions)
2224

23-
## Overview
25+
### Overview
2426

2527
This quick start demonstrates how to integrate Azure Open AI with ACS Job Router to intelligently choose the best-suited worker based on performance indicators for an incoming job.
2628

27-
### Console Application
29+
### Console application
2830
- Manages ACS resources including policies and queues.
2931
- Simulates job queuing and allocation.
3032

31-
### Azure Function Project
33+
### Azure Function project
3234
- Hosts API for Azure OpenAI integration.
3335
- Manages worker scoring and job labels.
3436

3537
#### This guide covers two main projects:
36-
1. A .NET console application to interact with ACS Job Router.
37-
2. An Azure Function project for OpenAI integration with ACS Job Router.
38+
- A .NET console application to interact with ACS Job Router.
39+
- An Azure Function project for OpenAI integration with ACS Job Router.
3840

3941
#### The console application is set up to provision the following ACS resources:
40-
1. A distribution policy that lets ACS Job Router understand how to generate offers for workers. This application is configured to provision a Best-Worker mode distribution policy that uses a Function Router Rule for scoring workers.
41-
2. A queue with the best-worker mode distribution policy attached.
42-
3. Five workers that are registered to a queue with three chosen performance indicator values populated as labels.
43-
4. Creates a Job in ACS Job Router and lets the user know which worker Azure OpenAI scored the highest based on the performance indicator labels.
42+
- A distribution policy that lets ACS Job Router understand how to generate offers for workers. This application is configured to provision a Best-Worker mode distribution policy that uses a Function Router Rule for scoring workers.
43+
- A queue with the best-worker mode distribution policy attached.
44+
- Five workers that are registered to a queue with three chosen performance indicator values populated as labels.
45+
- Creates a Job in ACS Job Router and lets the user know which worker Azure OpenAI scored the highest based on the performance indicator labels.
4446

45-
![SequenceDiagram](./media/Overview%20sequence%20diagram.png)
47+
:::image type="content" source="./media/overview-sequence-diagram.png" alt-text="Screenshot of Job Router with Azure Open AI integration SequenceDiagram.":::
4648

4749
#### The Azure Function project is set up to interact with a deployed Azure OpenAI model.
48-
1. The Azure function receives a request from ACS Job Router with a payload containing the worker's labels (performance indicators).
49-
2. The Azure function extracts those values from the request.
50-
3. The Azure function was preconfigured with a prompt to explain to the Azure Open AI model how to interpret each one of these performance indicators and to ask Azure OpenAI to score each worker based on these values to find the most suitable agent for a new job.
51-
> **Note:** The prompt can be updated for any desired outcome. For example, you could modify the prompt to weigh the Average Handling Time as the most important data point or ask the model to optimize for customer satisfaction.
52-
4. The Azure Function sends a request with the configured prompts and worker performance indicators, and Azure OpenAI responds back with a JSON Object containing the scores generated by Azure Open AI.
53-
5. The Azure Function then sends these scores back to ACS Job Router.
54-
6. ACS Job Router then sends an offer to the worker that was scored the highest by Azure OpenAI.
50+
- The Azure function receives a request from ACS Job Router with a payload containing the worker's labels (performance indicators).
51+
- The Azure function extracts those values from the request.
52+
- The Azure function was preconfigured with a prompt to explain to the Azure Open AI model how to interpret each one of these performance indicators and to ask Azure OpenAI to score each worker based on these values to find the most suitable agent for a new job.
53+
> [!NOTE]
54+
> The prompt can be updated for any desired outcome. For example, you could modify the prompt to weigh the Average Handling Time as the most important data point or ask the model to optimize for customer satisfaction.
55+
- The Azure Function sends a request with the configured prompts and worker performance indicators, and Azure OpenAI responds back with a JSON Object containing the scores generated by Azure Open AI.
56+
- The Azure Function then sends these scores back to ACS Job Router.
57+
- ACS Job Router then sends an offer to the worker that was scored the highest by Azure OpenAI.
5558

5659
## Performance indicators used in this project
5760

@@ -65,25 +68,21 @@ Workers are evaluated based on:
6568
- Learn about ACS Job Router. [Job Router Concepts](../../concepts/router/concepts.md)
6669
- Configure the BestWorker Distribution Policy using an Azure Function Scoring Rule. [Customize Worker Scoring](../../how-tos/router-sdk/customize-worker-scoring.md)
6770

68-
## Understanding Azure Function Deployments
71+
## Understanding Azure Function deployments
6972
- Learn about Azure Function Deployments. [Azure Function Deployments](../../../azure-functions/functions-deployment-technologies.md)
7073

71-
## Understanding Azure OpenAI Prompts
74+
## Understanding Azure OpenAI prompts
7275
- Learn about Azure Open AI prompt Engineering Techniques. [Prompt Engineering Techniques](../../../ai-services/openai/concepts/advanced-prompt-engineering.md)
7376

74-
## Deployment and Execution
77+
## Deployment and execution
7578

7679
1. Open the OpenAiScoringFunction project in Visual Studio Code with the Azure Function Extension installed. Select 'Create Function App in Azure...'
7780

78-
<p align="center">
79-
<img src="./media/CreateAzureFunctionFromCode.png" alt="CreateFunctionApp"/>
80-
</p>
81+
:::image type="content" source="/media/create-azure-function-from-code.png" alt-text="Screenshot of CreateFunctionApp in VS Code.":::
8182

8283
2. After selecting your Subscription, enter a unique name for your function app.
8384

84-
<p align="center">
85-
<img src="./media/FunctionSelectSubscription.png" alt="SetFunctionName"/>
86-
</p>
85+
:::image type="content" source="/media/function-select-subscription.png.png" alt-text="Screenshot of selecting subscription in VS Code.":::
8786

8887
3. Once your Function App is created, right-click on your App and select 'Deploy Function App...'
8988
4. Open the Azure portal and go to your Azure OpenAI resource, then go to Azure AI Studio. From here, navigate to the Deployments tab and select "+ Create new deployment"
@@ -92,26 +91,23 @@ Workers are evaluated based on:
9291
[Azure OpenAI Service models](../../../ai-services/openai/concepts/models.md)
9392
- b. Give your model a Deployment name and select “Create”
9493

95-
<p align="center">
96-
<img src="./media/AOAIModelCreation.png" alt="CreateAOI_Model"/>
97-
</p>
94+
:::image type="content" source="/media/azure-open-ai-model-creation.png" alt-text="Screenshot of creating azure open ai model.":::
9895

9996
5. Once your Azure OpenAI Model is created, copy down the 'Endpoint', 'Keys', and 'Region'
10097

101-
<p align="center">
102-
<img src="./media/AOI_KeyAndEndpoint.png" alt="AOI_Details"/>
103-
</p>
98+
:::image type="content" source="/media/azure-open-ai-keys-and-endpoints.png" alt-text="Screenshot of of key and endpoint page for Azure Open AU.":::
10499

105-
6. In the Azure Portal, navigate to your newly created Function App Environmental Variables blade and create the following variables:
100+
6. In the Azure portal, navigate to your newly created Function App Environmental Variables blade and create the following variables:
106101

102+
:::image type="content" source="/media/azure-function-enviornment-settings" alt-text="Screenshot of of Azure function enviornment settings example.":::
107103

108104
| Name | Value | Description |
109105
|-----------------|------------------|--------------------------------------------------------------------|
110106
| OpenAIBaseURI | {Endpoint} | Endpoint URI from OpenAI Resource |
111107
| OpenAIAPIKey | {Key} | Key from OpenAI Resource |
112108
| DeploymentName | {DeploymentName} | Deployment Name from OpenAI Resource |
113-
| Preprompt | You're helping pair a customer with an agent in a contact center. You'll evaluate the best available agent based on their performance indicators below. CSAT holds the average customer satisfaction score between 1 and 3, higher is better.Outcome is a score between 0 and 1, higher is better. AHT is average handling time, lower is better. If AHT provided is 00:00, please ignore it in the scoring.| Prompt containing preprocessing instructions for the Azure OpenAI model |
114-
| Postprompt | Respond with only a json object with agent Id as the key, and scores based on suitability for this customer as the value in a range of 0 to 1. Don't include any other information.| Prompt containing postprocessing instructions for the Azure OpenAI model |
109+
| Preprompt | You're helping pair a customer with an agent in a contact center. You'll evaluate the best available agent based on their performance indicators below. CSAT holds the average customer satisfaction score between 1 and 3, higher is better. Outcome is a score between 0 and 1, higher is better. AHT is average handling time, lower is better. If AHT provided is 00:00, please ignore it in the scoring.| Prompt containing preprocessing instructions for the Azure OpenAI model |
110+
| Postprompt | Respond with only a json object with agent ID as the key, and scores based on suitability for this customer as the value in a range of 0 to 1. Don't include any other information.| Prompt containing postprocessing instructions for the Azure OpenAI model |
115111
| DefaultCSAT | 1.5 | Default CSAT score for workers missing this label |
116112
| DefaultOutcome | 0.5 | Default Outcome score for workers missing this label |
117113
| DefaultAHT | 10:00 | Default AHT for workers missing this label |
@@ -121,14 +117,14 @@ Workers are evaluated based on:
121117
8. Navigate to your ACS resource and copy down your connection string.
122118
9. Open the JR_AOAI_Integration Console application and open the `appsettings.json` file to update the following config settings.
123119

124-
![AppSettings](./media/AppSetingsConfig.png)
120+
:::image type="content" source="/media/appsettings-configuration.png" alt-text="Screenshot of AppSettings.":::
125121

126122
10. Run the application and follow the on-screen instructions to Create a Job.
127123

128124
## Experimentation
129125

130126
Various experiments can be conducted within this project, such as:
131127

132-
1. Experimenting with the PrePrompt string (in the Environment Variables of the Azure Function) to further tune scores provided by Azure OpenAI.
133-
2. Add other performance indicator labels to workers, updating the OpenAiScorer class in the OpenAIScorerFunction project to account for new labels and updating the prompts, default performance indicators in the Environment Variables of your function, and add the new performance indicators into the `appSettings.json` file under each worker.
134-
3. Implement logic to update the values of the performance indicator labels as jobs are completed by each worker. This could be by adding persistence or a cache to your application to store these values. Labels are routable attributes in Job Router. If a worker's labels are updated, any offers issued for that worker will be revoked. Consider updating labels at a point when the worker isn't expecting offers (AvailableForOffers – false, or when the worker’s capacity is consumed).
128+
- Experimenting with the PrePrompt string (in the Environment Variables of the Azure Function) to further tune scores provided by Azure OpenAI.
129+
- Add other performance indicator labels to workers, updating the OpenAiScorer class in the OpenAIScorerFunction project to account for new labels and updating the prompts, default performance indicators in the Environment Variables of your function, and add the new performance indicators into the `appSettings.json` file under each worker.
130+
- Implement logic to update the values of the performance indicator labels as jobs are completed by each worker. This could be by adding persistence or a cache to your application to store these values. Labels are routable attributes in Job Router. If a worker's labels are updated, any offers issued for that worker will be revoked. Consider updating labels at a point when the worker isn't expecting offers (AvailableForOffers – false, or when the worker’s capacity is consumed).
38.2 KB
Loading

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ items:
199199
items:
200200
- name: Submit a job for queuing and routing
201201
href: quickstarts/router/get-started-router.md
202+
- name: Integrating Azure OpenAI with Job Router
203+
href: quickstarts/job-router-azure-open-ai-integration.md
202204
- name: Network Traversal
203205
items:
204206
- name: Access TURN relays

0 commit comments

Comments
 (0)