This use case briefly shows how to set up email AI analysis via Power Automate.
Before you start
- The Nimbus Power Automate Connector preconditions are met.
- A service with Email modality is set up. See Use Case - Setting Up Email.
- You require agent or service owner rights to access Email content in Power Automate.
- You need an Azure AI Studio license and credits for creating and using AI models. Refer to https://ai.azure.com/.
INC Icon Legend Accordion
Show Icon Legend
💡 = A hint to signal learnings, improvements or useful information in context. | 🔍 = Info points out essential notes or related page in context. |
☝ = Notifies you about fallacies and tricky parts that help avoid problems. | 🤔 = Asks and answers common questions and troubleshooting points. |
❌ = Warns you of actions with irreversible / data-destructive consequence. | ✅ = Intructs you to perform a certain (prerequired) action to complete a related step. |
Flow Overview
The flow starts with the “When a task changes state” Trigger Event from the Nimbus Power Automate Connector on the event when an agent accepts the email. We then set a system message and call the AI model via HTTP using a specific system message and the email content as inputs. We'll get a JSON response back where we need to find the answer for further processing. After that, we can update the task and post an adaptive card into the chat with the agent.
Show flow overview…
How-to Steps
Prepare the View in Nimbus
In Nimbus we want to get this view when a new email is accepted by an agent:
To achieve this, we need to create the parameters Summary, Sentiment and Reply in Nimbus. In the service settings of the service receiving the emails we need to add these parameters to the My Sessions View. Go to the admin portal Services > Edit Service > Extensions and add the parameters to the Session Parameter list:
Create and deploy an AI model
In Azure AI Studio, we deploy the chat completion model GPT-4o. ☝Note down the URL and the key for later use.
Go to the chat playground and experiment with the system message. The following message will be used in our Power Automate flow:
You will be given an Email. Given the email, you need to summarize it, then give a sentiment score and draft a possible short reply. Please return your answer as a machine readible JSON of the following format without using markdown:
{
"Summary": "Martina Willig is extremely dissatisfied with her recent order, receiving a yellow painted cupboard instead of the ordered table",
"Sentiment": "-2 (Negative)",
"Reply": "Dear Martina Willig,
I sincerely apologize for the inconvenience. Thank you for your patience and understanding.
Best regards,
[Your Name]
Customer Service Team"
}
Create the Flow in Power Automate
Start with “When a task changes state” trigger and set the event to “Connected to User”, filter on Email modality and Inbound. | |
Add a variable to the flow and name it “SystemMessage”. Add the system message you explored in Azure AI Studio to it. | |
Add a HTTP element to the flow and enter the URL and api-key from your model to it.
💡 We recommend using an Azure Key Vault for any api-keys. You can create an environment variable in Power Automate which will hold the value in a more secure way. Read more about it here Use environment variables for Azure Key Vault secrets - Power Apps | Microsoft Learn.
Add the following content to the body:
|
|
Add a Parse JSON element to the flow. Content=@{body('HTTP')} Schema=
|
|
Add a Compose element to the flow Input=@{outputs('HTTP')?['body']['choices'][0]['message']['content']} |
|
Add a Parse JSON element to the flow Content=@{outputs('HTTP')?['body']['choices'][0]['message']['content']} Schema=
|
|
Now Update the Nimbus Task with the Values from the AI response mapped to the parameters. | |
Additionally, you can send an adaptive card with the analysis to a channel or a chat Recipient=@{triggerOutputs()?['body/LastConnectedUserUPN']} Card JSON=
|
Test Your Flow
- Go to Microsoft Copilot and generate a fake Email. You can reuse these prompts:
- please generate a sample email from an angry customer complaining about a wrong order
- please generate a random sample email from an happy customer
- please generate a random sample email from customer with neutral sentiment
- Send an email to your service to start the trigger.
- Accept the Email task in Nimbus.
- You should now see the analysis and the adaptive card.