Field Generation Prompt Template in Salesforce Agentforce : Bijay Kumar
by: Bijay Kumar
blow post content copied from SalesForce FAQs
click here to view original post
### Summary of Salesforce Agentforce Field Generation Prompt Template In Salesforce Agentforce, support users often need to access detailed information about object records, like accounts. Instead of sifting through numerous fields, having a summary field can provide a quick overview. The Field Generation Prompt Template is designed to create these summary fields effortlessly. **Key Points:** 1. **Purpose of the Field Generation Prompt Template:** - It allows users to generate a concise summary for Salesforce records, reducing the time spent analyzing numerous fields. 2. **What is a Prompt Template?** - A pre-built message or instruction for the AI agent that can be reused multiple times, promoting efficiency and consistency in data handling. 3. **How to Create a Field Generation Prompt Template:** - Create a custom field (e.g., "Account Summary") on the account object to store summary content. - Use the Prompt Builder in Salesforce setup to create a new prompt template by filling out essential details such as template type, name, and description. - Define the model and resources needed for the prompt, ensuring it can pull relevant account data. 4. **Dynamic Grounding:** - The template can include both static content and dynamic data based on the specific account queried, making it adaptable to various contexts. 5. **Utilizing Apex Classes:** - For complex data retrieval, an Apex class can be integrated, allowing for custom logic to fetch necessary information. 6. **Preview and Testing:** - Users can preview the generated prompt and test responses from the AI model to ensure the summaries meet their needs. ### Conclusion Understanding how to create and use field generation prompt templates in Salesforce Agentforce can significantly improve the efficiency of data retrieval and provide a streamlined experience for support users. **Additional Information:** - This capability is particularly useful for organizations that deal with large volumes of data, allowing support staff to quickly access important information without wasting time. ### Relevant Hashtags #Salesforce #Agentforce #FieldGeneration #Prompts #Apex #AI #DataManagement #SalesforceTutorial #CRM #EfficientSupport
As a support user, you have a query regarding any object record, and to resolve that query, you have to go through all the fields of that record to analyze it.
It would be better if there were a field that summarizes all the important information. By looking at that field, we can get a quick overview without reviewing all the account details.
To generate the summary of record, the Field Generation Prompt Template makes this task easier for you.
In this tutorial, we will learn about the field generation prompt template in Salesforce Agentforce.
Prompt Template in Salesforce Agentforce
A prompt template in Agentforce is like a pre-built message or instruction given to the AI agent in Agentforce. We can create this prompt template using the prompt builder in Salesforce.
Instead of writing the same message repeatedly, we can create a template once and use it many times. It helps us save time and stay consistent.
The prompt template builds a trusted generative AI that is bound to one or more objects to generate summaries or content.
To better understand, let me give you one example: The account object has multiple fields, and you need some important information about the account record. Now, it would be difficult to go through all the records, find related contacts, and open cases for that particular account.
Now, what if we had a summary field where we could get all this important information? It would save our time and efforts.
For that, we have a field generation prompt template in Salesforce Agentforce, which displays this information in the fields.
Field Generation Prompt Template in Salesforce Agentforce
A field generation template populates values in an object’s field. It can be used on a record page, which means it is bound to a specific field, such as the account summary field.
You can place your summary field on the record page and bind it to this field generation prompt template.
Then, whatever response comes from this template will be stored in that particular field. It can also be called via Einstein Copilot, action flow, REST API, and Apex.
Create Field Generation Prompt Template in Salesforce
In the following step, I will explain how to create a field generation prompt template in Salesforce Agentforce.
In the first step, to display an account’s summary, we need to create a custom field on the account object. So this field will store the content and summarize the different contacts this account has.
This will help the agent have a quick overview of the account by reviewing this field. For that reason, I have created a custom field called account summary, which is a type of long text area.

Now, let’s create the field generation prompt template:
- Click on the Gear icon and select Setup.
- In Quick Find, search for the Prompt Builder and click on it.
- This screen is very similar to our Einstein Copilot action screen.
- To create a new prompt, click the New Prompt Template button.

Now, fill in the details for the new prompt template, as I explained below:
- Prompt Template Type: We have four types of prompt templates. We are creating a Field Generation template.
- Template Name: After that, provide the name of your template as per your requirement. The API Name will be automatically populated.
- Description: Give a short intro about your prompt template.
- Object: Select the object to create this field generation template. You also need to select the Object Field.
After that, click the Next button to proceed.

Now, we need to build our prompt template. Here, we can specify which Model to use, and we should be able to see the preview.
For the prompt template, Salesforce offers various LLM Models, and we can use any one of these available LLMs.
Since we have selected the account as an object for this field generation template, you should be able to see it in the Resource option.
- Account: If we need to ground this template with account-related information, such as contacts, opportunities, and cases. We should be able to access it through the Resource option.
- Current User/Organization: Here, we can add information about the current user and the organization.

So here, since we want this template to summarize the account information, we should give our prompt like the one below, or you can provide as per your requirement.
Write a short paragraph summary of account, as well as the contact created for the account having Account name as: Input.Account.Name.
This is where we have to provide specific information about an account, which means we are grounding the customer data into the prompt template.
For that, we need the account name. Click on the Resource -> Account -> Account Name field. Again, to add more information, go to Resources -> Account -> where you will find all the account fields.
That means now this template has some static content and will have dynamic content based on which account is passed here. This way, we can ground the CRM data into the prompt, which we can call dynamic grounding.
When this prompt executes, we pass that information just before that. So, you can add more information about this account object from the resource section. If you have to get information about the current logged-in user, I can get it through resources.
Now, we require that the information we want to feed into the prompt template be available in a third-party system. Maybe the information is a little complicated, requires a SOQL query to run, or requires some custom logic to run.

Now, to process whatever prompt the agent gets for such a requirement, you can invoke apex or flow, and they can respond with whatever response they give back that will become the grounding data for this prompt template.
For that, we need to create an Apex class, or you need to have specific flows. Then, that apex class or flow will be available in a prompt template.
Apex Class For Prompt Template in Salesforce Agentforce
Below, I have created an Apex class, AccountSummaryPrompt. Just like our custom actions, if we want the Apex method to be available in the prompt template response, then that method should be annotated with the Invokable method.
Since our prompt template is for an account, the account is the related entity to that prompt template. After that, save the apex class and navigate to the prompt builder again.
public class AccountSummaryPrompt {
@InvocableMethod(label='Account Details'
description='Find Account details')
public static List<Response> getAccData(List<Request> requests) {
if (requests.size() != 1)
throw new IllegalArgumentException('The requests list must contain one entry only');
Account acc = requests[0].RelatedEntity;
List<Account> AccDetails = [SELECT Id, Name, Industry FROM Account WHERE Id = :acc.Id];
String responseData;
if (AccDetails.isEmpty()) {
responseData = 'There are no Account records.';
} else {
responseData = 'Account Details: ';
for (Account a : AccDetails) {
responseData += String.format('{0}, {1}.', new List<Object>{a.Id, a.Name});
}
}
List<Response> responses = new List<Response>();
Response res = new Response();
res.Prompt = responseData;
responses.add(res);
return responses;
}
public class Request {
@InvocableVariable(required=true)
public Account RelatedEntity;
}
public class Response {
@InvocableVariable(required=true)
public String Prompt;
}
}
Now, we need to add the apex class that we created:
For that, click the Resources -> Apex -> Select the label you provided in the apex invocable method. That Apex method will give the response in a string format that will be added here.

So, the final prompt, which already includes all this information, will be passed as a prompt to the LM model.
In the preview panel, we will see what our final prompt has been generated by actually adding this information here. In the response, we will see that by passing that prompt, what response are we getting from the LM model? So, for this one, let’s use a model like OpenAI’s GPT 4.
We have to give a related record to get that account’s name, which will also be passed to our Apex method. So, for that, let’s add our account. Let’s use sForce. You can click on Save and Preview. This is where you will see two pieces of information.

In the preview section, we see this prompt template. After grounding the information, how does it look? We were told to write a short paragraph summary of the account details. The account name is sForce.
You will see that it has grounded that information. The account name is now available here. The account details and the case details are listed below.

Conclusion
I hope you have a good understanding of prompts templates in Salesforce Agentforce. I have also explained how to create a field generation prompt template in Salesforce Agentforce.
We learned that designing an effective prompt is key to unlocking the benefits of generative AI. Also, I have explained the types of prompt templates and how to create a prompt template in Salesforce AgentForce.
You may like to read:
- Create Agentforce-Enabled Scratch Orgs From Salesforce Developer Edition
- Agentforce for Developers in Salesforce
- Build Sales Email Prompt Template in Salesforce Agentforce
The post Field Generation Prompt Template in Salesforce Agentforce appeared first on SalesForce FAQs.
April 16, 2025 at 07:12PM
Click here for more details...
=============================
The original post is available in SalesForce FAQs by Bijay Kumar
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Post a Comment