You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Quick Start: Integrating Azure OpenAI with ACS Job Router
15
15
16
-
## Prerequisites
16
+
Integrate ACS Job Router with Azure Open AI. Use Azure Open AI to pair your jobs to agents.
17
+
18
+
### Prerequisites
17
19
- Create an Azure OpenAI resource. [Setup Guide](../../../ai-services/openai/how-to/create-resource.md)
18
20
- Create an Azure Communication Services resource. [Setup Guide](../create-communication-resource.md)
19
21
- Clone the GitHub solution. [Integrating Azure OpenAI with ACS Job Router](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/JobRouterOpenAIIntegration)
20
22
- Visual Studio Code Installed. [Visual Studio Code](https://code.visualstudio.com/)
21
23
- Azure Functions Extension for Visual Studio Code. [Azure Function Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions)
22
24
23
-
## Overview
25
+
###Overview
24
26
25
27
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.
26
28
27
-
### Console Application
29
+
### Console application
28
30
- Manages ACS resources including policies and queues.
29
31
- Simulates job queuing and allocation.
30
32
31
-
### Azure Function Project
33
+
### Azure Function project
32
34
- Hosts API for Azure OpenAI integration.
33
35
- Manages worker scoring and job labels.
34
36
35
37
#### 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.
38
40
39
41
#### 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.
:::image type="content" source="./media/overview-sequence-diagram.png" alt-text="Screenshot of Job Router with Azure Open AI integration SequenceDiagram.":::
46
48
47
49
#### 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.
55
58
56
59
## Performance indicators used in this project
57
60
@@ -65,25 +68,21 @@ Workers are evaluated based on:
65
68
- Learn about ACS Job Router. [Job Router Concepts](../../concepts/router/concepts.md)
66
69
- Configure the BestWorker Distribution Policy using an Azure Function Scoring Rule. [Customize Worker Scoring](../../how-tos/router-sdk/customize-worker-scoring.md)
67
70
68
-
## Understanding Azure Function Deployments
71
+
## Understanding Azure Function deployments
69
72
- Learn about Azure Function Deployments. [Azure Function Deployments](../../../azure-functions/functions-deployment-technologies.md)
70
73
71
-
## Understanding Azure OpenAI Prompts
74
+
## Understanding Azure OpenAI prompts
72
75
- Learn about Azure Open AI prompt Engineering Techniques. [Prompt Engineering Techniques](../../../ai-services/openai/concepts/advanced-prompt-engineering.md)
73
76
74
-
## Deployment and Execution
77
+
## Deployment and execution
75
78
76
79
1. Open the OpenAiScoringFunction project in Visual Studio Code with the Azure Function Extension installed. Select 'Create Function App in Azure...'
:::image type="content" source="/media/function-select-subscription.png.png" alt-text="Screenshot of selecting subscription in VS Code.":::
87
86
88
87
3. Once your Function App is created, right-click on your App and select 'Deploy Function App...'
89
88
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:
92
91
[Azure OpenAI Service models](../../../ai-services/openai/concepts/models.md)
93
92
- b. Give your model a Deployment name and select “Create”
:::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.":::
104
99
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:
106
101
102
+
:::image type="content" source="/media/azure-function-enviornment-settings" alt-text="Screenshot of of Azure function enviornment settings example.":::
| OpenAIBaseURI | {Endpoint} | Endpoint URI from OpenAI Resource |
111
107
| OpenAIAPIKey | {Key} | Key from OpenAI Resource |
112
108
| 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 |
115
111
| DefaultCSAT | 1.5 | Default CSAT score for workers missing this label |
116
112
| DefaultOutcome | 0.5 | Default Outcome score for workers missing this label |
117
113
| DefaultAHT | 10:00 | Default AHT for workers missing this label |
@@ -121,14 +117,14 @@ Workers are evaluated based on:
121
117
8. Navigate to your ACS resource and copy down your connection string.
122
118
9. Open the JR_AOAI_Integration Console application and open the `appsettings.json` file to update the following config settings.
123
119
124
-

120
+
:::image type="content" source="/media/appsettings-configuration.png" alt-text="Screenshot of AppSettings.":::
125
121
126
122
10. Run the application and follow the on-screen instructions to Create a Job.
127
123
128
124
## Experimentation
129
125
130
126
Various experiments can be conducted within this project, such as:
131
127
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).
0 commit comments