This guide is part of our series on “Mastering Agentforce”.
To explore the complete series, please click here.
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:
- Record Merge Fileds
- Related List Merge Fields
- Flow Merge Fields
- Apex Merge Fields
- Data Cloud DMO Merge Fields
- Record Snapshot Merge Fields
In this guide, we’ll focus on using Apex 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 Apex, 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 using Flow Merge Fields.
Where to Use Apex Merge Fields?
- Apex Merge Fields are ideal when you need to retrieve specific data based on complex logic
- When pulling data from external systems using Apex Callout
Step-by-Step Guide: Using Apex Merge Fields in Prompt Template
In this guide, we will walk through how to use Apex Merge Fields to analyze open Cases and Opportunities for an Account, focusing on how open cases may impact opportunities.
This process is simple and should take 20-30 minutes to configure and test. Here’s what the guide covers:
- Sign Up & Set Up Einstein Generative AI Trial Org
- Create Apex Classes to Get Open Cases & Opportunities
- Create Prompt Template
- Create Agent Custom Action
- Assign Custom Action to Einstein Copilot Agent
- 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.
NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.
Unlock the Power of Salesforce Generative AI: Master Agentforce!
Discover how to leverage Salesforce’s cutting-edge Generative AI tools to streamline your workflows and boost productivity.
Our comprehensive guides and hands-on workshops will take you from beginner to expert in no time. Learn the ins and outs of Agentforce, Agents, Topics, Actions and Prompt Builder with step-by-step tutorials, best practices, and real-world examples.
We also offer live onsite/online training for Salesforce partners, as well as consulting and implementation services for Salesforce customers.
Conclusion
Incorporating Apex Merge Fields into your prompt templates unlocks the potential for dynamic and precise AI-driven outputs. By leveraging the power of Apex, you can customize data inputs to align with complex business logic, ensuring the AI delivers highly relevant and actionable insights. This empowers your users with smarter automation and better decision-making capabilities.
References & Useful URLs
- Salesforce help article – Ground with Apex Merge Fields