Sunday, November 16, 2025

Best Practices for writing clear instructions for your agentforcve agent

Instructions are the rules that guide how your agent behaves inside a topic. They tell the agent what steps to take, what actions to choose, and how to speak to customers. Clear instructions make the agent more dependable and help avoid confusion.

Why Instructions Are Important

Good instructions help your agent in several ways:

  • Choosing the right action: They point the agent toward the correct tool for the situation.

  • Setting the tone: They guide how the agent talks and responds.

  • Adding business context: They explain company rules, steps, and words your team uses.

If instructions are vague, the agent may pick the wrong action or misunderstand what a customer really wants. Since instructions are turned into a prompt, they are not fully predictable—so they cannot replace coded rules. They simply guide the agent’s thinking.

How the Reasoning Engine Uses Instructions

When a customer asks something, the reasoning engine uses your instructions to:

  • Pick the right step: For example, whether to look up an account or check a policy first.

  • Decide the order of actions: Instructions can say what must be done before something else.

  • Shape the reply: They help the agent format answers clearly.

  • Handle unusual cases: For example, when something doesn’t match a normal process, instructions can tell the agent to hand off to a human.

The clearer the instructions, the more reliable the agent becomes.

Good vs. Bad Instruction Examples

Bad: “Get customer details.”
Good: “If a customer asks about a warranty claim, request their full name, purchase date, or product serial number.”
Why better: It shows exactly what details are needed.

Bad: “Help fix computer problems.”
Good: “Before using the Troubleshoot Device action, confirm whether the customer is using a laptop or desktop. Include the device type when running the action.”
Why better: It sets an order and names the action to use.

Bad: “Use knowledge for product info.”
Good: “When asked about product features, identify the model number first. Then call the Knowledge Lookup action with that exact model.”
Why better: Clear steps and clear action names.

Bad: “Check if they need more help.”
Good: “After giving subscription details, ask the customer if they need help updating their plan.”
Why better: States when to follow up and what to offer.

Best Practices for Strong Instructions

  • Define important terms.
    Example: “A service code is used for repairs, while a booking code is used for appointments.”

  • Explain steps in the right order.
    Example: “First confirm the customer’s identity, then share their membership details.”

  • Use the same wording everywhere.
    Don’t switch between “client,” “user,” and “customer” unless they mean different things.

  • Be careful with words like “always” or “never.”
    Agents follow them strictly, so only use them when you mean it.

  • Match actions to situations.
    Example: “Use the Track Package action when customers ask where their shipment is.”

  • Tell the agent how to choose between options.
    Example: “If the customer has a phone number available, use SMS Verification; otherwise, use Email Verification.”

Best Practices for Building Strong Topics in Agentforce

Topics tell your agent what it should handle. Each topic has three parts: a name, a classification description, and a scope. Clear topics help your agent stay accurate and consistent.

1. Topic Name

A topic name should quickly explain the task.

Bad: “Support”
Good: “Track Delivery Issue”
Why: The good name shows the exact job.

Bad: “Account Stuff”
Good: “Update Contact Details”
Why: It focuses on a specific action.

Tips

  • Use short, action-based names (fix, update, provide).

  • Avoid names that sound alike.

  • Check for duplicates.

  • Keep topic count small—around 10–15.

2. Topic Classification Description

This explains what kinds of messages should trigger the topic.

Bad: “Fix delivery problems.”
Good: “Help customers report late packages, missing items, or delivery tracking errors.”
Why: More precise.

Bad: “Handle billing questions.”
Good: “Assist users with viewing bills, downloading invoices, or checking recent charges.”
Why: Covers real request types.

Tips

  • Include common phrases customers use.

  • Use simple language.

  • Make it clearly different from other topics.

3. Topic Scope

Scope sets boundaries: what the agent can and cannot do.

Bad: “Solve delivery issues.”
Good: “Your job is to explain delivery status and help file delivery complaints. You cannot change addresses or resend items.”
Why: Clear limits.

Bad: “Help with billing.”
Good: “You can explain recent charges and show where to find invoices. You cannot update payment methods or issue refunds.”
Why: Avoids overstepping.

Tips

  • Write it like instructions for a new employee.

  • Use “Your job is to…” and “You cannot…”

  • Keep it direct and unambiguous.

Prompt Templates vs. Agents: What’s the Difference?

On the Agentforce 360 Platform, you can use two main AI tools: prompt templates and agents. They both help you build smart features, but they work in different ways.

Prompt Templates

Prompt templates are one-time instructions you give to an AI model. They create a single response, do not remember past messages, and do not make decisions. All prompt templates go through Salesforce’s trust layer, so they protect sensitive information and follow permission rules.

Use a prompt template when the task is simple, such as:

  • Summarizing customer notes

  • Creating a short email

  • Checking the tone of a message

  • Suggesting a quick next step

They work best when no ongoing memory or multi-step actions are needed.

Agents

Agents can think through several steps, choose actions, and react to new information. They can call APIs, look up records, and change course when needed.

Use an agent when the task is complex, such as:

  • Routing support requests

  • Handling return or booking workflows

  • Troubleshooting issues across different systems

  • Scheduling based on available time slots

Agents are ideal when decisions or multi-step reasoning are required.

Saturday, November 15, 2025

Understanding Agentforce: Choosing the Right Custom Action

 When building an agent in Agentforce, you can use many different actions to help your system think, find information, and complete tasks. Each action has its own purpose, level of skill needed, and licensing requirements. In this article, we will walk through each option in clear, simple language so you can decide what fits your project best.

1. Prompt Template

What it does:

A prompt template lets the agent ask a large language model (LLM) for an answer. This is one of the ways an agent can use Retrieval-Augmented Generation (RAG).

When to use:

When the agent needs to create or rewrite text

When you want the LLM to reason or answer based on instructions or retrieved details

Skill level: Low-code

Extra license needed? Yes

2. Flow

What it does:

Flow actions let your agent run low-code, rule-based steps. It can also look up records from Salesforce automatically.

When to use:

When you want simple automation

When you need to follow business rules

When pulling data stored in Salesforce

Skill level: Low-code

Extra license needed? No

3. Apex Code

What it does:

Apex code actions use pro-code logic.


This is the best option for complex rules or custom record operations.

When to use:

When low-code tools are not enough

When you need detailed control or special logic

Skill level: Pro-code

Extra license needed? No

4. MuleSoft API

What it does:

MuleSoft API actions connect your agent to older systems or complicated applications inside a large company.

When to use:

When data lives outside Salesforce

When your environment has many legacy systems

Skill level: Pro-code

Extra license needed? Yes

5. External Service

What it does:

This option connects to REST APIs that follow OpenAPI standards.

When to use:

When you want to pull information from a modern REST API

When you need a quick, low-code integration

Skill level: Low-code

Extra license needed? Yes

6. Predictive Model

What it does:

A predictive model lets your agent use AI to forecast or score information.

When to use:

When you want the agent to make predictions

When scoring or classification is useful

Skill level: Low-code

Extra license needed? Yes

Sunday, October 12, 2025

Automating Account & Contact Creation using Agentforce Agent And Using Apex As An Action

Use Case Overview:

Let’s say a customer initiates a chat or call, and the agent (or bot) collects basic details like company name, contact name, and email. Instead of manually creating records or building complex Flow logic, you can invoke a single Apex method from the Agentforce Topic to:

  • Check if the Account already exists

  • Create the Account if needed

  • Create a related Contact

  • Return success or error messages to the agent or bot

Pre-requisite:

Turn On Einstein Setup
Enable Einstein for Sales
Assign below Permission Sets to your user

Prompt Template Manager – for users who create and manage templates

Prompt Template User – for users who run the templates




Let's create a Agentforce Agent now.

Automating Account & Contact Creation using Agentforce Agent And Using Apex As An Action

In next step, un select all selected topics.

Automating Account & Contact Creation using Agentforce Agent And Using Apex As An Action


Automating Account & Contact Creation using Agentforce Agent And Using Apex As An Action

We are not specifying any data source. Click create.

Create a Topic in next step as shown below along with Instructions properly specified and attached an apex action to the Topic.

Name: AccountContactCreationTopic

Classic Description: The AccountContactCreationTopic facilitates real-time creation of Account and Contact records in Salesforce by invoking the AccountContactCreator Apex class.

Scope: Your job is to create Account Contact only

Instructions:

Instruction 1:

Select this topic when the user says or implies any of the following:

“I want to create an account and contact”

“Add a new company and person”

“Register a new customer”

“Create contact for this account”

“Set up a new business record”

This topic should be triggered by bot intent, agent selection, or guided flow when the goal is to create both an Account and a related Contact in Salesforce.

Instruction 2:

Below variables must be collected before invoking the Apex class:

Variable Name Required Description Validation Tip
accountName Yes Name of the Account (company/org) Must not be blank
contactFirstName Yes First name of the Contact Must not be blank
contactLastName Yes Last name of the Contact Must not be blank

Instruction 3:

Optional variables (recommended if available):

Variable Name Required Description
accountPhone No Phone number of the Account
accountWebsite No Website of the Account
contactEmail No Email address of the Contact
contactPhone No Phone number of the Contact

Instruction 4:

Call the action AccountContactCreator for creating account and contact

Instruction 5:

Once the action is successfully executed display the message The Account and Contact have been created successfully. Account ID: {accountId}  andContact ID: {contactId}

Automating Account & Contact Creation using Agentforce Agent And Using Apex As An Action

Action associated to a Topic:


Agentforce Service Agent
Agentforce Service Agent

Agentforce Service Agent
Agentforce Service Agent

Agentforce Service Agent


Apex Class:

public class AccountContactCreator {

    public class AccountContactInput {
        @InvocableVariable(required=true)
        public String accountName;

        @InvocableVariable
        public String accountPhone;

        @InvocableVariable
        public String accountWebsite;

        @InvocableVariable(required=true)
        public String contactFirstName;

        @InvocableVariable(required=true)
        public String contactLastName;

        @InvocableVariable
        public String contactEmail;

        @InvocableVariable
        public String contactPhone;
    }

    public class AccountContactOutput {
        @InvocableVariable
        public String resultMessage;

        @InvocableVariable
        public Id accountId;

        @InvocableVariable
        public Id contactId;
    }

    @InvocableMethod(label='Create Account and Contact' description='Creates Account and associated Contact records')
    public static List<AccountContactOutput> createAccountContact(List<AccountContactInput> inputList) {
        List<AccountContactOutput> results = new List<AccountContactOutput>();

        for (AccountContactInput input : inputList) {
            AccountContactOutput output = new AccountContactOutput();

            try {
                // Check if Account already exists
                List<Account> existingAccount = [SELECT Id FROM Account WHERE Name = :input.accountName LIMIT 1];

                Account account;
                if (existingAccount.size() > 0) {
                    account = existingAccount[0];
                } else {
                    account = new Account(
                        Name = input.accountName,
                        Phone = input.accountPhone,
                        Website = input.accountWebsite
                    );
                    insert account;
                }

                Contact contact = new Contact(
                    FirstName = input.contactFirstName,
                    LastName = input.contactLastName,
                    Email = input.contactEmail,
                    Phone = input.contactPhone,
                    AccountId = account.Id
                );
                insert contact;

                output.resultMessage = 'Account and Contact created successfully.';
                output.accountId = account.Id;
                output.contactId = contact.Id;

            } catch (Exception ex) {
                output.resultMessage = 'Error creating Account/Contact: ' + ex.getMessage();
            }

            results.add(output);
        }

        return results;
    }
}


Now, it is time to Test. Before testing make sure you create a permission set and enable access to Apex Class created above and asssign it to agent associated to your service agent.

Agentforce Service Agent