Should I let Azure OpenAI reply to my emails?

What if AI could reply to all your emails, would you let it? In this blog post, I have created a short proof of concept that does exactly that: let AI answer emails on your behalf. This is done by using Power Automate and Azure OpenAI.

The flow looks at the current email chain, and at the last 25 emails from the user that sends the email to you. This to get some context from old emails if needed. I have instructed it to reply in any language.

To learn how to create an AI instance and get an API key to use in the requests, look at this previous blog post here.

Start with the When a new email Arrives (V3) trigger.
No settings are needed other than the connection needs to be the account that is to reply to the emails.

Use the data you get from the “When a new email arrives (V3)” trigger to fill out these fields.

Use the data you get from the “Get emails (V3)” action to fill out this field.

{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant. You reply to all emails for me. My signature should be Alexander Holmeset, Senior Cloud Consultant, Contoso. You can reply in all languages. format your reply in html"
},
{
"role": "user",
"content": "@{item()?['bodyPreview']}. The following is a history of previous emails, dont add it to your reply. @{variables('EmailHistory')}"
}
]
}
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"object": {
"type": "string"
},
"created": {
"type": "integer"
},
"model": {
"type": "string"
},
"choices": {
"type": "array",
"items": {
"type": "object",
"properties": {
"finish_reason": {
"type": "string"
},
"index": {
"type": "integer"
},
"message": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"content": {
"type": "string"
}
}
}
},
"required": [
"finish_reason",
"index",
"message"
]
}
},
"usage": {
"type": "object",
"properties": {
"prompt_tokens": {
"type": "integer"
},
"completion_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
}
}
}
}

Add the Message property from the “Parse JSON” action.

Use the data you get from the “When a new email arrives (V3)” trigger to fill out these fields.

Below you can see some examples of emails that my AI assistant has replied to.

Leave a comment