Skip to main content

Geschätzte Zeit

Themen

Die Community fragen

Add a Flow as an Agent Action

Learning Objectives

After completing this unit, you’ll be able to:

  • Ground an agent’s topic for maximum effectiveness with flow-based agent actions.
  • Create an agent action that references a flow.
  • Configure a topic so that one agent action provides data to another agent action.
Note

This badge assumes you’re familiar with flows and have experience with Flow Builder. Follow the Build Flows with Flow Builder trail to build strong process automation skills and become a Flow Builder expert.

Now that you’ve created the flows that the Coral Cloud Experience Agent needs to help customers manage their booked activities, create a topic on that agent and give it the flow-based actions it needs to help your customers.

Set Up Agentforce

First, make sure Agentforce is enabled in your Trailhead playground.

  1. In the Setup Quick Find, search for and select Einstein Setup.
  2. Make sure Turn on Einstein is On.
  3. Refresh your browser to reload Setup.
  4. In the Setup Quick Find, search for and select Agentforce Agents.
  5. Make sure Agentforce is On.

“”

Add a Topic

Before you create the agent’s topic, consider some guidelines and best practices for configuring topics.

  • Ground your topic with information about the relevant Salesforce objects. Describe their purposes so the agent understands how their data is used.
  • Tell the topic that it shouldn’t use any Salesforce data that isn’t provided by an action. Remember, agents have access to all objects and fields granted to them by permissions. This statement prevents the agent from talking about data that isn’t relevant or shouldn’t be shared.
  • Tell the topic not to show the customer any ID values. Record collection variables always include the IDs of the records, so without this instruction, there’s a good chance the agent will show this data to customers, even though it’s meaningless to them. This statement protects your customers from being confused by cryptic data.
  • When you mention an agent action, make sure you use the action’s API name. For example, refer to it as the “Get_Customer_Details action”, not the “Get Customer Details action”. This practice helps the agent distinguish action names from the surrounding text.

When you configure a topic, you provide its classification description, scope, and instructions.

Field Name

What to Do

Classification Description

Provide a general idea of what the topic is for and explain the context of the data it’s working with.

Scope

Tell the agent what its job is, and provide specific details about things it should not do.

Instructions

Be specific about how the agent should interact with the customer:

  • The agent should ask how it can help instead of guessing which question to ask.
  • If the agent doesn’t know which customer they’re talking to, it should ask for identifying information and use that to run the Get Customer Details flow. It should do this before it runs any other flows.
  • If a customer asks for their booked activities, the agent should run the Get Contact’s Upcoming Bookings flow. It should then give the results of that flow to the customer.

Now create a topic that tells the agent what it can and cannot do with customers’ booked activities.

  1. In the Setup Quick Find, search for and select Agentforce Agents.
  2. Select Coral Cloud Experience Agent.
  3. Click Open in Builder.
  4. In the Topics panel, click New and select New Topic.
    If the New button does not appear, return to the agent setup page and toggle the Agentforce toggle to off, then back to on again.

“”

  1. Leave “What do you want this topic to do?” blank and click Next.
    The “What do you want this topic to do?” field automatically fills in other topic values for you. For this exercise, you set the values manually so we can walk you through them.
  2. In the Create a Topic box, configure the topic as follows.
    • For Name, enter Booked Activity Management.
    • For Classification Description, enter:
      This topic helps Coral Cloud Resort guests to manage and understand their booked activities. Booked activities are stored in the 'Bookings' object in Salesforce. Guests are represented by the 'Contacts' object in Salesforce.
    • For Scope, enter:
      Your job is only to help Coral Cloud Resort guests book activities, give them information about their existing booked activities, and cancel their booked activities. Do not use any Salesforce data that wasn't provided by an action's output. Do not show the customer any ID values.
  3. At the bottom, click Add Instructions two (2) times to display a total of three instruction text boxes.
  4. Add these Instructions:
    • For the 1st Instruction, enter:
      After showing the customer a list of their activities, ask them how you can help them.
    • For the 2nd Instruction, enter:
      If the customer is not known, you must always ask for their email address and their membership number to get their Contact record by running the Get_Customer_Details action before running any other actions.
    • For the 3rd Instruction, enter:
      If the customer asks what their current booked activities are, run the Get_Contact_s_Upcoming_Bookings action and then present the output to the customer.
      The topic fields corresponding to the previous instructions.
  5. Click Next.
  6. Click Finish.
    If a Topic Overlap Detected message window pops up, click Ignore. The message alerts an agent’s creator that there may be a similar topic already in this org’s topic library. For this badge, you don’t have to worry about that.

Add Flows as Agent Actions

It’s time to add the flows to the agent. Create an agent action for each flow and assign them to the topic. Fortunately, you can create these agent actions without having to leave Agentforce Builder.

Add the Get Customer Details Action to the Agent

  1. Click the Booked Activity Management topic.
  2. Click the This Topic’s Actions tab.
    This Topic’s Actions tab highlighted.
  3. Click New and select Create New Action.
  4. Select Flow as the Reference Action Type.
  5. For Reference Action, select Get Customer Details.
  6. Keep the default Label and API Name, and click Next.
  7. Make sure the Agent Action Instructions say Validate a Customer’s details by passing their email and memberNumber to see if there is a related contact.
  8. Uncheck the box labeled Show loading text for this action.
  9. Configure the email variable’s input settings.
    • Make sure the Instructions say The Email Address of the customer that is validating their identity.
    • Check Require input.
      This setting tells the agent that it shouldn’t run this action unless it has data to send to it. Use this setting to ensure that the flow doesn’t run without the data it needs to run successfully.
  10. Configure the memberNumber variable’s input settings.
    • Make sure the Instructions say The Member Number of the customer that is validating their identity.
    • Check Require input.
  11. Configure the contact variable’s output settings.
    • Make sure the Instructions say The contact that was returned in the search for records.
    • Check Show in conversation.
      This setting tells the agent that it’s okay to send the contents of this variable to the customer. If the Show in Conversation checkbox isn’t selected for a particular output, that flow variable’s contents won’t ever be shared with the customer.
  12. Click Finish.

Add the Get Contact’s Upcoming Bookings Action to the Agent

  1. In the This Topic’s Actions tab of the Booked Activity Management topic, click New and select Create New Action.
  2. Select Flow as the Reference Action Type.
  3. For Reference Action, select Get Contact’s Upcoming Bookings.
  4. Keep the default Label and API Name, and click Next.
  5. Make sure the Agent Action Instructions say Find all the Booking records related to the guest's contact record. Only retrieve Bookings whose date hasn't occurred yet.
    Notice that the default Agent Action Instructions match the flow’s description. When you write a good description for the flow that accurately describes what it does, you save yourself effort later!
  6. For Loading Text, enter Retrieving your booked activities.
  7. Configure the Contact_ID variable’s input settings.
    • Make sure the Instructions say The Id of a Contact record that you would like to find related Booking records for.
      Notice that the default Instructions match the description of the Contact_ID variable in the flow. Seeing a pattern?
    • Check Require input.
  8. Configure the Contact_Bookings variable’s output settings.
    • Make sure the Instructions say The upcoming not-canceled bookings assigned to the contact whose ID matches the Contact_ID.
    • Check Show in conversation.
  9. Configure the Error_Message_Output variable’s output settings.
    • Make sure the Instructions say The error message to show to the customer when this flow doesn't finish successfully.
    • Check Show in conversation.
  10. Click Finish.

Test the Agent

Now that the topic is ready, you can put it to the test. Use the Conversation Preview panel in Agentforce Builder to run the agent and verify that it’s working as expected.

  1. While still in the Agentforce Builder, click Refresh (circular arrow) in the top right corner of the Conversation Preview.
    The Conversation Preview window.
  2. Enter this prompt: Can you show me my booked activities? and press your Return/Enter key.
  3. After the agent responds, enter the next prompt: I am sofiarodriguez@example.com and my membership number is 10008155. Press your Return/Enter key.

The agent shows a list of Sofia’s currently booked activities that looks something like this:

Here are your upcoming booked activities:
Family Adventure Quest
Date: 2025-05-11
Time: 13:30 - 14:30
Trail Running Adventure
Date: 2025-05-14
Time: 09:00 - 10:00
Seaside Gourmet Dinner
Date: 2025-05-15
Time: 09:00 - 12:00
Beach Bootcamp Challenge
Date: 2025-05-15
Time: 13:30 - 17:30
Seaside Gourmet Dinner
Date: 2025-05-16
Time: 13:30 - 16:30
Family Movie Night Under the Stars
Date: 2025-05-25
Time: 09:00 - 10:00
Ocean Kayak Fitness Expedition
Date: 2025-05-26
Time: 09:00 - 15:00
Live Music Beach Party
Date: 2025-05-26
Time: 13:30 - 15:30
Coastal Kayak Excursion
Date: 2025-05-31
Time: 13:30 - 14:30
Artisan Workshop Series
Date: 2025-06-02
Time: 13:30 - 14:30

Congratulations, you created a flow that makes your agent more accurate and powerful, then gave that agent the instructions it needs to run the flow consistently. In the hands-on challenge, you create another agent action that updates your customer’s Booking records.

Resources

Teilen Sie Ihr Trailhead-Feedback über die Salesforce-Hilfe.

Wir würden uns sehr freuen, von Ihren Erfahrungen mit Trailhead zu hören: Sie können jetzt jederzeit über die Salesforce-Hilfe auf das neue Feedback-Formular zugreifen.

Weitere Infos Weiter zu "Feedback teilen"