Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • How to Build a Custom Action in Salesforce Agentforce: Patient Appointment Scheduling
    • Agentforce Explained: Core Components Every Salesforce Professional Should Know
    • The Ultimate Guide to Automate Data Ingestion in Salesforce Data Cloud with Zapier
    • Prevent Large Data Queries in Salesforce with Transaction Security Policies
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Top Mistakes Developers Make in Salesforce Apex Triggers
    • Introducing Agentforce3 to Salesforce Developers
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Monday, September 1
    • Home
    • Salesforce Platform
      • Architecture
      • Apex
      • Lightning Web Components
      • Integration
      • Integration List
      • Flows & Automation
      • Best Practices
      • Questions
      • News
      • Books Testimonial
    • Salesforce Industries
      • Artificial Intelligence
      • Agentforce
      • Data Cloud
    • Hire Me
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Downloads
      • Salesforce Release Notes
      • Apex Coding Guidelines
    • About Us
      • Privacy Policy
    • Contact Us
    SalesforceCodex
    Home»Industries»Agentforce»How to Build a Custom Action in Salesforce Agentforce: Patient Appointment Scheduling

    How to Build a Custom Action in Salesforce Agentforce: Patient Appointment Scheduling

    Dhanik Lal SahniBy Dhanik Lal SahniSeptember 1, 2025Updated:September 1, 2025No Comments8 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Custom Action in Salesforce Agentforce | SalesforceCodex
    Custom Action in Salesforce Agentforce | SalesforceCodex
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Salesforce Agentforce is revolutionizing how businesses leverage AI-driven agents for customer interactions. One of its most powerful capabilities is Custom Actions—the ability to define specialized tasks that an agent can execute within Salesforce or external systems.

    In this blog post, we’ll walk through how to build a Custom Action in Agentforce for a real-world use case: Patient Appointment Scheduling in a healthcare scenario.

    Why Custom Actions in Agentforce?

    Agentforce comes with a set of predefined skills, but every industry has unique requirements. With Custom Actions, developers can extend Agentforce to perform domain-specific tasks such as

    • Scheduling a patient’s appointment with a doctor.
    • Checking insurance eligibility.
    • Creating a service request for financial advisors.

    For healthcare, appointment scheduling is a crucial workflow that can be automated, reducing staff workload and improving patient experience.

    Use Case: Patient Appointment Scheduling

    Imagine a patient interacting with a healthcare provider’s virtual agent:

    Patient: “I want to book an appointment with Dr. Smith for next Monday at 11 AM.”
    Agentforce: “Sure, let me check Dr. Smith’s availability for Monday…”

    Here, the agent must:

    1. Understand the intent, which is appointment scheduling.
    2. Retrieve the requested doctor’s available time slots.
    3. Confirm details with the patient.
    4. Create the appointment in Salesforce Health Cloud.
    5. Sent invitation details to the patient

    This is where our Custom Action comes in. As a developer, we need to create a custom action. Custom actions can be created using Apex and Salesforce Flow. In this post we will create an action using Salesforce Apex.

    How Custom Action will process the request

    Custom action will

    1. Retrieve the current customer record. It will use a standard action for this.
    2. Retrieve Dr. Smith. record. It will use a standard action for this.
    3. Confirm availability for the time slot. It can use a standard action.
    4. Book an appointment with Dr. Smith. It will use a custom action that we will create in this blog.
    5. Send appointment confirmation on WhatsApp/email. We can use a custom action. It is not handled in this blog.

    Steps to create a custom action in Salesforce Agentforce

    1. Create an invocable Apex class.
    2. Create a Custom Action
    3. Create a topic
    4. Add actions to the topic
    5. Test Action in Agentforce Builder
    6. Activate Topic

    1. Create an invocable Apex class

    Agentforce required an invocable method to create a custom action. As required, we will create an Apex class with an invocable method to create an appointment record. We have used a custom Appointment object in Health Cloud Org for this. You can use an object based on your requirements.

    Provide as much information as possible in the description for the invocable method. It will help in easily finding this action.

    2. Create a Custom Action

    We need to create a custom action for the above class method so that it will be available in the Agentforce asset library. We can create a custom action from Setup -> Einstein ->
    Einstein Generative AI -> Agentforce Studio -> Agentforce Assets

    Select the Actions tab and then the New Agent Action button on the Agentforce Asset Library page.

    Salesforce Agentforce - Agentforce Asset Library

    Connect an existing action

    It will open the Create an Agent Action page. Select the information below on the page

    • Reference Action Type: Apex
    • Reference Action Category: Invocable Method
    • Reference Action: Select the action that you have created. For us, it will be a Schedule Appointment.
    • Click Next

    Configure your action for Agent

    In this step, we will configure a custom action for Agentforce. It will populate information from an invocable method.

    Configure Custom Action for Salesforce Agentforce
    • *Agent Action Instructions: Put instructions for your custom action in this field. By default, it will be populated from the invocable method description. Put as much information in this field. The Atlas Reasoning engine will use this field to decide which action to perform. So it is a very important field.
    • *Loading Text: Put text that you want to display when the action is being performed. Example – Booking an Appointment for a Patient with a Doctor.
    • Inputs: Put instructions and data type for each input parameter. You can also put whether the parameter is required or not.
      • AppointmentDate: Put the instruction “Pass the appointment date given by the patient.” and make it required.
      • AppointmentType: Put the instruction “Pass the appointment type given by the patient. It can be a consultation or follow-up,” and make it required.
      • PatientId: Put the instruction “Get the ID from the record name that the user has mentioned, against which the appointment needs to be created. The account object will be used for retrieving the record Id ” and make it required.
      • ProviderId: Put the instruction “Retrieve the ID from the Healthcare Provider object by the record name that the user has specified, against which the appointment needs to be created” and make it required.
    • Outputs: Put the instruction to show the result.
      • message: Put the instruction “Show the message from the UI.” Mark checked to Show in the conversation
      • success:Put the instruction “Show the success from the UI.” Mark checked to show in the conversation
    • Click Finish to add a custom action in the asset library.

    Note: We have to provide access to this Apex class to the running user. Based on your requirement, you can give access to this class.

    3. Create a topic

    We can now add the above asset (custom action) to Agentforce agents to handle appointments. It can be done from Setup -> Einstein ->
    Einstein Generative AI -> Agentforce Studio -> Agentforce Agents
    . Select the default agent for our use case. You can use your agent based on your requirement. Open the default agent in Builder.

    It will show all topics that are already added to the agent. We will create a new topic for our use case.

    A Topic defines the scope of knowledge or subject area the agent can handle. Think of it as a container of domain-specific instructions, data sources, and actions. Topics guide the agent’s reasoning engine on what context to use when answering a question.

    The topic can only be created when the agent is inactive. So if it is already active, then make it inactive.

    Topic in Agentforce

    On the click of the new topic (as shown in the above image), it will open a pop-up to describe the topic.

    • What do you want this topic to do? – This is scheduling an appointment for a patient with doctors.

    Create topic

    Based on the above topic description, the system will populate below information

    • Name: Appointment Scheduling
    • *Classification Description: Handles scheduling appointments for patients with doctors based on availability and patient preferences.
    • *Scope: Your job is only to assist patients in scheduling appointments with doctors, ensuring the availability of the requested time and date, and providing options if the preferred time is unavailable.
    • Instructions 1: Ask the patient for their preferred date, time, and doctor for the appointment. User must provide the Provider name, patient name, and time for booking. Retrieve the patient ID and provider ID by using the given patient name and provider name.
    • Instructions 2: If the user does not provide these details, then show this message: “Please provide correct details.”
    • Example User Input: Book an appointment of Andy Smith with Dr. Anna Garcia on September 5th at 10 AM.

    The topic is created and ready to test.

    4. Add actions to the topic

    1. Add the above-created action (Schedule Appointment) to this topic.
    2. As per our apex class, we need to pass the patient and provider ID. We are getting the names from the user request. We can retrieve the record IDs (patient ID and provider ID) from the name field using SOQL in the Apex class itself. But Salesforce Agentforce provides a standard action, Identify Record by Name. So use this action to get the record id. It will reduce SOQL in Apex class.

    5. Test Action in Agentforce Builder

    Test the functionality in Agent Builder itself. Provide instructions to create an appointment.

    Agentforce Custom Action Testing in Builder | SalesforceCodex
    Salesforce Agentforce - Appointment Record

    6. Activate Topic

    Activate the topic and use it based on your requirement. It can be used in a Salesforce Org or a Community Org.

    Summary

    By building a Custom Action in Salesforce Agentforce, we can extend the AI agent’s capabilities beyond standard tasks. In healthcare, automated patient appointment scheduling not only improves operational efficiency but also enhances patient satisfaction.

    This same approach can be adapted for other industries—whether it’s scheduling financial consultations, creating service requests, or initiating onboarding workflows.

    Need a Salesforce Agentforce Expert?

    If you need Salesforce Agentforce experts, contact us or send an email to salesforcecodex@gmail.com.

    References

    • Create a Custom Agent Action
    • Get Started with Agentforce: Custom Actions

    Related Posts

    • Agentforce Explained: Core Components Every Salesforce Professional Should Know
    • How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI
    • Introducing Agentforce3 to Salesforce Developers

    Other Important Posts

    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Top 10 Enhancements in Salesforce Winter ’25 for Developers
    • Appointment Assistance Real Time Location Url Generation
    • Integrate Slack in Salesforce for Real-Time Notifications
    • Low Code Integration for Text Translation using SysTran API
    • Extract Demographic Detail using Trestle Reverse Phone API
    • Generic Notification Component in LWC
    • Generic Multi-Select Lookup Component
    Agentforce Agentforce Custom Action Agentforce for Healthcare Healthcare Automation in Salesforce Salesforce Agentforce Salesforce AI Salesforce AI Agent Salesforce Apex Development Salesforce Automation Workflows Salesforce Custom Action Salesforce Health Cloud Salesforce Healthcare Cloud
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAgentforce Explained: Core Components Every Salesforce Professional Should Know
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni5 Mins Read

    Agentforce Explained: Core Components Every Salesforce Professional Should Know

    August 29, 2025
    By Dhanik Lal Sahni6 Mins Read

    Prevent Large Data Queries in Salesforce with Transaction Security Policies

    August 11, 2025
    By Dhanik Lal Sahni6 Mins Read

    How to Leverage Model Context Protocol (MCP) to Enhance Salesforce AI

    July 28, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 Salesforce Developer Blog by SalesforceBen.com
    SFBenTopDeveloper
    Ranked #4 Salesforce Developer Blog by ApexHours.com
    ApexHoursTopDevelopers
    Categories
    Archives
    Tags
    apex (117) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) batch processing (4) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) future method (4) google (6) google api (4) integration (20) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Queueable (9) queueable apex (4) rest api (24) salesforce (153) salesforce apex (53) salesforce api integration (6) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    MailChimp

    Expert Salesforce Developer and Architect
    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • How to Build a Custom Action in Salesforce Agentforce: Patient Appointment Scheduling
    • Agentforce Explained: Core Components Every Salesforce Professional Should Know
    • The Ultimate Guide to Automate Data Ingestion in Salesforce Data Cloud with Zapier
    • Prevent Large Data Queries in Salesforce with Transaction Security Policies
    • The Ultimate Guide to Data Cleanup Techniques for Salesforce
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 10 Salesforce CRM Trends to Watch in 2025 July 18, 2025
    • Discover the Top 10 Salesforce AppExchange Apps to Boost Productivity July 10, 2025
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    Archives
    Categories
    Tags
    apex (117) apex best practices (5) apex code best practice (10) apex code optimization (6) Apex logging (4) apex rest (11) apex trigger best practices (6) architecture (22) Asynchronous apex (9) AWS (5) batch apex (10) batch processing (4) best code practice (4) code optimization (9) custom metadata types (5) design principle (9) flow (16) future method (4) google (6) google api (4) integration (20) integration architecture (6) lighting (8) lightning (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) optimize apex (5) optimize apex code (6) optimize apex trigger (5) Queueable (9) queueable apex (4) rest api (24) salesforce (153) salesforce apex (53) salesforce api integration (6) Salesforce Interview Question (5) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.