Sunday, 16 November 2025

Grounding Prompt Templates with Apex Merge Fields

 Hi,

You can include an Apex merge field in a prompt template to surface data retrieved from a SOQL query or an external API. Apex is also useful when you need to generate structured JSON or apply programmatic data filtering.

To use Apex within Prompt Builder, create an Apex class that contains at least one method annotated with @InvocableMethod.

If needed, you can specify a CapabilityType in the annotation so it aligns with the prompt template’s type.

Example:
@InvocableMethod(CapabilityType='PromptTemplateType://einstein_gpt__salesEmail')


Prompt Template TypeCapabilityType
Sales EmailPromptTemplateType://einstein_gpt__salesEmail
Field GenerationPromptTemplateType://einstein_gpt__fieldCompletion
Record PrioritizationPromptTemplateType://einstein_gpt__recordPrioritization
Record SummaryPromptTemplateType://einstein_gpt__recordSummary


The Flex capability has been retired, so it should no longer be used in Apex classes. Salesforce recommends refactoring any Apex code that specifies CapabilityType=FlexTemplate://* to remove the FlexTemplate reference entirely. Simply delete the CapabilityType attribute, save the class, and then confirm that your prompt template still functions correctly with its Apex merge fields.

Notes:

  • Do not specify a CapabilityType for the prompt template type einstein_gpt__caseEmailDraft, used by Service Email Assistant. This template type uses Case as its input API name, so choose a different API name for the input—such as CaseObject.

  • If you change the inputs for a Flow or Apex class used as a resource in a prompt template, the template will no longer function, and you won’t be able to save new versions.


Method Input Requirements

The method’s input parameter must be a List<Request>. The Request class must define an InvocableVariable for each input required by the prompt template type. All inputs from the prompt template are passed into the invocable method, and only the first list element contains data.

When a prompt template type includes a CapabilityType, it effectively acts as an interface for the Request class. Each CapabilityType requires that the Request class include specific InvocableVariable fields.
For example, the field generation CapabilityType requires a RelatedEntity member. If the prompt template includes additional objects, the Request class must define matching InvocableVariable members using exact spelling and case sensitivity.
In this example, the prompt template specifies Account as the object being updated, so the Request class must declare a corresponding Account variable.


public class Request {
    @InvocableVariable
    public Account RelatedEntity;
}



Method Output

The method must return a List<Response>. The Response class contains a single string field named Prompt, which must be annotated with @InvocableVariable.

Adding an Apex Resource to a Prompt Template

In the Prompt Template Workspace, you can add an Apex class to a prompt template by selecting Insert Resource in the Prompt section and choosing Apex from the list.









Reference:

https://help.salesforce.com/s/articleView?id=ai.prompt_builder_ground_apex.htm&type=5

https://help.salesforce.com/s/articleView?id=ai.prompt_builder_add_apex_flex.htm&type=5

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm



Tuesday, 21 October 2025

How Agentforce Is Redefining Productivity: My Take on Employee AI Agents

Hi,  

I’ve been working on Agentforce and several related projects recently, and it’s been fascinating to see firsthand how Salesforce is shaping the next wave of workplace AI. We’ve all heard about AI tools that help with sales, marketing, and customer service — but what about AI designed to empower the people who keep everything running behind the scenes?

That’s where Agentforce for Employees really stands out. It’s like giving everyone in your organization a smart digital sidekick that helps them work faster, stay focused, and remove the repetitive parts of their day

What Exactly Is an Agent?

At its simplest, an agent is an AI-powered assistant that performs or helps with a specific task. You give it a request — something like “Summarize this account before my meeting” or “Help me file an IT ticket” — and it figures out what needs to be done.

Behind the scenes, Agentforce uses what’s called the reasoning engine, which helps each agent decide the best way to complete a request. Guardrails prevent misinformation and ensure agents operate within company data rules — so everything stays secure and accurate.

Meet Employee Agents — Digital Coworkers You’ll Actually Love

Imagine having a helpful coworker who never gets tired and always knows where to find the right information. That’s what employee agents are built to be.

They can:

  • Draft sales emails or proposals.

  • Find HR or benefits details in seconds.

  • Help onboard new hires.

  • Surface knowledge or assist with IT issues.

And they’re available right where you already work — in Salesforce, Slack, or even on your phone.

How It Works

Each employee agent comes preconfigured with actions and topics, but you can also customize them in Agentforce Builder to fit your organization’s unique needs.

They also work with role-based permissions, so data access automatically matches the employee’s level. That means a manager and an associate can use the same agent safely — each seeing only what they’re authorized to see.

Why Slack + Agentforce Is a Game-Changer

One of my favorite aspects of Agentforce is how seamlessly it integrates with Slack. You can simply @mention your agent in any channel or direct message, and it’s instantly ready to help.

Even non-CRM users can access Agentforce in Slack through Salesforce identity licenses — no extra Salesforce seat required. It’s a small detail, but one that opens up powerful automation across entire organizations.

Real Use Cases I’ve Seen and Loved

Working with Agentforce has shown me how flexible these employee agents can be. Some of the most exciting real-world examples include:

  • HR: Automating onboarding and answering benefits questions.

  • IT: Managing help desk tickets and automating incident updates.

  • Sales: Preparing executive briefings and proposals.

  • Marketing: Creating campaign content and tracking performance.

  • Engineering: Assisting with QA and sprint management.

  • Legal: Simplifying compliance and approval workflows.

Anywhere you have repetitive processes or scattered information, Agentforce can help simplify and automate.

Built on Trust and Security

Since this is Salesforce, trust is baked in. Agentforce relies on the Einstein Trust Layer, which ensures your data is secure, private, and never stored. It also monitors for toxicity and inappropriate content — so responses stay professional and safe.

That trust foundation makes it easier to experiment and scale AI without fear of compromising sensitive company information.

Getting Started with Agentforce for Employees

Employee agents use Flex Credits, Salesforce’s flexible, usage-based system. This means you can roll out Agentforce for Employees across your existing Salesforce and Slack setup. If your team already uses Agentforce for Sales or Service, this is the perfect way to extend that power internally.

Final Thoughts

After working with Agentforce on multiple projects, I’ve come to appreciate how it strikes the right balance between intelligence, security, and usability. It’s not about replacing people — it’s about helping them focus on what matters most.

AI should feel like collaboration, not automation. And with Agentforce, it really does. It brings AI into the natural flow of work, making every employee more capable, informed, and efficient.

The future of work isn’t humans vs. AI — it’s humans with AI. And Agentforce is making that future happen right now.


Reference:

https://trailhead.salesforce.com/content/learn/modules/einstein-copilot-quick-look

https://trailhead.salesforce.com/content/learn/modules/agentforce-for-employees-quick-look/get-started-with-agentforce-for-employees

https://trailhead.salesforce.com/content/learn/modules/the-einstein-trust-layer

https://trailhead.salesforce.com/content/learn/projects/connect-your-agentforce-org-with-slack

https://trailhead.salesforce.com/content/learn/modules/agentforce-configuration-for-slack-deployment





Sunday, 25 May 2025

Agentforce metadata types for deployment

 Hi,

The following are key metadata types to consider when deploying Prompt Templates, Topics, Agent Actions, and Agents in Salesforce.

<!--Agents-->

<types>

    <members>*</members>

    <name>Bot</name>

 </types>

 <types>

   <members>*</members>

    <name>GenAiPlanner</name>

  </types>

<!--Agent Actions-->

 <types>

       <members>*</members>

      <name>GenAiFunction</name>

 </types>

  <!--Agent Topic-->

  <types>

       <members>*</members>

       <name>GenAiPlugin</name>

  </types>

  <!--PromptTemplate-->

  <types>

    <members>*</members>

    <name>GenAiPromptTemplate</name>

  </types>

  <!--Messaging Channel-->

<types>

   <members>*</members>

   <name>MessagingChannel</name>

</types>

Referennce:

https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_genaifunction.htm


https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_genaifunction.htm


Sunday, 9 February 2025

Differences between Agentforce for Service and Einstein Bots

 Hi ,

There are a few differences between Agentforce for Service and Einstein Bots.

Agentforce vs. Einstein Bots

Agentforce for Service vs. Einstein Bots

Difference Agentforce for Service Einstein Bots
Setup Sets up in minutes with prebuilt topics and actions. AI agents are powered by generative AI and large language models (LLMs) to provide flexibility and conversational capabilities similar to humans. Set up requires you to manually train natural language models (NLMs) to understand customer language and design dialogs.
Maintenance Update out-of-the-box topics, actions, and instructions—or quickly create your own as service requests increase. Improve performance easily by adding and iterating on natural language instructions. Requires high maintenance to keep the dialogs and intents up to date and to train new dialogs and intents as service requests increase.
Context and Exception Handling Understands human language and responds to follow-up questions and unplanned exceptions—has context of entire conversations. Can’t understand human language and responds only to the most recent question—has no context of entire conversations.

Key Benefits of Agentforce for Service

Hi,

Key Benefits of Agentforce for Service:

Agentforce for Service offers flexible solutions to customer service challenges.


Responds 24/7: Answers questions, deflects cases, and meets service goals on channels at any time of day, whenever is convenient for your customer.

Replies naturally: Uses generative AI to craft conversational responses that understand context and match your brand’s voice.

Adds clarity: Instructs AI agents to ask questions specific to your business to gather and share more accurate information.

Handoffs to humans: Lets AI seamlessly transfer or escalate conversations to live agents who can solve more complex issues.

Deploys quickly: Sets up in minutes with service-specific templates and existing workflows. There’s no need to write dialogs, determine intents, maintain conversation trees, or train large language models (LLMs).

Grounded in trusted data: Grounds your AI agents in credible sources like your Knowledge articles, similar cases, and CRM data. All large language model (LLM) calls from Agentforce go through the Einstein Trust Layer on the Salesforce Platform, which keeps customer data safe.



Reference:

Grounding Prompt Templates with Apex Merge Fields

 Hi, You can include an Apex merge field in a prompt template to surface data retrieved from a SOQL query or an external API. Apex is also u...