Route or deflect cases using AI Builder
Applies to: Dynamics 365 Customer Service
Case management is the core of any customer service solution. Dynamics 365 Customer Service offers many features to collect customer support inquiries, track them as cases, and get agents to work on a resolution.
Especially in solutions with Omnichannel for Customer Service, requests often come from multiple sources. Some of these channels imply direct interaction with the customer (such as through a chatbot or a phone call), which allows the collection of detailed information through scoping questions. However, other channels are asynchronous in nature, such as emails.
Working with unstructured data, as emails are by nature, can take extra effort when processing the resulting case, in order to achieve the following objectives:
- Analyze the original message
- Define the nature of the request
- Understand how the case needs to be assigned and resolved
Email-to-case process with automatic record creation and unified routing
Let's consider a typical scenario such as in the following illustration:
Many organizations have a support mailbox (such as support@contoso.com) that external contacts use to forward their support requests.
When this mailbox is associated with a queue in Customer Service, and the queue is configured to convert incoming emails to activities, every new incoming message is created as an email activity and registered as a queue item.
If you set up rules to automatically create or update records, these activities are automatically transformed into new cases.
Then, if you set up routing of records, the newly created cases are delivered to agents for resolution.
Since the case description was populated automatically with the email body, the actual request for the case could be hard to identify. Also, the customer could be sending the request to a wrong mailbox (such as a support request to an "info" mailbox).
For cases originating from emails, the organization may then need to have one or more agents dedicated to manually sorting through those cases, to triage and categorize them, and eventually route the request again to assign it to the proper owner.
This could require a significant effort in dedicated resources, and it might be a good idea to apply some automation in this scenario.
AI capabilities in unified routing
With unified routing, you can apply machine learning model-based rules during the work classification phase:
While these are powerful options at our disposal, there are still a few scenarios that might not be covered:
There's currently not an option to invoke another model—for example, a custom model.
The work classification rules are applied at workstream level. There isn't an option to apply machine learning at an early stage—for example, before the routing actually takes place.
Learn more at Create machine learning-based skill classification rulesets.
Note
Always check the product documentation and roadmap to be aware of all the latest available features. Learn more at Get started with Customer Service admin center.
Power Automate and AI Builder
When you set up the different types of automatic routing, you'll see the link Configure in Microsoft Power Automate. Modern routing actions are implemented as Power Automate flows. The automatically generated flow has some predefined steps, such as recognizing the email sender and create the case record. You can edit the flows to add more steps, such as the step added in the following illustration:
Note
Some of the predefined steps are restricted for editing. Changing or moving these steps in unsupported ways could prevent the routing from working properly.
Learn more at Route records automatically using custom flow.
You can also use AI Builder models in a flow in Power Automate. AI Builder offers many prebuilt models: sentiment analysis, category classification, language detection, entity extraction, and more. It's also possible to create and train a custom model.
Better email-to-case process with AI Builder
By applying the capabilities of Power Automate and AI Builder, it's possible to evolve the initial scenario:
If you add AI Builder actions to the routing flow, you can analyze the original text of the email, extract relevant information, categorize the case during initial creation, and allow the routing engine to identify the proper destination.
You can also add AI Builder actions in routing flows. To do that, you must add a custom GPT prompt in Power Platform's AI Prompt section. Learn more at Use your prompt in Power Automate.
The flexibility of the GPT prompt lets you define that you want to process an input text, and you can request that the text is categorized in one of the predefined categories. You can also specify that you want a text field containing a reason to justify the assigned category. To complete the prompt, ask to extract additional information from the text. Optionally, specify if you want the output formatted as JSON and include an example of the desired data structure.
You can test the prompt directly from the editor by providing a sample input text to get a preview of the output. This allows for some fine-tuning before saving the finalized prompt.
To use the newly created prompt in the existing flows, implement the following logic:
- Process the text of the incoming email
- Identify the category of the request
- Store the extracted information in the new case
Before proceeding, you must define new columns in the case table to store the values returned by the AI model:
It's also a good idea to add these new columns to the case form so that you can see their values during the test later.
Now that the data model is ready, you can start editing the flow in Power Automate. You'll want to position our new steps just after the check on the email sender, and right before the case creation:
When adding the new step, start by selecting the AI Builder connector to filter available actions, and then select the action Create text with GPT using a prompt:
In the configuration of the new step, specify the custom prompt that you saved in the earlier step, and pass the Description value from the incoming email as the input parameter:
Since the prompt returns a JSON output, add an additional step to process the JSON so that you can work with specific fields. To do so, use the native Parse JSON action, and provide a sample of the expected JSON to generate the corresponding schema:
Finally, use the extracted values in the existing step that will create the new case:
With these changes, the flow will perform the expected logic to transform an incoming email into a new case, but at the same time it will enrich the case with the results from the AI action.
Testing the process
Now that you've implemented all the changes, it's time to test the setup. As a prerequisite,correctly configure server-side-sync on a mailbox associated with the queue where the routing rule triggers; otherwise, you won't receive any emails.
Let's compose a new email, simulating the feedback from a dissatisfied customer, and send it to the queue you configured:
After a few minutes, the mail is synchronized in Dynamics 365 and registered as a new activity:
Now check the Power Automate flow and verify that it was correctly triggered:
Open the details of this execution so that you can check the results of the GPT prompt:
Finally, go back into Customer Service to see the generated case with the values stored in the record:
With these values, you can enter the configuration of the workstream, and define new routing rules to divert the case to a specific queue, based on the predicted category:
Even if you don't want to implement complete automation in your routing rules yet, and prefer to let your agents analyze incoming emails, you can greatly reduce their effort during the triage phase by providing a suggested category and a simple explanation.
Working with custom categories
In the previous example we provided a static list of categories in the definition of our prompt. But what if we want to define and maintain the categories in a Dataverse table? Let's say for example that we created an Email Category table to list the category values and insert a description of the category:
The GPT prompt editor allows us to perform grounding on Dataverse data, so we can edit our prompt to add a reference to our Email Category table, specify that the incoming text has to be matched with the category description and that we want the corresponding category name in return:
The results of this prompt will be very similar to what we obtained previously, but this time if we need to update the list of our categories, we can simply change the records in Dataverse and no change is required to the prompt definition.
This approach also allows us to build some kind of fine-tuning and continuous improvement process. In this example, we have users check the results of the automated email categorization, and confirm or change the assigned category. For that purpose, we implement a flow with steps as in the following list:
- Add in the case two columns, one for AI Category and one for Confirmed Category.
- Let predefined user roles double-check the category assigned by the AI.
- Users can confirm whether the assigned category is correct, or select a different one.
- Periodically extract all the records where Confirmed Category is different from AI Category.
- Analyze the list of records to understand what they have in common and why they were assigned a wrong category.
- Improve the descriptions of the affected categories to improve the accuracy of the AI model.
With a process such as this example, you can incrementally increase the accuracy of your flow, without the need for any change to your implemented solution. You could even try to use a GPT prompt to generate category descriptions starting from past resolved cases.
Dataverse AI Functions
Another option you can evaluate is the use of Dataverse AI Functions instead of the GPT prompt:
These functions are exposed as any other unbound action. You can easily run them not only from your Power Automate flow, but also in low-code plugins. While offering a bit less flexibility because you can't formulate your own custom prompt, they represent a very simple way to perform some AI actions in your solution.
Summary
This article takes you through how a low-code approach can help you enhance a typical email-to-case process with the addition of AI automation, and enhance and simplify case routing.
AI Builder offers many capabilities, and opens the opportunity to achieve interesting results when used in combination with Customer Service.
We could, for example, implement a flow recognizing customers requesting instructions to reset their credentials, and generate an automated response with a link to a KB explaining self-service procedures.
Again, we could implement a flow to detect a customer asking for the status of a shipment. The flow could extract the unique number of the shipment, call an external API to check the status, and provide an answer to the customer automatically, resolving the case without human intervention.
With the flexibility of the GPT prompts, and all the tools offered by AI Builder and Azure Open AI, you can build exciting solutions that work seamlessly in your Power Platform environment.