DEV Community

Der Sascha
Der Sascha

Posted on • Originally published at blog.bajonczak.com on

Harnessing AI with Power Automate for Streamlined EMail Management

Harnessing AI with Power Automate for Streamlined EMail Management

I think AI is now becoming a mainstream tool. So I wondered if it can help me in my daily business.

In may daily work I filter out the CC Mails, so that I am not getting distracted from any unimportant things. But what if it escalates and I did not recognize it? So for this I try to use AI for now. To use it easyly its better to get an ready to use tool that integrated in the ecosystem. So I give Power automat a try.

What is Powerautomate

Power Automate, formerly known as Microsoft Flow, is a robust automation platform by Microsoft. It allows users to create automated workflows across various applications and services without extensive coding. With its user-friendly interface and seamless integration with Microsoft and third-party apps, Power Automate simplifies tasks, streamlines processes, and enhances productivity. Leveraging Microsoft's cloud infrastructure, it ensures scalability, reliability, and security, making it an indispensable tool for businesses seeking efficiency and innovation. It provide many connectors and triggers so that it is possible to react on many ways and do all with the given data.

How to use it for my case

So I drawed a small diagram for this:

Harnessing AI with Power Automate for Streamlined EMail Management

So when I receive an E-Mail the flow must then anaylze the content if it contains negative segments. If this is true, then I get a notification (in Teams) that there is a mail that contains a negative content.

Create the flow

First of all, I create a new flow in the powerautomat dashboard. For this I will go to the following site https://make.powerautomate.com/. On this page I click Create and select the "automated cloud-flow" option. Take this screenshot as references (sorry only german screen available)

Harnessing AI with Power Automate for Streamlined EMail Management

After that, I can define a name for the flow and select the trigger. I use the trigger, when an E-mail arrives

Harnessing AI with Power Automate for Streamlined EMail Management

After hitting create You are in the flow designer. It looks likt the Logicapp designer but it has more integrated things that we will use then

Generating the Workflow

The first step after receiving the email, you convert the E-Mail body to plain text. Because the AI -Model does not work with HTML bodies.

Harnessing AI with Power Automate for Streamlined EMail Management

Now the next step is to shorten the body to a maximum 500 characters, So it will take only the first email. In some cases it is more than 500 characters but for this demo case I assume that most mails did not have more than 500 characters written down because you do not need the complete history in it.

Harnessing AI with Power Automate for Streamlined EMail Management

The next part is the important part.

Harnessing AI with Power Automate for Streamlined EMail Management

I use the the AI builder part to identify the positive or negative mood of the mail.

The next stept are simple, I will get the actual Offie Profile to get the account in Teams. After that it will check the outcome of the AI Builder step. When the mood was negative it will send me a message through teams with the content of the mail

Harnessing AI with Power Automate for Streamlined EMail Management

The AI Builder Task

Let's deep dive into the AI builder Task. Let's assume that you get the following input

{
    "host": {
        "connectionReferenceName": "shared_commondataserviceforapps",
        "operationId": "PredictV2"
    },
    "parameters": {
        "item/requestv2/language": "en",
        "item/requestv2/text": "Neue Ankündigung in der Microsoft Partner Community Community im Microsoft 365\nPartner Community Viva Engage Netzwerk\n\nMicrosoft 365 Partner Community\n[https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.yammer.com%2Foffice365partners%2Fhome%3Ftrk_event%3Dcom_network_click%26allow_app_redirect%3D1&data=05%7C02%7Csascha.bajonczak%40realcore.de%7Cc7fe517e352d4bf0ee3908dc2fb172e3%7C99c7da5256fc49caaa958f7fb09c995e%7C0%7C0%7C638437686431021901%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=8wmiJy4zg7MdaYFlA3Ovfw9YV6Ye3i5%2FnyqGiekDRjg%3D&reserved=0]\nViva Engage\n[https://mailie.assets-yammer.com/mailer_images/viva-word-logo-grey.png]\n\nJasper Pagsinohin hat eine neue Ankündigung in Microsoft Partner Community\ngepostet\n\n[https://mailie.assets-yammer.com/mailer_images/blowhorn-icon-red.png]\nAnkündigung gepostet in Microsoft Partner Community\n[https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.ya",
        "recordId": "f1c549c2-a97e-47a5-b612-c5c2bab0f163"
    }
}
Enter fullscreen mode Exit fullscreen mode

This is a notification about a yammer group that I participate. No worry it's a shared group no private stuff here. So the AI Builder Task will takt this and analyze the content for now, the results are this

..... "body": {
        "@odata.context": "https://....crm4.dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.PredictResponse",
        "responsev2": {
            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
            "operationStatus": "Success",
            "predictionId": "14202776-317f-44ee-b79c-d7e3d75aa682",
            "predictionOutput": {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "result": {
                    "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                    "sentiment": "neutral",
                    "documentScores": {
                        "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                        "positive": 0.07,
                        "neutral": 0.91,
                        "negative": 0.02
                    },
                    "sentences@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
                    "sentences": [
                        {
                            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                            "sentiment": "neutral",
                            "offset": 0,
                            "length": 599,
                            "sentenceScores": {
                                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                                "positive": 0.11,
                                "neutral": 0.84,
                                "negative": 0.04
                            }
                        },
                        {
                            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                            "sentiment": "neutral",
                            "offset": 0,
                            "length": 125,
                            "sentenceScores": {
                                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                                "positive": 0.05,
                                "neutral": 0.93,
                                "negative": 0.02
                            }
                        },
                        {
                            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                            "sentiment": "neutral",
                            "offset": 0,
                            "length": 118,
                            "sentenceScores": {
                                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                                "positive": 0.12,
                                "neutral": 0.86,
                                "negative": 0.01
                            }
                        },
                        {
                            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                            "sentiment": "neutral",
                            "offset": 0,
                            "length": 84,
                            "sentenceScores": {
                                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                                "positive": 0.04,
                                "neutral": 0.95,
                                "negative": 0.01
                            }
                        },
                        {
                            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                            "sentiment": "neutral",
                            "offset": 0,
                            "length": 71,
                            "sentenceScores": {
                                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                                "positive": 0.01,
                                "neutral": 0.99,
                                "negative": 0.01
                            }
                        }
                    ]
                }
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

You see several information but important is this fragemnt

"documentScores": {
                        "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                        "positive": 0.07,
                        "neutral": 0.91,
                        "negative": 0.02
                    },
Enter fullscreen mode Exit fullscreen mode

This represents the mood for the complete document what we send to the AI -Builder. In this case you get a prediction of 91% that the mood is neutral. There are not so negative and positive fragments in it.

The following example analyzed a positive mail

...
    "body": {
        "@odata.context": "https://.....crm4.dynamics.com/api/data/v9.1/$metadata#Microsoft.Dynamics.CRM.PredictResponse",
        "responsev2": {
            "@odata.type": "#Microsoft.Dynamics.CRM.expando",
            "operationStatus": "Success",
            "predictionId": "570422bb-d5be-4570-b72b-adf4a6a0cd43",
            "predictionOutput": {
                "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                "result": {
                    "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                    "sentiment": "positive",
                    "documentScores": {
                        "@odata.type": "#Microsoft.Dynamics.CRM.expando",
                        "positive": 0.54,
                        "neutral": 0.41,
                        "negative": 0.05
                    },
                   ........
Enter fullscreen mode Exit fullscreen mode

You see that this mail contains a prediction of 54% that this content is more positive. Also it assumes that the content is 41% neutral mood. But in this case the content was very positive, thrust me 😄

Sending the results to Teams

So in my case I want to send it to teams when the content is identified as negative content. You saw above this IF-Segment. In this I will check Against the outcome of the AI-Builder. I Check if the outcome is "negative" and then it will send me a message to me via teams

Harnessing AI with Power Automate for Streamlined EMail Management

The Result

So in my case when I get a message to teams. Here is an example for a negative E-Mail content:

Harnessing AI with Power Automate for Streamlined EMail Management

Conclusion

Powerautomate (aka Flow) is a very handy tool, because it integrates into the MS Ecosystem and in my example It reacts on the mood of an E-Mail content. For me it's very handy, because I get several CC-Mails that is not in my direct focus. But when it "escalates" than the process will notify me, so that I can take action or helping out.

I think this is a good example in which case AI can help to get more productive. It saved me time and I can focus on my work again.

What are your thoughts?

Top comments (0)