Appearance
Exercise 6 (Optional): Extend Agents with MuleSoft
In this exercise, you will import MuleSoft APIs into Salesforce and make them available to be integrated with Agentforce. This will help Coral Cloud Resorts to efficiently manage any transactions for their customer rewards program.
Step 1: Set up named credentials
Open the Setup Menu and click Setup.
In the quick find, search for Named Credentials and click Named Credentials.
Click on the dropdown besides New and select New Legacy.
Configure the credential as follows:
Field Value Label RewardAPI
Name Keep default URL https://coralcloud-agentforce-sys-api-ues9o0.5sc6y6-2.usa-e2.cloudhub.io/
Click Save.
Use the screenshot below to confirm that you entered the right values.
Step 2: Import external services
In this step, you will import pre-existing MuleSoft APIs from Anypoint Exchange. We have created the Rewards API for Coral Cloud Customers and already published it in Anypoint Exchange.
From Setup, open External Services.
Click Add an External Service.
Select Reroute to MuleSoft Services UI, then click Next.
Click Confirm on the dialog.
Click Log In to log into MuleSoft Anypoint Platform, and confirm the log in.
Enter the following credentials in the MuleSoft login screen:
Field Value Username coralclouduser Password Coralclouduser@2024 Click Sign In.
Click Confirm on the dialog.
Click Import.
Select the MuleSoft API titled coralcloud-rewards-api with the latest version then click Next.
Set the service details:
Field Value Name Rewards
Description Keep default Named Credential RewardAPI
Click Save & Next.
Select all operations by clicking on the checkbox to the left of the Operation Name table header.
Click Finish.
Step 3: Create the flow
From Setup, open Flows.
Click New Flow.
Leave Start from Scratch selected and click Next.
Select Autolaunched Flow (No Trigger) and click Create.
Open the Resources panel by clicking the sidebar icon to the left of the Select Elements button.
Using the New Resource button, create two variables defined as follows:
Resource Type API Name Description Data Type Available for input Available for output Variable rewardId
The Reward Id that has rewards points associated.
Number ✅ Unchecked Variable rewardPoints
The Reward points of the Coral Cloud customer.
Text Unchecked ✅
TIP
Writing clear and informative descriptions is a crucial part of building actions. It allows the planner to select the right actions, populate inputs with the right values, and correctly interpret outputs.
Define the MuleSoft API call
Mouse over the circle after the Start element, click +, and select Action.
Select the action Get Rewards By Reward Id.
Configure the Action element as follows:
Field Value Label Get Reward Points by Reward Id
API Name Keep default Description The Reward Id that has rewards points associated
Reward Id {!rewardId}
You can use the screenshot below to confirm that you entered the right values.
Click Done.
Store the API result
Mouse over the circle after Get Reward Points By Customer Id, click +, and select Assignment.
Configure the Assignment element as follows:
Field Value Label Output of the API call
API Name Keep default Description Storing the output of the reward points API call.
Set the following variable assignment:
Variable Operator Value rewardPoints Equals {!Get_Reward_By_Id.200.pointsRequired} Use the screenshot below to confirm that you entered the right values.
Save and activate the flow
Click Save from the top banner.
Configure the Flow as follows:
Field Value Label Get Customer Reward Points
API Name Keep default Description This Flows fetches customer reward points for a given reward Id.
Click Save.
Click Activate.
Click the back arrow button to leave Flow Builder and go back to Setup.
Step 4: Create the agent custom action
From Setup, open Agent Actions.
Click New Agent Action.
Configure the action as follows:
Field Value Reference Action Type Flow Reference Action Get Customer Reward Points Agent Action Label Keep default Agent Action API Name Keep default Click Next.
Leave the default instructions in.
Check Require Input in the Input section.
Check Show in conversation in the Output section.
Click Finish.
Step 5: Add the action to your agent
From Setup, open Agents (under Agent Studio).
Click on Einstein Copilot in the list of agents.
Click Open in Builder.
Click Deactivate to deactivate the agent, so that you can add a new custom action.
In the Topics sidebar, click the CustomerServiceAssistant tab.
Go to This Topic's Actions tab.
Select New and from the dropdown list choose Add from Asset Library.
Check the Get Customer Reward Points action and click Finish.
Go back to the Topic Configuration tab and add a new instruction. Click on Add Instruction and add the following instruction:
txtAsk for Reward Id when the user wants Reward points. Make sure the Reward Id is a number
Step 6: Try it out
Activate the Builder and refresh the Conversation Preview.
In the Conversation Preview panel, enter the following prompt:
txtGet me the Reward Points for Reward Id 3553.
In the planner, notice that the reasoning engine will select Get Customer Reward Points action.
Try entering a wrong prompt with an incorrect Reward Id, for example:
txtGet customer Reward Points for Reward Id 36bfc