How to Build AI Agent with Salesforce? Step-by-Step Guide [2024]
servicenow-stripe-image

 Meet Us at

World Forum NYC 2024

07th November, Thursday  |

9:00 a.m.–5:00 p.m. ET

servicenow-stripe-image

Meet Us At

WorldForum

Explore the Latest Business Insights

Uncover the Keys to Success with Popular CRM Trends, New Releases and AI Launches and More!

Download E-Guide

Register to read the complete guide as PDF on your email.

Download Customer Success Story

Register to read the complete solution and benefits of this Customer Success Story as a PDF on your email.

Download Case Study

Register to read the complete solution and benefits of this Case Study as a PDF on your email.

How to Build an AI Agent With Agentforce?

October 25, 2024 eye-glyph 12

Table of Contents

    The AI revolution has already picked up pace, and it has transformed from predictive AI to generative AI. From forecasting the future based on data to helping users define the next best action to understand and create human-like content and make lives easy, AI has come a long way.

    Now, there has been another breakthrough in this with the third wave of AI revolution through autonomous AI agents or Agentic AI. This revolution is led by Salesforce recently in Dreamforce 2024 with the launch of AI Agents by Agentforce. These AI agents are assistive as well as autonomous systems equipped with the well-processed knowledge and experience of a human-level agent.

    These agents not only recommend action but also have the ability to reason and address multiple queries at once without needing human assistance at every step.

    But the real question is: How do you build an AI agent? Is there a process to create one? What are these agents made up of, and are they even secure? Let’s find it out all at once.

    Different levels of autonomy

    Agentforce Different Level of Autonomy Light Img Agentforce Different Level of Autonomy Dark ImgAgents can have different levels of autonomy:

    1. Assistive Agents

    Assistive agents, also termed copilots, are assistants to humans. Such agents support human ability through human input and feedback that makes the surrounding environment cooperative.

    2. Autonomous Agents

    Contrastingly, autonomous agents are able to work without the constant need for human supervision. However, this category does not group the Agentforce Agents together; they can push tasks back to humans when needed, with a balance between giving autonomy and human influence.

    3. Guardrails

    Both assistive and autonomous agents require guardrails. Guardrails ensure:

    • Prevention of Harmful Content: Avoidance of hallucinations, toxicity, and all other negative outputs.  By establishing these measures, organizations can maximize benefits with both types of agents while minimizing risks.

    Agentforce Agents implement a holistic approach to the presence of proper control guardrails in operational capabilities from multiple layers of security and functionality.

    4. Einstein Trust Layer

    The Einstein Trust Layer enables agents to work with LLMs inside a secure environment so that company data is secured. This layer comprises a range of control mechanisms such as a secure gateway, data masking, toxicity detection, and audit trails to monitor and control interactions with LLMs to keep sensitive information protected.

    5. Instructions

    Natural Language guidelines may also be specified for an Agentforce Agent to clarify what rules will guide it. This includes actions the agent needs to carry out and actions to avoid. Such guidelines define the behavioral space of the agent, indicating what is expected of it in terms of limits to behavior.

    6. Shared Metadata

    Salesforce’s metadata framework enforces high-level rules in agents and traditional applications. In addition to permissions, sharing models, validation rules, and workflow automation, the emphasis is on safeguarding data and business practices.

    Agent Analytics is the observability facility that helps an organization understand its ability to perform, use, and make its agents reliable. Organizations have been able to identify aspects that need improvement, hence improving agent functionality.

    7. AI Test Center

    The AI Test Center offers a standardized test framework for agents. It allows batch testing of various functionalities, such as prompt templates and retrieval-augmented generation (RAG), to ensure that the model’s application use cases are exhaustively checked.

    The same components that provide the test center also guarantee the efficient working of its agents within strict security protocols and more operational guidelines.

    A Transformative Software Paradigm

    The impact of the emergence of agents is a significant shift in the software landscape. It brings the sophisticated language and reasoning capabilities of LLMs closer to business applications’ practical demands. This evolves into better access to private data and streamlined action execution, leading to a revolutionary approach to software development. Transformative Software Paradigm Light Img Transformative Software Paradigm Dark Img

    Modular Software Development

    In this new paradigm, software is no longer composed of massive monolithic applications. Instead, it is composed of granular components called actions. These actions encapsulate specific functionalities—e.g., Locating an Order or Changing Order Address—and are organized into broader categories called topics, like Order Management.

    Agents’ Role

    An agent is a dynamic software system that makes use of the linguistic and reasoning capabilities of LLMs to orchestrate a sequence of actions in a specified domain. How an agent works can be divided into three stages:

    • Understand the Task: The agent uses the LLM’s potential to develop a deep understanding of the task it is required to do.
    • Iterative Planning and Acting: With such understanding, the agent calculates what could be done and then selects the optimal set of subsequent actions. This may involve actually performing those actions or perhaps requesting clarification for further questions. The agent proceeds through this iterative cycle until it feels that it has appropriately responded to the initiating query.
    • Response Construction: Last, the agent builds a response from its understanding and actions undertaken.

    Application Composition 

    Another very innovative feature of this paradigm is that agents can respond to unexpected requests without predefined criteria. Now, imagine an agent whose actions are in many numbers; it can assemble combinations of those in practically untold ways—in some cases, even unanticipatedly. In this sense, an agent thus faces new problems while arriving at solutions and forms the extent of application composition.

    For instance, this product line has Salesforce’s Sales Cloud, Service Cloud, Marketing Cloud, and much more break down into these fine-grained actions. This makes it possible for Salesforce’s Agentforce Agents to tap into a deep-set wealth of capabilities across different subjects. This makes actions flow together fluidly to deliver users an integrated experience across business functions.

    Customization and Security

    Developers can then extend Agentforce Agents with customized actions built with code, APIs, or templates from prompts, opening up organization-specific use cases.

    Security is also a most imperative consideration. The Einstein Trust Layer provides assurances that Salesforce data is protected and cannot be accessed by third-party AI providers, so their LLMs can be safely used without compromising sensitive information.

    Actions In Agentforce

    Actions empower agents with the following essential capabilities:

    • Access to private company data: Actions provide agents with access to your customer and enterprise data. When giving any agent access to data, it’s important to ensure that the agent doesn’t disclose data to unauthorized users. Using Agentforce Agents, access to data is governed by permissions and sharing models. The same permissions and sharing models apply regardless of where the data is accessed from: traditional applications or agents.
    • Ability to take action: Actions enable agents to execute logic and integrate with external systems. Standard Agentforce actions have that ability built-in: They can act on sales, service, marketing, commerce, and industries. In addition, developers can build custom actions that can act on Salesforce or external systems using code, APIs, flows, and prompt templates.

    Build & Customize AI Agents For Agentforce

    Salesforce Agentforce integrates human capabilities with autonomous agents powered by artificial intelligence (AI), data, and actionable insights. It offers essential features and tools for creating, customizing, and deploying reliable agents and other innovative AI applications, all while maintaining the necessary guardrails and supervision. Below is an overview of the key components.

    Metadata

    Salesforce metadata establishes universal rules that apply universally, regardless of whether data is accessed through traditional applications or agents. This includes:

    • Permissions: Controls who can access specific datasets.
    • Sharing Models: Defines how data is shared across users.
    • Validation Rules: Ensures data integrity by enforcing particular criteria.
    • Workflow Automation: Streamlines processes to enhance efficiency.

    Metadata enhances the understanding of context and meaning within data, leading to more accurate AI responses. For instance, it allows large language models (LLMs) to present customer relationship management (CRM) data in a more actionable format.

    Data Cloud

    High-quality, unified data is crucial for effective AI. Salesforce Data Cloud consolidates all your data—both Salesforce and external sources, structured and unstructured—providing a foundation for AI with relevant and actionable information. Key features include:

    • 200+ Connectors: Facilitates seamless integration with various data sources.
    • Custom Connectors: Allows for the creation of tailored connections.

    Once data is unified, Data Cloud enables its activation at scale across AI agents, analytics, and applications, delivering valuable insights and personalized experiences. This eliminates siloed experiences that arise from fragmented data.

    Models

    Agentforce features a configurable model architecture that allows easy integration and composition of models. Users can leverage:

    • Hosted Foundation Models: Quick access to AI innovation.
    • Fine-tuned Models: Custom models tailored to specific needs.
    • User-defined Models: Built using proprietary data.

    Einstein Trust Layer

    The Einstein Trust Layer ensures secure usage of existing models without compromising company data through several mechanisms:

    • Secure Gateway: Enforces consistent security policies across model providers.
    • Data Masking and Compliance: Anonymizes personally identifiable information (PII) before sending requests to model providers.
    • Zero Retention Policy: Ensures that model providers do not retain or train on Salesforce data.
    • Post-processing Steps: Includes demasking real data, detecting toxicity in outputs, and maintaining an audit trail for transparency.

    Actions

    Actions empower agents to execute logic and integrate with external systems. Standard actions can address areas such as sales, service, marketing, commerce, and industry-specific tasks. Additionally, developers can create custom actions using:

    • Custom Code
    • APIs
    • Flows
    • Prompt Templates.

    Topics

    A topic organizes actions into logical groups representing specific areas of focus for agents. Examples include:

    • Order Management
    • Warranty
    • Pricing
    • Frequently Asked Questions (FAQ)

    Tooling

    Agentforce offers low-code tools for building agents and AI applications:

    • Prompt Builder: Enables the creation of reusable prompt templates in a graphical environment using dynamic data from various sources.
    • Agent Builder: A visual tool for configuring agents and copilots where users can select available actions and test their agents in a sandbox environment.

    Now, with all the essential components on the side, let’s start building your first AI Agent with Agentforce.

    How to build and implement an AI Agent with Agentforce? 

    Follow the steps to get start ed with Agentforce:

    1. Salesforce Org Requirement

    Requirements: Enterprise, Performance, and Unlimited Editions with Einstein for Sales, Einstein for Service, or Einstein Platform add-ons. (Currently, we are using Salesforce Agentforce Playground provided by Salesforce)

    2. Enable Einstein

    a) Setup -> Einstein -> Einstein Generative AI -> Einstein Setup b) Click the “Turn on Einstein” toggle, and make sure Einstein is On.

    Turn on Einstein Img

    3. Enable Einstein Bots

    a) Setup -> Einstein -> Einstein Platform -> Einstein Bots b) Click the “Einstein Bot” toggle, and make sure it is On.

    Enable Einstein Bots Img

     

    4. Enable Einstein Copilot for Salesforce

    a) Setup -> Einstein -> Einstein Generative AI -> Agent Studio -> Agents b) Click the “Einstein Copilot for Salesforce” toggle, and make sure it is On.

    Note: Einstein copilot is used inside Salesforce as it also works as an agent.

    Enable Einstein Copilot for Salesforce Img

    5. Create a New Agent

    a) Setup -> Einstein -> Einstein Generative AI -> Agent Studio -> Agents. b) Click New Agent to create a new Agent. c) Give the name to an agent in a Label like “Order Support Agent.” d) Provide the description (Purpose) of the agent. e) The Agent User Can be a Basic Agent User or a Custom Agent User.

    Note: We can assign a Custom User if our Agent requires additional permissions.

    Create an Agent Img

    f) Set Tone as “Casual” g) Click Create h) Our Agent is created Successfully.

    6. Agent Builder

    Agent Builder is a tool for configuring our agent according to our use case based on Industry or functionality

    Agent Builder Tool Img

    We can also test our agents in Agent Builder itself. Agent Builder consists of four sections: a) Agent Topics (Topics define the range of jobs your agents and copilot can handle). b) Agent Actions (Actions are the tools they can use to get the jobs done). c) Language Settings (The language in which the Agent can communicate). d) (The logs of each conversation are stored here).

    7. Create Agent Topic:

    a) Click the down arrow and select a new topic.

    Create Agent Topic Img

    b) Provide a Label or name to the topic. c) Classification Description: The agent will use this description to determine when to use a topic in a conversation. d) Scope: A specific job description for a topic. e) Instructions: (Just like we give instructions to ChatGPT) Instructions help a copilot make decisions about how to use the actions in a topic for different use cases.

    (We can add more instructions to be more specific).

    Create a Topic More Specifically Img

    f) Click Next g) Topic is Created Successfully. [For example: The below image gives an overall idea of these fields]

    [For Further Support: Agent Topics]

    8. Create Agent Actions

    a) Setup -> Einstein -> Einstein Generative AI -> Agent Studio -> Agent Actions b) Click New Agent Action.

    Create Agent Actions Img

    c) Select Reference Action Type: We can create an Agent Action based on Flow, Apex, or Prompt Template. d) Select Reference Action: We can select the flow or apex class (Invocable) or Prompt template that we have created. [Note: We can create Apex Class, Flow, or Prompt Templates according to our requirements] [Note: The Flow needs to be Autolaunched Flow, and The Apex method should be Invocable in order to be visible]. e)  Set Action Label and API name. f) Click Next.

    Add Agent Actions

    g) Agent Action Instructions: Describe what your action does and when to use it in a conversation. h) Provide instructions for various input and output variables. i) For inputs, check “Require input” if the input is required for the (Flow, Apex, or Prompt template) to work. j) For Inputs, check “Collect data from user” if the input needs to be provided by the customer or end user. k) For Outputs, check “Show in conversation” if the output needs to be displayed to the end-user or customer.

    [Note: At least one output needed to be “show in conversation”].

    l) For Outputs, check “Filter from agent action.” If you create an agent action, all inputs and outputs from the reference action are added to it. Enable this setting when you don’t want to use a parameter from the reference action with your agent action. At least one output must be used with the action. j) Finish

    [For Further Support: Agent Actions].

    9. Add Action to Topics

    a) Go to Agent Builder (Setup -> Einstein -> Einstein Generative AI -> Agent Studio -> Agents -> Agent DropDown -> Open in builder).

    Add Action to Topics Img

    b) Click the topic in which you want to add action. c) Click the Topic’s Action Subtab.

    Click the Topic Action Tab Img

    d) Click the Add Action Icon as shown above

    Click the Add Action Icon as shown above

    e) Select the custom action that you want to add f) Click Finish g) Now, we need to add new instructions to the topic so that the Agent can use the custom build actions.

    For Example, when a customer requests to book an experience, first locate a Session__c record that corresponds to the desired date and Experience__c they wish to book. Then, use the “Create Experience Session Booking” action to complete the booking, ensuring that you pass the Session__c Id, not the Experience__c Id.

    h) Click Save.

    10. Test our Agent

    a) Open Agent Builder. b) Click Refresh (circular arrow) in the top right corner of the Conversation Preview. c) Now, we can test our agent by giving different prompts. d) You may tweak the instructions until you are getting the correct results. e) After testing, Activate the Agen

    Test our agent by giving different prompts

    11. Deploy Agent to Channel (Experience Site)

    Now, you can align agent with your preferred channel and get started.

    Best Practices For Building AI Agents with Agentforce

    Creating effective AI agents using Agentforce involves following some key best practices. Here’s a some straight from the experts:

    1. Use Flows for Actions Instead of Apex

    Build your actions using flows rather than complex Apex code. This approach helps keep each flow focused on a single action, reducing confusion for the agent when responding to queries. Flows are easier to manage and modify, making them ideal for straightforward tasks.

    2. Leverage Existing Actions

    Instead of starting every action from scratch, explore the extensive library of pre-built actions available on AppExchange. Analyzing and configuring these out-of-the-box solutions can save time and enhance your bot’s functionality without reinventing the wheel.

    3. Limit Agent Capabilities

    When designing your agent, ensure it has only the necessary capabilities to perform its tasks. Providing too many options can lead to confusion during interactions with users. Focus on specific actions that align with the agent’s purpose to maintain clarity and efficiency.

    4. Ensure Compliance with Regulations

    While Agentforce is designed with security in mind, it’s crucial to adhere to compliance regulations like HIPAA or GDPR. Avoid requesting sensitive information unless necessary and ensure that any data shared is done securely. This helps protect customer information and maintains trust.

    5. Employ Guardrails To Stay Compliant

    To ensure that AI agents remain aligned with their intended roles and responsibilities, it is essential to employ guardrails. These guardrails serve as operational boundaries that guide the AI’s behaviour and decision-making processes. By clearly defining the scope of the AI agent’s functions, organizations can prevent deviations that may lead to unintended consequences or ethical dilemmas.

    Also, Guardrails allows you to define what AI can do and what it can’t and how to respond in certain situations where it is asked something it can’t do and how to give response in a proper format for some critical information like bullets or be humble etc.

    6. Conduct Regular Audits

    Regular audits are key to making sure AI agents produce outputs that meet business standards and comply with regulatory requirements. These audits should cover a few important areas: checking performance, ensuring compliance, and keeping an eye on things continuously. For performance checks, you’ll want to see how accurate and efficient the AI’s outputs are compared to what you expect. Compliance checks help make sure everything aligns with regulations like GDPR or any industry-specific rules, catching any biases or mistakes in decision-making. By setting up ongoing monitoring, you can keep tabs on the AI’s performance and data quality, catching any issues early on. By weaving these auditing practices into your AI development and implementation process, you can boost accountability, transparency, and trust in your AI systems.

    While working with AI or related innovations, businesses are concerned about data accuracy, integrity, transferring correct information from authorized users across channels, and so on. To navigate these complexities successfully, partnering with a knowledgeable team that offers Salesforce Implementation Services is crucial. Such services provide a holistic approach to optimizing your Salesforce platform, including tailored solutions for data management, system integration, and user training. Build Your Own AI Agent With Salesforce, Contact Us CTA! Build Your Own AI Agent With Salesforce, Contact Us!

    The Final Note

    Building your first AI agent with Agentforce can transform how your business used to connect with customers. Companies like Fisher & Paykel have successfully unified their data, allowing for personalized content delivery and improved sales strategies using Agentforce AI Agents. During the pilot phase, users highlighted how structured prompts within Agentforce enhanced customer interactions by providing tailored suggestions and timely discounts.

    Cyntexa is here to help businesses seamlessly start using AI agents. With our expertise, you can easily customize and deploy your AI agent to meet your specific needs. Whether you’re enhancing customer service or streamlining operations, we ensure that your transition into the AI-driven world is smooth and effective.

     

    Frequently Asked Questions

    Yes, Agentforce is designed as a low-code platform, making it accessible for users without extensive coding skills. It allows you to build and customize AI agents using intuitive tools like the Agent Builder, enabling quick setup and modifications through simple drag-and-drop features and natural language instructions.

    Absolutely! Cyntexa specializes in helping businesses leverage Salesforce tools, including Agentforce, to build custom AI agents. They provide expertise in configuring agents tailored to specific business needs, ensuring that your AI solutions are effective and seamlessly integrated into your existing workflows.

    AI agents can assist in various job roles across multiple industries. They can handle customer service inquiries, support sales teams by booking meetings, manage HR tasks like onboarding, and streamline operations by automating repetitive processes. Essentially, they enhance productivity by taking on routine tasks across different functions.