
I asked myself, can Azure OpenAI understand the tone of the text I am inputting? Turns out it can! Here is an example of the inputs I tested out. It can differentiate between for example if the text is neutral, positive, or negative.

What can we do with this? As a proof of concept I am creating a flow that can sort incoming support emails based on the tone of the language. We are going to move the emails into folders named Positive, Negative, and Neutral.
First of all, we need an API Key from Azure OpenAI. You can read about how you get that under the API Key header in my previous blog post, I wrote about “Getting started with Azure OpenAi and PowerShell“.
Next, we need to prepare the mailbox we are using, by creating the folders we are moving emails into.
Open Outlook web, and click “Create new folder”.

Enter the name and click Save. You need one for Positive, Negative, and Neutral.


Now got to flow.microsoft.com and create a new Automated Cloud Flow that is triggered by “When a new email arrives”.

Make sure you are authenticated with the user of the mailbox. (This is just a POC, you would rather use a shared mailbox in a real live scenario).
Click New Step.
Add an HTTP action
Enter the settings like below:
URI:
(the URI contains your Azure OpenAI resource name and deployment name)
https://azureopenaialex.openai.azure.com/openai/deployments/TextGenerator/completions?api-version=2022-12-01 |
Body:
{ | |
"prompt": "Is the following text possitive, negative or neutral? ", | |
"max_tokens": 2000 | |
} |

Add a Parse JSON action.

Add the following Schema:
{ | |
"type": "object", | |
"properties": { | |
"id": { | |
"type": "string" | |
}, | |
"object": { | |
"type": "string" | |
}, | |
"created": { | |
"type": "integer" | |
}, | |
"model": { | |
"type": "string" | |
}, | |
"choices": { | |
"type": "array", | |
"items": { | |
"type": "object", | |
"properties": { | |
"text": { | |
"type": "string" | |
}, | |
"index": { | |
"type": "integer" | |
}, | |
"finish_reason": { | |
"type": "string" | |
}, | |
"logprobs": {} | |
}, | |
"required": [ | |
"text", | |
"index", | |
"finish_reason", | |
"logprobs" | |
] | |
} | |
}, | |
"usage": { | |
"type": "object", | |
"properties": { | |
"completion_tokens": { | |
"type": "integer" | |
}, | |
"prompt_tokens": { | |
"type": "integer" | |
}, | |
"total_tokens": { | |
"type": "integer" | |
} | |
} | |
} | |
} | |
} |
Add an “Initialize variable” action.

Add a “Set variable” action, and choose “text” as the value. It now will automaticaly put this inside an “Apply to each” loop.

Create three parallel Conditions with a Move email action under “if Yes”.




Now all you have to do is to save the flow and start sending emails.
Here are some examples that I sent and got sorted into the correct folder.



Hope this gives you some inspiration on what you can do with Azure OpenAI text genearation.