Skip to content

Commit

Permalink
Merge pull request Microsoft-USEduAzure#92 from Microsoft-USEduAzure/…
Browse files Browse the repository at this point in the history
…Vishal/LabsUpdate0905

Vishal/labs update0905
  • Loading branch information
cricex authored Sep 12, 2023
2 parents a653582 + 0c66e17 commit 62b7588
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 239 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ The following prerequisites must be completed before you start these labs

- Required Resource Providers [How to Register Azure Services](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-providers-and-types)

- Azure OpenAI
- Microsoft.Search
- Microssoft.Functions
- Microssoft.Web
- Microsoft.Authorization
- Microsoft.CognitiveServices
- Microsoft.ManagedIdentity
- Microsoft.KeyVault
- Microsoft.Storage
- Microsoft.Insights
- Microsoft.Application
- Microsoft.LogicApps
- Microsoft.Logic
- Microsoft.BotService

- [VS Code](https://code.visualstudio.com/download) installed on your computer.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documents/images/lab-1-ModelName.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/images/lab-1-savelogicapp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 58 additions & 27 deletions labs/Lab_1_Automate_Mailbox_Responses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ Logic App 1 (read-mailbox-techsupport): reads incoming email from an Outlook mai

Logic App 2 (email-techsupport-integration): Calls Azure OpenAI for answers to the user support question and emails back a response.

### Note:

We will deploy the second logic app first because we will need its URL when provisioning the first logic app.
> [!NOTE]
> We will deploy the second logic app (email-techsupport-integration) first, as we will need its URL when provisioning the first logic app (read-mailbox-techsupport).
<img src="../../documents/images/lab-1-architecture.png" height=30%>

Expand All @@ -27,13 +26,15 @@ Go to https://portal.azure.com and enter your credentials
## Step 2. Deploy Logic App 2 (email-techsupport-integration)

### OpenAI Prompt Overview

This logic app uses the following prompt to answer questions sent to a technical support mail box:

_________________________________________________________________________
---

You are a Helpdesk assistant. Extract the person's name and technical problem from the text below. Provide possible solutions including links to websites in html. If no solutions are found, respond with 'We will get back to you in 48 hrs'.
If this is a hardware problem give them tips for troubleshooting and indicate we will create a support ticket and schedule a repair within 48 hours.

______________________________________________________________________________
---

In this step you are going to perform the following actions to deploy and configure the logic app:

Expand All @@ -42,78 +43,108 @@ In this step you are going to perform the following actions to deploy and config
- Enter Azure OpenAI authentication credentials
- Configure your connection to Outlook

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FMicrosoft-USEduAzure%2FOpenAIWorkshop%2Fmain%2Flabs%2FLab_1_Automate_Mailbox_Responses%2Fscripts%2Fopen_ai_integration%2Ftemplate.json)

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FMicrosoft-USEduAzure%2FOpenAIWorkshop%2Fmaster%2Flabs%2FLab_1_Automate_Mailbox_Responses%2Fscripts%2Fopen_ai_integration%2Ftemplate.json)

After the deployment you should see two new items in your resource group

![](../../documents/images/lab-1-logicapp-1.png)
![](../../documents/images/lab-1-logicapp-1.png)


Click on the logic app and click on the edit button
Click on the logic app and click on the edit button

![](../../documents/images/lab-1-logicapp-2.png)
![](../../documents/images/lab-1-logicapp-2.png)

Expand the first box "When an HTTP request is received" and copy the URL to your text editor

Expand the first Logic App Step named "When an HTTP request is received" and copy the URL to your text editor

![](../../documents/images/lab-1-logicapp-3.png)

Scroll down to the HTTP box and enter your OpenAI api key and the OpenAI endpoint with the following format:

**"https://<YOUR_AZURE_OPENAI_RESOURCENAME>.openai.azure.com/openai/deployments/<DEPLOYMENT_NAME>/completions?api-version=2022-12-01"**
Scroll down to locate the Logic App Step named "HTTP". If the box is not already open, click the Title bar to open it.

In the **URI** field, enter the URI of your Azure OpenAI Deployment endpoint, with the following format:

**"https://<YOUR_AZURE_OPENAI_RESOURCENAME>.openai.azure.com/openai/deployments/<DEPLOYMENT_NAME>/chat/completions?api-version=2023-05-15"**

You can find the <DEPLOYMENT_NAME> in the Azure OpenAI Studio Deployments blade as shown below:

![](../../documents/images/lab-1-ModelName.png)


In the **api-key** field, enter your Azure OpenAI API key.

> [!NOTE]
> Ensure the ?api-version for chat completions is recent, as new updates may have caused the api schema to change. See the **Supported versions** subsection, under **Completions** in [this article](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions).
![](../../documents/images/lab-1-logicapp-4.png)

Scroll down to the action box with the outlook logo and expand it to enter new authorizaion credentials for your mailbox:

Scroll down to the Logic App Step named **"Send email with oprions"**, the one with the Outlook logo, and expand it to enter new authorizaion credentials for your mailbox:

![](../../documents/images/lab-1-logicapp-5.png)

Scroll down to the condition option and expand it, then expand the true option. Select the valid connection to send the final notification in this logic app.

Scroll down to the Logic App Step named **"Condition"** and expand it, then expand the **True** box. Select the valid connection to send the final notification in this logic app.

![](../../documents/images/lab-1-logicapp-6.png)

> IMPORTANT: **Save the logic app**

Save the logic app.

![](../../documents/images/lab-1-savelogicapp.png)

### Step 3. Deploy Logic App 1 (read-mailbox-techsupport)

This logic app scans a mail box every X minutes for new emails with the subject: **"Helpdesk Bot"**.

![](../../documents/images/lab-1-logicapp-9.png)

Note: When you click the 'Deploy to Azure' button below, you will need to provide the URL to your second logic app (email-techsupport-integration) in the 'Email_integration_url' parameter field.
> [!IMPORTANT]
> When you click the 'Deploy to Azure' button below, you will need to provide the URL to your second logic app (email-techsupport-integration) in the 'Email_integration_url' parameter field.
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FMicrosoft-USEduAzure%2FOpenAIWorkshop%2Fmaster%2Flabs%2FLab_1_Automate_Mailbox_Responses%2Fscripts%2Freadmailbox%2Ftemplate.json)
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FMicrosoft-USEduAzure%2FOpenAIWorkshop%2Fmain%2Flabs%2FLab_1_Automate_Mailbox_Responses%2Fscripts%2Freadmailbox%2Ftemplate.json)

In this step you are going to perform the following actions to deploy and configure the logic app:

- Deploy the logic app that reads an Outlook mailbox and calls a logic app to send the user question to Azure OpenAI
- Configure your connection to Outlook

After the deployment you should see the new logic app your resource group, open the logic app and click the edit button
After the deployment you should see the new logic app in your resource group.

![](../../documents/images/lab-1-logicapp-7.png)


![](../../documents/images/lab-1-logicapp-7.png)
Click he new Logic App, then click the **Edit** button

Select the top box titled connection and select the appropiate connection to Office 365 outlook
![](../../documents/images/lab-1-logicapp-readmailbox-clickedit.png)


Select the top box titled **When a new email arrives (V3)** and select the appropiate connection to Office 365 outlook

![](../../documents/images/lab-1-logicapp-8.png)

### Step 4. Test

Send an email to the mailbox configured in your second logic app
> **Don't forget the email subject**
**"Helpdesk bot"**
Send an email, as follows, to the mailbox configured in your second logic app

You can use this test:
_______________________________________________________________
---
**Email Subject:**
Helpdesk bot

**Email body:**
Hello,

I can't login into my account, I need to reset my password. Also my keyboard is not working.

Thank you

Your Name
_______________________________________________________________

---


Monitor your Inbox for the automated email response. As soon as you receive it, open the email and **click one of the options provided**:

![](../../documents/images/Lab-1-screenshot-automatedemailresponsewithoptions.png)

Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"type": "AppendToStringVariable",
"inputs": {
"name": "finalanswer",
"value": "@items('For_each')?['text']"
"value": "@item()?['message']['content']"
}
}
},
Expand All @@ -141,7 +141,12 @@
"inputs": {
"body": {
"max_tokens": 400,
"prompt": "@variables('finalprompt')",
"messages": [
{
"content": "@variables('finalprompt')",
"role": "user"
}
],
"temperature": 0.2
},
"headers": {
Expand Down Expand Up @@ -251,16 +256,16 @@
"index": {
"type": "integer"
},
"logprobs": {},
"text": {
"message": {
"content": {
"type": "string"
}
}
},
"required": [
"text",
"message",
"index",
"finish_reason",
"logprobs"
"finish_reason"
],
"type": "object"
},
Expand Down Expand Up @@ -324,7 +329,7 @@
"HideHTMLMessage": false,
"Importance": "Normal",
"Options": "Useful, Not Useful",
"ShowHTMLConfirmationDialog": false,
"ShowHTMLConfirmationDialog": true,
"Subject": "Automated response from your Helpdesk AI bot",
"To": "@variables('emailto')"
},
Expand Down
Loading

0 comments on commit 62b7588

Please sign in to comment.