This tutorial will guide you through configuring an Agentforce Action deployed to Heroku within your Salesforce org. This allows Agentforce agents to access powerful custom-coded actions written in Python and other languages, leveraging Heroku's fully managed and elastic compute service. By the end, you will be able to generate your own badge as shown below!
Ensure you have access to Agentforce by searching for
Agents
in theSetup
menu. If not, you can create a temporary org by logging into Trailhead and creating a Playground per the instructions at the top of this module (you do not need to complete the module). Once you have access to the org, locateEinstein Setup
under theSetup
menu and enable Einstein, which will also enable Agentforce.
The examples in this tutorial are intentionally simple, designed to give you a clear starting point for creating your own actions. We have also included fully developed actions, and we recommend watching the video demonstrations first. Once you’re ready, proceed below to start building your own Agentforce Action with Heroku.
Example | Demo Video | Related Content | |
---|---|---|---|
The Archive Agent action demonstrates using Heroku to access and perform complex computations over unstructured archived data. It uses AI to interpret natural language requests from users to perform a wider array of dynamic calculations on the data. | Link | Blog Code | |
With the Coral Cloud Collage Agent, we explore how Coral Cloud Resort invites its guests to browse and book unique experiences throughout their stay using Agentforce. With Heroku, we extend the agent's functionality to generate a personalized collage of each guest's adventures, showcasing how custom code deployed on Heroku can create dynamic digital media delivered directly within the Agentforce experience. | Link | Code |
This tutorial provides examples in Java and Python for coding a basic Agentforce action. You can deploy these to your own Heroku account or proceed for now with the pre-deployed versions we have created for you.
Language | Pre-deployed API URL | Pre-deployed API Test Page | Or Deploy your Own to Heroku |
---|---|---|---|
Python | Action API URL | Action API Test Page | Go to this GitHub Repository |
Java | Action API URL | Action API Test Page | Go to this GitHub Repository |
With the above information, you have two paths to take:
- If you are using the pre-deployed versions, right-click the Action API URL link from above and copy the URL to your clipboard when requested below. Optionally, click the Action API Test URL to try the API out from your browser; this will be the Action API Agentforce will eventually call out to when invoking your action.
- If you want to deploy your own action before proceeding, follow the instructions in the respective repository above and return here with the deployed URL.
If you have not yet gained access to an Agentforce-enabled environment, please refer to the note above. The following steps assume that you are logged in and have administrator access to the Salesforce Setup
menu.
-
Search for
Named Credentials
underSetup
, select theExternal Credentials
tab, and clickNew
, completing the dialog as shown. -
Scroll down the next page to the
Principals
section and clickNew
, completing the dialog as shown.The default password for this tutorial is
agent
. -
Search for
Named Credentials
underSetup
, select theNamed Credentials
tab, and clickNew
, completing the dialog as shown.To obtain the URL value, right-click the desired
Pre-deployed API URL
above or use the one given to you after completing your own Heroku deployment. The one shown in the screenshot above is the Java pre-deployment.
-
Search for
External Services
underSetup
and clickAdd an External Service
. Then, selectFrom API Specification
and clickNext
, completing the dialog as shown, and clickSave & Next
.If you have not modified the action code yet or are using the pre-deployments above, you can click here (Java) or here (Python) to obtain the schema and copy-paste it into the
Schema
field. Log in when prompted with userheroku
and passwordagent
.Alternatively, to obtain the dynamically generated schema for your own action deployment, refer to the instructions in the respective GitHub repository in the table above to open the API Test (Swagger) page. Then click the link just below the API title in the top left corner of the page, as shown in the examples below. Then copy and paste the entire contents into the
Schema
field above.For more information on the API Test (Swagger) page and authentication, see the respective sample code GitHub repositories listed in the table in step 1.
-
Finally, on the next page, select the
Operation
shown below and clickNext
. -
Confirm you can see the input and output parameters as shown below, and click
Finish
.
-
Search for
Permission Sets
underSetup
, clickNew
, complete the page as shown, and clickSave
. -
Locate the
External Credential Principal Access
section and edit it so that it appears as shown. -
Finally, assign the permission set to your current user using the
Manage Assignments
button.
-
Search for
Flows
underSetup
and clickNew Flow
. ClickStart from Scratch
, thenNext
, and selectAutolaunched Flow (No Trigger)
. ClickCreate
to open theFlow Builder
. -
From the
Flow Builder
, open theToolbox
by clicking the sidebar icon near the top left of the screen. ClickNew Resource
and create the following variable resources.-
Resource Type: Variable
- API Name: AgentActionRequestName
- Data Type: Text
- Apex Class: Not Applicable
- Availability Outside the Flow: Available for Input
-
Resource Type: Variable
- API Name: AgentActionResponseMessage
- Data Type: Text
- Apex Class: Not Applicable
- Availability Outside the Flow: Available for Output
-
Resource Type: Variable
- API Name: AgentActionRequest
- Data Type: Apex Defined
- Apex Class: ExternalService__HerokuAgentAction_AgentRequest
- Availability Outside the Flow: None
Your
Flow
should look like this so far: -
-
Click the
+
icon in the middle of the canvas and selectAction
. In theSearch Actions
sidebar, search forHeroku
, select thePost Process
action, and complete the fields as shown. -
Click the
+
icon before theCall Heroku
element on the canvas, selectAssignment
, and complete as shown. -
Click the
+
icon after theCall Heroku
element on the canvas, selectAssignment
, and complete as shown.Tip: To complete the
Value
field click into the field and use the popup to select theOutputs from the Call Heroku Action
resource, then click_200
and finallymessage
. -
Finally, your
Flow
should look like this: -
Click
Save
, enterHeroku Agent Action
, and clickSave
, followed by clickingActivate
. -
Search for
Agent Actions
under theSetup
menu, and clickNew Agent Action
, selectingFlow
as theReference Action Type
. In theReference Action
search field, search forHeroku
so that you see the following: -
Complete defining the action as follows and click
Finish
.Field Text Agent Action Instructions
Use this action to produce a unique Heroku badge with a custom name printed on it AgentActionRequestName Instructions
Name to be placed on the badge. Do not show the parameter name. AgentActionResponseMessage Instructions
Render the response as HTML rich text output.
-
Search for
Agents
underSetup
and be sure to toggle to enableEinstein Copilot for Salesforce
. -
Click the
Einstein Copilot
link at the bottom of the page to find theOpen in Agent Builder
button. -
Click the
Deactivate
button in the top right of the screen if present. -
Click
Topics
and theGeneral CRM
topic. If theNew Version
button is shown, click it. -
Click the
This Topic's Actions
tab and selectAdd from Asset Library
from theNew
button dropdown. -
Complete the dialog as shown and click
Finish
. -
Finally, click the
Activate
button in the top right of the screen.
-
Open the
Agent Builder
forEinstein Copilot
. -
In the
Conversation Preview
, enterGenerate my badge with the name Master Builder on it!
You can, of course, change the name to your own and share your badge with your friends!
Congratulations on deploying your first Heroku-powered Agentforce Action!
We are working to improve and simplify this process, so please follow this repository to stay informed on updates.