I wanted to try AI Builder and found out quite basic business need. People are reading shared mailbox and categorizing emails for different queues – maybe asking more information. Automatizing this is nothing new but I wanted to try myself and use AI Builder. We also built integration for Public 360 case management, that it would create case and document for it, when user sends email to shared mailbox.

Actually everything is happening inside one Power Automate. Besides that we needed shared mailbox and the developer needed to be owner of the mailbox and also have permissions for Send behalf of Send as. Automation is replying user emails as customer service.

We use Teams channel message (adaptive card) and replies for this as user interface what is happening in the solution on the background. In actual solution error reporting should be placed with maybe Azure Application Insights or Power Platform monitoring tools.

Custom Category Classification Model

Go to https://make.powerapps.com/environment/[your_environment_guid]/aibuilder/models and select new model and then Classify texts into custom categories

I needed to get at least 10 tag and sentence for each tag. I used Bing (creative, ChatGPT 4) in Edge browser side to create me those sentences for Human Resources and Financial Department.

Prompt 1: Create me 15 sentences related to Finance Department and use different keywords in each of them.

Prompt 2: Create me 15 sentences related to Human Resources and use different keywords in each of them.

Then I copied these to Excel and imported those to Dataverse table, which was connected to my model. More specific instructions for creating custom model Overview of category classification model – AI Builder | Microsoft Learn

I think it was too precise way to go since AI Builder gives me unrealistic high score. But this is just a demo and not Proof of Concept for customer, so there is no need for refactoring this more. I’m going to demo the functionality of AI Builder in demo. With proof of concept I would need to teach the model for certain case.

Receive email Power Automate flow

Flow consists a bunch of variables and then quite straightforward logic for reading data and categorizing the email.

Process starts first checking if the email is reply or not

Then another block as condition it the email is sent first time.

These could be inside same scope and condition but better to split into separate actions because of better structure of a flow.

  • Create case to Dataverse and get GUID
  • Then use AI Builder to get metadata for the case with ready made models for sentiment, language and phrases

Category we should get every time

Because we want to loop the categories later on and be sure, if the category might change or related to another category after the user has replied the email.

  • Get category from AI Builder custom model
  • Filter the category and join them
  • Update category information to Dataverse row

Time to check whether email relates to a case or create a new one

  • Get case ID from email with regex
  • If found, set the variables for return email to user
  • If not found, create case to Public 360
  • Update the case number to Dataverse row
  • Inform user using Teams adaptive cards or reply for card posted when first email arrived

Each category needs certain properties

I want to test the entity extractor as well, so I attached different entities to my test categories Finance and Human Resources

  • I get my recognized category from Dataverse and properties for it
  • Then I extract the entities from email
  • Crosscheck that does the email contain all needed categories
  • Finally format the output and email message to user which properties are missing

Then create document and file to Public 360

If all properties are given

  • Create the document under the case
  • If creating document fails, report it to Teams with reply and separated error message to another channel
  • Then add the email as file with format of HTM

Finally reply the user that document received