Appearance
Exercise 4: Extend Agents with Flow Actions
In this exercisse, you'll extend your agent with a custom action powered by a flow. This custom action allows customer service representatives to issue resort credits to guests.
Step 1: 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 three variables defined as follows:
Resource Type | API Name | Description | Data Type | Object | Available for input | Available for output |
---|---|---|---|---|---|---|
Variable | contactId | The Id of the Contact the credit will be issued to. | Text | N/A | ✅ | Unchecked |
Variable | amount | The amount of the resort credit. | Number (Decimal places: 0) | N/A | ✅ | Unchecked |
Variable | creditRecord | The Credit record that was created. | Text | Credit__c | 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.
Create a credit record
Mouse over the circle after the Start element, click +, and select Create Records.
Configure the Create Records element as follows:
Field Value Label Create Credit Record
API Name Keep default Description Create a credit record including a Contact Id and the amount of the credit.
How to Set the Record Field Values Manually (default) Object Credit Under Set Field Values for the Credit, add the two fields below with their values set as follows:
Field Value Contact__c contactId Amount__c amount
Query the new record
Mouse over the circle after the Create Credit Record element, click +, and select Get Records.
Configure the Create Records element as follows:
Field Value Label Get Credit Record
API Name Keep default Description Query the credit record to present back to the user
Data Source Salesforce Object Object Credit Condition Requirements All Conditions Are Met (AND) Define the condition below:
Field Operator Value Id Equals {!Create_Credit_Record}
Leave How Many Records to Store and How to Store Record Data to their defaults.
Assign the output
Mouse over the circle after the Get Credit Record element, click +, and select Assignment.
Configure the Create Records element as follows:
Field Value Label Assign Credit Record to Output Variable
API Name Keep default Description Assign the record output to the creditRecord Variable
Set the variable values:
Field Operator Value {!creditRecord}
Equals {!Get_Credit_Record}
Leave How Many Records to Store and How to Store Record Data to their defaults.
Save and activate the flow
Click Save from the top banner.
Configure the flow as follows:
Field Value Label Issue Resort Credit
API Name Keep default Description Issue a resort credit for a Contact
Click Activate.
Click the back arrow button to leave Flow Builder and go back to Setup.
Step 2: Create the agent custom action
From Setup, open Agentforce Assets and select the Actions Tab.
Click New Agent Action.
Configure the action as follows:
Field Value Reference Action Type Flow Reference Action Issue Resort Credit Agent Action Label Keep default Agent Action API Name Keep default Click Next.
Leave the default instructions in.
Check Show loading text for this action .
Set Loading Text to
Adding credit...
.Check Require Input for both inputs (
amount
andcontactId
).Check Show in conversation for the
creditRecord
output.Click Finish.
Step 3: Add the action to your agent
From Setup, open Agentforce Agents (under Agent Studio).
Click on the Customer Service Agent in the list of agents.
Click Open in Builder.
Click Deactivate to deactivate the agent, so that you can add your new custom action.
In the Topics sidebar, click the Hotel Customer Service(or similarly generated named) topic.
Click the This Topic's Actions tab.
Click the New button, then Add from Asset Library to add an action.
Check the Issue Resort Credit action and click Finish.
Step 4: Try it out
In the Conversation Preview panel, enter the following prompt:
txtIssue $100 resort credit to contact named Sofia Rodriguez
In the planner, notice that the reasoning engine first selected the Identify Record By Name action, then the Issue Resort Credit action you just created.
Then in the conversation preview, you can see the newly created Credit Record.