I have recently been working on a requirement to store case summary data. In this post I will explain how I created an approach to store a “snapshot” of an AI generated summary as cases are resolved.

My Requirement
If you have experimented with the copilot case summary option, you’ll already know how useful an AI summary can be. Quickly being able to view a short paragraph about a potentially complex case can save significant amounts of time.

The Copilot case summary option works from the case form. A user simply opens the summary control and within a few seconds they have an informative summary. (As shown below.)

But I recently had a requirement to show an AI case summary in case views or when data is exported to Excel etc. Meaning I wanted to generate a summary and show it in views without needing to open the case form.

In my requirement I simply wanted to see a short paragraph directly from my resolved case in views. (As shown below.)

My Solution
My solution involved creating a Power Automate that would create a summary based on the case description plus any emails exchanged between the support team and the customer.

This is just an example! I guess I could have extended this solution to look at other activity types, case notes and more.

In the remainder of this post, I will explain the approach I adopted.

Case changes
The changes I made to the case table were extremely simple. I just created a new column called “Ai Summary”. This was a multi-line text field.

I then simply added this new field to my case forms and views as required.

In my solution I decided to only populate the summary as cases are resolved. Meaning I just needed to add this new field into my “Resolved Case” views.

Power Automate
I created an automated Power Atomate that would populate my summary as cases are resolved. Meaning it was triggered as the case status was modified to resolved. (For good measure I also check the summary is already blank, so I avoid triggering my Flow more often than expected!)


Next, I started to build a string containing information about the case. (We’ll see how I use this later.) For this I use an “Initialize variable” action.

My string will contain details about the case and associated emails.

As I initialize a variable called “CaseData” I add the case number, title and description into the string. (I could have added any other fields I thought might be useful, but these worked for my purposes.)

The next part of my Flow will list all the emails associated with the case. For this I added a “Dataverse List Rows” action. With the table set to “Email Messages”. And in my filter, I added regardingobjectid_value eq ‘<<Case GUID>>’, meaning I would list all of the emails associated with the case.

FYI: I could have expanded this logic to also include other activity types! But in my example most conversations with the customer were via email.

I now have an “Apply to each” control. (Which is passed the output value from my list rows action.)

Within my apply to each loop I use the “Html to text” action. I’m doing this as the email body could contain all sorts of html formatting and I wanted to remove this to give the AI Summarize action a fighting chance at understanding the content of the email.

Tip: I did first try this solution without converting the email body to text. I found the approach still worked but the summary seemed to be less accurate.

All I am doing is adding the email description into a “Html to text” action.

Now I can append the results of my “html to text” action to the variable I created earlier. I use an append action meaning I am building one large string with the text from the case and all associated emails.

Below you can see that I add the email subject and email description into my “CaseData” variable.

Notice I have used a “substring” formula when adding the email description. I have done this as emails could be very long and I want my string to stay within the maximum size possible for the AISummarize action.

My substring formula was substring(body(‘Html_to_text’),0,100). This will simply take the first 100 characters of the out of my “html to text” action. I could have taken more than 100 characters but for my purposes 100 seemed enough.

So now I have a string I’d like to summarize. For this add a dataverse “Perform an unbound action” tile into my Flow.

The unbound action I have selected is called “AISummarize”.

I then add my “CaseData” variable into the text field. Meaning the action will summarize my case details and all associated emails.

Finally, I want to write the result of my unbound action back into the case. You may recall I’d created a custom field called “AI Sumamry”!

Therefore, I add a Dataverse “Update a row” action. I select the case entity for my table name. And the “Row ID” will be the GUID of the case which triggered this Flow.

Then I add the “SummarizedText” field, which is an output of my unbound action, into my custom field.

Considerations
You may need to consider a few pre-requisites / limitations, including.

Hopefully, in this post I have shown how we can simply use the “AISummarize” action. Obviously in this example my focus has been cases and associated emails. But you could adapt this idea to work on all sorts of Dynamics 365 records. Including Contacts, Leads, Opportunities, Work Orders and more. Enjoy!

Leave a comment

Trending

Website Powered by WordPress.com.