Step-by-Step Guide to Using Flow Merge Fields in Prompt Template

To enhance the effectiveness of prompt templates in Salesforce, it's important to make them context-aware, allowing AI models to deliver better results. One way to do this is by using merge fields to pull relevant data from your Salesforce org. This gives the AI the necessary context to generate more accurate and meaningful responses.

Salesforce Prompt Builder lets you use merge fields from different sources, including:

  1. Record Merge Fileds

  2. Related List Merge Fields

  3. Flow Merge Fields

  4. Apex Merge Fields

  5. Data Cloud DMO Merge Fields

  6. Record Snapshot Merge Fields


In this guide, we’ll focus on using Flow Merge Fields in a prompt template.

Business Use Case: Proactively Managing Opportunity Risks with AI

Imagine you're a sales rep managing multiple accounts, each with its own open opportunities and ongoing cases. Keeping track of everything can be challenging. Now, what if you had an AI assistant that could analyze these cases and opportunities, flagging any risks that might affect your deals?

That’s exactly what we aim to do here. By using Flow, we can filter down to only the open cases and opportunities related to a specific account. This data is then fed into the AI, prompting it to assess whether any open cases could negatively impact ongoing opportunities.

For instance, let's say you're about to close a deal with a customer for a large order of mobile generators. But there's also a high-priority case open from the same customer regarding issues with a generator they previously purchased. This could signal a potential risk - the customer might be hesitant to make another purchase if they're not satisfied with their existing product and/or your service.

Note: For this same business use case, we have also created a #Step-by-Step Guide to Using Apex Merge Fields in Prompt Template.

Benefits for Sales Reps and the Business:

  • Proactive Risk Management: Spot potential deal-breakers early, allowing you to address concerns and increase your chances of closing deals.

  • Improved Customer Relationships: Show customers that you’re aware of their concerns, building trust and loyalty.

  • Increased Sales Efficiency: Focus on the most promising opportunities, saving time and resources.

  • Enhanced Decision-Making: Gain insights into account health, leading to more informed sales strategies and forecasts.

Where to Use Flow Merge Fields?

  1. Flow Merge Fields are ideal when you need to retrieve specific data based on filter conditions. In situations where using "Related List" merge fields would pull in too many records (creating unnecessary noise for the AI), Flow is a better option.

  2. It’s also useful for retrieving data from multiple objects based on complex logic or

  3. When pulling data from external systems using an HTTP Callout action in Flows.

Step-by-Step Guide: Using Flow Merge Fields in Prompt Template

In this guide, we will walk through how to use Flow Merge Fields to analyze open Cases and Opportunities for an Account, focusing on how open cases may impact opportunities. We will make use of Template-Triggered Prompt Flow, a new type of Flow that Salesforce has introduced specifically for this purpose.

This process is simple and should take 20-30 minutes to configure and test. Here’s what the guide covers:

  1. Sign Up & Set Up Einstein Generative AI Trial Org

  2. Create Flows to Get Open Cases & Opportunities

  3. Create Prompt Template

  4. Create Agent Custom Action

  5. Assign Custom Action to Einstein Copilot Agent

  6. Test Prompt Template with Einstein Copilot Agent


In the overall flow of Agentforce, the following diagram highlights the key components that we will cover in this guide.


Conclusion

Incorporating Flow Merge Fields into your prompt templates is a powerful way to enhance the relevance and actionability of AI-driven insights. By tailoring data inputs based on specific conditions, you improve the accuracy of the AI’s recommendations, ultimately empowering your users.


Agentforce Advisory, Training & Implementation Services

If you’d like help going deeper with Agentforce beyond this guide, I offer the following:

  • Self-Paced Training – #Mastering Agentforce

    A structured, hands-on course covering Agentforce concepts, Prompt Templates, Agents, Actions, and real-world implementation patterns.

  • Live Online & Onsite Agentforce Training

    Instructor-led training for Salesforce teams, partners, and customer organizations, tailored to real use cases and practical scenarios.

  • Agentforce Advisory & Implementation Services

    Strategic advisory and hands-on implementation support to help you design, build, and scale Agentforce solutions with confidence.

For training, advisory, or implementation discussions, please reach out via the Contact page, where you can submit a form or schedule a conversation.


References & Useful URLs



Liked something? Say something! Share your thoughts in the comments below 👇