The era of AI in CRM is here, and its name is Salesforce Copilot. It’s more than just a chatbot that answers questions; in fact, it’s an intelligent assistant designed to take action. But its true power is unlocked when you teach it to perform custom tasks specific to your business.
Ultimately, this guide will walk you through the entire process of building your very first custom Salesforce Copilot action. We’ll create a practical tool that allows a user to summarize a complex support Case and post that summary to Chatter with a single command.
Understanding the Core Concepts of Salesforce Copilot
First, What is a Copilot Action?
A Copilot Action is, in essence, a custom skill you give to your Salesforce Copilot. It connects a user’s natural language request to a specific automation built on the Salesforce platform, usually using a Salesforce Flow.

To see how this works, think of the following sequence:
1. To begin, a user gives a command like, “Summarize this case for me and share an update.”
2. Salesforce Copilot then immediately recognizes the user’s intent.
3. This recognition subsequently triggers the specific Copilot Action you built.
4. Finally, the Flow connected to that action runs all the necessary logic, such as calling Apex, getting the summary, and posting the result to Chatter.
Our Project Goal: The Automated Case Summary Action
Our goal is to build a Salesforce Copilot action that can be triggered from a Case record page. To achieve this, our action will perform three key steps:
1. It will read the details of the current Case.
2. Next, the action will use AI to generate a concise summary.
3. Lastly, it will post that summary to the Case’s Chatter feed for team visibility.
Let’s begin!
Building Your Custom Action, Step-by-Step
Step 1: The Foundation – Create an Invocable Apex Method
Although you can do a lot in Flow, complex logic is often best handled in Apex. Therefore, we’ll start by creating a simple Apex method that takes a Case ID and returns its Subject and Description, which the Flow can then call.
The CaseSummarizer Apex Class
// Apex Class: CaseSummarizer
public with sharing class CaseSummarizer {
// Invocable Method allows this to be called from a Flow
@InvocableMethod(label='Get Case Details for Summary' description='Returns the subject and description of a given Case ID.')
public static List<CaseDetails> getCaseDetails(List<Id> caseIds) {
Id caseId = caseIds[0]; // We only expect one ID
Case thisCase = [SELECT Subject, Description FROM Case WHERE Id = :caseId LIMIT 1];
// Prepare the output for the Flow
CaseDetails details = new CaseDetails();
details.caseSubject = thisCase.Subject;
details.caseDescription = thisCase.Description;
return new List<CaseDetails>{ details };
}
// A wrapper class to hold the output variables for the Flow
public class CaseDetails {
@InvocableVariable(label='Case Subject' description='The subject of the case')
public String caseSubject;
@InvocableVariable(label='Case Description' description='The description of the case')
public String caseDescription;
}
}
Step 2: The Automation Engine – Build the Salesforce Flow
After creating the Apex logic, we’ll build an Autolaunched Flow that orchestrates the entire process from start to finish.
Flow Configuration
- Go to Setup > Flows and create a new Autolaunched Flow.
- For this purpose, define an input variable:
recordId(Text, Available for Input). This, in turn, will receive the Case ID. - Add an Action element: Call the
getCaseDetailsApex method we just created, passing therecordIdas thecaseIdsinput. - Store the outputs: Store the
caseSubjectandcaseDescriptionin new variables within the Flow. - Add a “Post to Chatter” Action:
- Message: This is where we bring in AI. We’ll use a Prompt Template here soon, but for now, you can put placeholder text like
{!caseSubject}. - Target Name or ID: Set this to
{!recordId}to post on the current Case record.
- Message: This is where we bring in AI. We’ll use a Prompt Template here soon, but for now, you can put placeholder text like
- Save and activate the Flow (e.g., as “Post Case Summary to Chatter”).
Step 3: Teaching the AI with a Prompt Template
Furthermore, this step tells the LLM how to generate the summary.
Prompt Builder Setup
- Go to Setup > Prompt Builder.
- Create a new Prompt Template.
- For the prompt, write instructions for the AI. Specifically, use merge fields to bring in your Flow variables.
You are a helpful support team assistant.
Based on the following Case details, write a concise, bulleted summary to be shared with the internal team on Chatter.
Case Subject: {!caseSubject}
Case Description: {!caseDescription}
Summary:
4. Save the prompt (e.g., “Case Summary Prompt”).
Step 4: Connecting Everything with a Copilot Action
Now, this is the crucial step where we tie everything together.
Action Creation
- Go to Setup > Copilot Actions.
- Click New Action.
- Select Salesforce Flow as the action type and choose the Flow you created (“Post Case Summary to Chatter”).
- Instead of using a plain text value for the “Message” in your Post to Chatter action, select your “Case Summary Prompt” template.
- Follow the prompts to define the language and behavior. For instance, for the prompt, you can use something like: “Summarize the current case and post it to Chatter.”
- Activate the Action.
Step 5: Putting Your Copilot Action to the Test
Finally, navigate to any Case record. Open the Salesforce Copilot panel and type your command: “Summarize this case for me.”
Once you issue the command, the magic happens. Specifically, the Copilot will understand your intent, trigger the action, run the Flow, call the Apex, generate the summary using the Prompt Template, and post the final result directly to the Chatter feed on that Case.
Conclusion: The Future of CRM is Action-Oriented
In conclusion, you have successfully built a custom skill for your Salesforce Copilot. This represents a monumental shift from passive data entry to proactive, AI-driven automation. Indeed, by combining the power of Flow, Apex, and the Prompt Builder, you can create sophisticated agents that understand your business and work alongside your team to drive incredible efficiency.

Leave a Reply