Mastering Salesforce Prompt Builder: Tips and best practices

Mastering Salesforce Prompt Builder: Tips and best practices

Holly Bracewell on

Share with



AI solutions are in high demand across software development — and the Salesforce ecosystem is no different. With Salesforce investing so heavily in generative and agentic AI, teams are keen to leverage these new tools but often don’t know where to start or how to make AI work for them.

This post will be looking at Salesforce Prompt Builder, outlining what prompts are, how to create one, and prompt engineering best practices.

What is a prompt?

Prompts are questions or examples that you input into a Large Language Model (LLM) to give guidelines for how AI should respond, helping it create more relevant, high quality, and consistent outputs for users.

In Salesforce, prompts can be written to use relevant data from across the business through merge fields, so AI functions in your orgs can deliver dynamic outputs tailored specifically to your business context. For example, prompts can support your sales teams by generating personalized emails or summarising key account or opportunity details.

An introduction to Prompt Builder

While prompts are a valuable way to help your users and customers get more tailored and specific outcomes from AI, they can be difficult to engineer. Without the right structure, prompts can give vague, inconsistent, or even incorrect outputs — especially when they’re not grounded in real business data. Effective prompts need to give details on tone, formatting, and safety, which can be hard to get right without clear examples or testing tools. Prompt Builder is designed to make that process easier.

What is Prompt Builder?

To streamline the process of creating and managing prompts, Salesforce introduced Prompt Builder as a native prompt engineering solution — allowing you to build AI prompts declaratively and with natural language instructions, making it an accessible way to leverage AI without code.

Although Prompt Builder and Agent Builder are separate, the prompts written in Prompt Builder can also be invoked by agents to augment their actions with generative AI capabilities, helping them make context-aware decisions.

How to enable Prompt Builder

There are three steps you need to follow to set up and use Prompt Builder in your orgs:

  • Enable Einstein by going to Setup > Einstein Setup > toggle on Turn on Einstein
  • Enable Copilot through Setup > Einstein Copilots > toggle on Einstein Copilot for Salesforce
  • Assign the necessary Copilot permissions Einstein Copilot for Salesforce Admin and Einstein Copilot for Salesforce User

Once you’ve completed these steps, you’ll need to refresh your browser window before Prompt Builder becomes visible.

Enable Einstein in Salesforce to start using Prompt Builder

How to create a prompt in Prompt Builder

With Prompt Builder enabled in your org, you’re ready to start writing prompts. Navigate to Setup then search for Prompt Builder to get started.

Step 1. Configure the prompt details

To start writing a new prompt, you need to complete the New Prompt Template details which include selecting a prompt type. There are a number of different prompt types available in Salesforce that relate to specific use cases:

  • Sales email. Drafts personalized emails for outreach or follow-up based on the customer’s data.
  • Field generation. Uses record context to autofill specific fields on a record page.
  • Record summary. Creates structured summaries of record pages to help users get up to speed quickly.
  • Knowledge answers. Provides answers to user queries based on Salesforce Knowledge articles.
  • Flex templates. A flex prompt template can generate content for use cases that aren’t covered by the other prompt types.

You also need to give the prompt template a name, as well as an API name that acts as an unique identifier, and select the object the prompt relates to.

Fill out the details for the new prompt template

Step 2. Fill out the prompt template

In the prompt template workspace, write a prompt in natural language that clearly and concisely describes the task you want AI to perform. We’ll look at prompt engineering and best practices below, to help you hit the ground running with effective prompt writing.

You can also include CRM data that AI should draw on when completing the task, known as merge fields. Grounding the prompt in your Salesforce and Data Cloud data is key to getting the most relevant, personalized responses from your prompts.

Prompts are protected by the Einstein Trust Layer, so you can be confident your customer’s sensitive data is secure.

Write your prompt in the template workspace

Step 3. Test the prompt output

To check that your prompt generates the output you expect, you can preview an example in the prompt builder preview. Simply select a record and preview language to see an example of how the prompt will work when live.

If the preview output isn’t quite what you’re looking for, you can continue to iterate on your prompt and re-test until you’re confident it will generate the expected content for users.

Check the output of your prompt and edit if needed

Step 4. Activate your prompt

When you’re happy with the prompt you can activate and embed it in your workflows and agent actions.

Activate your prompt to set it live in your org

Effective prompt engineering for Salesforce Prompt Builder

Getting the most from your prompt isn’t always straightforward. Let’s look at common prompt engineering techniques that help guide the writing process.

Role-task-format prompt engineering

Role-task-format is the prompt format you’ll see recommended in Prompt Builder. This involves telling AI who it should act like (the role), what it should do (the task), and how the response should be structured (the format). By approaching prompt writing in this way, it sets clear intent and expectations for the output, making the responses more predictable and effective.

Depending on the type of action you’re prompting, there are additional techniques you can use within the role-task-format framework that help make the prompt more effective and fit for purpose.

  • Few-shot prompting. When creating prompts to produce written output, including a number of input-output examples in the ‘format’ section of the prompt helps ensure accurate responses that align with your expected tone, length, and other criteria.
  • Chain-of-thought prompting. If the task you’re asking the LLM to carry out involves multi-step reasoning, there’s a greater chance that the output will veer off track through the different stages of reasoning. With chain-of-thought prompting you guide the model through step-by-step logic that needs to be taken at each stage of the ‘task’, helping to deliver more accurate outcomes. It also increases transparency of AI decision making by highlighting how the model reached the given output.
  • Reason-and-acting prompting. If the prompt involves a task that needs to be context-specific rather than generic (such as prioritization tasks), reason-and-acting prompting can help AI make the right decision. This approach separates out analysis (reasoning) and the specific action/output (acting) into separate instructions within the prompt, to ensure that AI assesses the relevant data before carrying out a task.

By following the role-task-format approach, and including other prompt engineering techniques where relevant, you can help ensure you’re using GenAI to deliver valuable outputs to your end users.

Prompt engineering best practices

While these engineering techniques lay a solid foundation for effective prompt writing, they don’t cover all the elements of a successful prompt. Here are some key considerations to keep in mind when writing Salesforce prompts:

  • Define a clear objective for the prompt. Prompts shouldn’t be created for the sake of using AI — each prompt should be aimed at delivering value to end users through achieving specific goals. Having a clear idea of what you’d like the prompt to deliver will help you design a clearer, more focused prompt. It also makes it easier to identify the relevant KPIs to measure whether a prompt is achieving its intended outcome.
  • Measure performance and iterate. Prompts shouldn’t be “set and forget”. By regularly measuring how your prompts are performing, you can iterate and improve them over time to make sure they’re still fit for purpose and delivering value to users. While Agentforce Analytics doesn’t directly analyse prompt success (such as quality of output, or hallucination detection), it can be used to get proximate measures of prompt performance such as usage, acceptance of AI-generated content, or impact KPIs such as the average handle time of support cases. Without regularly reviewing and improving your prompts, they can quickly become outdated and defunct.
  • Include guardrails. Including clear instructions in your prompt helps set guardrails and avoid hallucinations that make the output inaccurate. By following the prompt engineering techniques covered above, you’ll most likely have included instructional, contextual, and structural guardrails in your prompt. But it’s easy to overlook instructions for what the model should do when there’s not enough context. This is a common cause of hallucinations or false assumptions. Including guardrails on what to do when the necessary context isn’t available (which could be as simple as ‘select the unknown option’) helps avoid this.
  • Establish internal processes for AI. Planning for scalability is key to avoid bottlenecks or dropping prompt quality as your organization and demand for prompts grows. Defining a clear AI strategy that includes how to write and manage prompt templates ensures consistency in prompt creation — delivering better user experiences without slowing the team down.

Delivering Salesforce AI securely with DevOps

Prompts are a powerful way to boost efficiency by tailoring generative AI to your business — but they’re only one piece of what’s possible with Agentforce. Learn more in the comprehensive guide to Salesforce Agentforce and find out how to build agents and deliver them successfully with DevOps.

Try all of Gearset for free