Skip to main content

예상 시간

Create an Apex Agent Action

Learning Objectives

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

  • Create an Apex Agent Action.
  • Add an Agent Action to a topic.
  • Test the Agent Action.

Build an Apex Agent Action

Now that the Apex is ready, let’s add it to an action. You’ll see where the parameters in the Apex automatically get ported to the action.

  1. Click Setup “” and select Setup.
  2. In the Setup Quick Find box, search for and select Agentforce Assets.
  3. Click the Actions tab.
  4. Click New Agent Action.
  5. For Reference Action Type, select Apex.
  6. For Reference Action Category, select Invocable Method.
  7. For Reference Action, select Check Weather. This is the invocable method.

    Create an Agent Action showing the fields as described above.
  1. For Agent Action Label, leave the prefill, Check Weather, that was pulled from the invocable method label parameter.
  2. For Agent Action API name, leave the automatically generated prefill, Check_Weather.
  3. Click Next.

The next step is to configure the Agent Action. This is where you start to see the benefit of the parameters being set in the Apex.

  1. For Agent Action Instructions, leave the prefill provided from the Apex invocable method description parameter.
  2. Un-check Show loading text for this action.
  3. For Input, notice that dateToCheck is prefilled.
  4. For Instructions, note that it’s prefilled with the Apex invocable variable description parameter. You can also update or add to the instructions as necessary.
  5. For Data Type, it’s prefilled with the Apex data type.
  6. Required input is defaulted to checked from the required parameter set to true.
  7. Check Collect data from user.

    Input section filled out as described in the content.
  1. For Outputs, there are three that got pulled from the Apex invocable variables, maxTemperature, minTemperature, and temperatureDescription. The Instructions for each are prefilled from the corresponding description parameters and Data Type.
  2. For the third output, temperatureDescription, check Show in conversation.

    Output 3 filled out as described above with Show in conversion checked.
  1. Click Finish.

Excellent! The action is complete. You now know what it takes to add your Apex to actions. And you have a better understanding of how the Apex parameters work to help build out the action. Let’s add the Check Weather Agent Action to a topic and test it.

Update the Topic

  1. Click Setup “” and select Setup.
  2. In the Setup Quick Find box, search for and select Agentforce Agents.
  3. Select Einstein Copilot or Agentforce (Default).
  4. Click Open in Builder.
  5. Ensure the agent is deactivated.
  6. Select MigrationDefaultTopic.
  7. Click This Topic’s Actions.
  8. Click New, and select Add from Asset Library.
  9. Check the box for the Check Weather action, and click Finish.
  10. Refresh your browser window and then select MigrationDefaultTopic.
  11. Click This Topic’s Actions and verify Check Weather action is still in the list. If it isn’t, repeat steps 8 to 11. Sometimes in our practice environments, an added action doesn’t stay associated with the topic the first time you save it.
  12. Click Activate.

Let’s Check the Weather

  1. While still in Agentforce Builder, enter Check the weather for tomorrow in the Conversation Preview.

    Conversation pane showing the request to Check the weather for tomorrow and the response from the agent showing the temperatures at Coral Cloud.
  1. Take a look at the steps the agent took and notice it selected the Check Weather action to fulfill the request.

    Agentforce Builder steps showing the prompt, selecting the Migration Default Topic then selecting the Check Weather action.
  1. Want the weather forecast for next week? Enter Check the weather for next week.
  2. Take a look at the steps again. The agent sent the date for each day of the week to build the response.

    Agentforce Builder steps showing multiple calls to the Check Weather action with different date Inputs.

Well done! You’ve taken a large step toward using all of the Apex functionality your org already has and delivering it up for AI agents to use. You’ve learned some best practices and how to set parameters to get the most out of your agents.

Resources

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기