
It is super important to classify cases in Salesforce. Especially when they come from Email-to-Case and we have no idea what they’re actually about. Setting the Case Type right away saves our support reps a ton of time and makes it much easier to assign the case to the right team. The good news? AI can do this for us. With Flow and Prompt Template, it’s quick and easy to set up.
Let’s see how you can classify cases using Flow and Prompt Template.
Building a Prompt Template to Classify Cases
We will start with creating a new prompt template using Prompt Builder. Prompt Builder is a tool in Salesforce that lets you work with LLMs without writing any code. With Prompt Builder, you can plug in your CRM data, Data Cloud, or even external data using merge fields and grounding. Thanks to the Einstein Trust Layer, you can do it all securely and responsibly.
Let's assume that you enabled Einstein in your Salesforce environment. Go to Prompt Builder in Setup and click New Prompt Template. Select Flex as the template type. This option gives you the freedom to shape the prompt exactly for your use case. Then, create an input variable for the Case record.

Next, enter your prompt. Make sure to include the Case fields you want the template to use when classifying the case. You can use something like this:
Your job is to categorize a Case based on its Subject and Description.
Possible Case Type values:
Technical Support,Financial Problem,Feedback,Complaint,Other
Choose exactly one value from the list. Output only the value, nothing else.
Subject: {!$Input:Case.Subject}
Description: {!$Input:Case.Description}

This prompt template will work, but we can make it better and more flexible. Right now, the possible Case Type values are hardcoded, which means if you add a new value to the Type picklist, you’ll have to update the template every time. To make it dynamic, let’s build a Template-Triggered Prompt Flow.
Template-Triggered Prompt Flow
Once you’ve created your prompt template in Prompt Builder, it can generate endless variations of personalized content based on your data. And if you want to take it a step further, you can use Flow to pull in real-time data for the prompt. To do that, you have to use a special flow type called Template-Triggered Prompt Flow.
In our example, we will build a Template-Triggered Prompt Flow that pulls the Case Type values. As you can see in this post, our goal is to get the Picklist Value Info records for the Case Type field. Since it is a standard field, we don't need to get the Entity Definition and Field Definition records first.
After creating a new flow, add a Get Records element to fetch the Picklist Value Info records of Case.Type.

Next, add a Transform element to turn those values into a text collection.

Now that you’ve got a text collection of Type values, add an Add Prompt Instructions element to send those values to your Prompt Template.

At the end, your flow should look like this.

Now that you have your flow ready, go back to your Prompt Template and replace the hardcoded Type values with the flow output.

At the end, your Prompt Template should look like this.

As you can see, our Prompt Template is working well!

Building a Record-Triggered Flow to Classify Cases
Now it’s time to automate the whole thing. We will build a record-triggered flow that calls this prompt template to classify cases.
Create a new record-triggered flow that runs when a Case record is created. Add the prompt template that we created earlier (Case Classification).

Our Prompt Template needs the Case record as an input, so make sure to provide it.

Then, update the Case Type with the output from the Prompt Template action.

In the end, the whole solution will work like this.

The best part is that nothing in this solution is hardcoded. If you add a new Type value, there’s no need to update the Prompt Template or Flows. Plus, since we’re using AI, it will work across multiple languages.
This was just a simple example of using Flows and Prompt Templates. You can take it further by enhancing your Flow and Prompt Template to set values for additional fields too. Just keep in mind that in those cases, you’ll need to parse the values from the output.
So are we using Gen AI license here?
Very nicely explained!!
Great post. Two suggestions from me:
We should consider only active pocklist values.
Also there is a need to respect their assignment to record types (which is very common for Cases).