Heroku AppLink and Agentforce Integration
Step 1. Deployment of the Heroku Application
You can deploy the Heroku application from the Heroku Dashboard or from the Heroku CLI.
Deployment from Heroku Dashboard (Recommended)
- Go to the heroku-tdx25-agentforce repository and click on the Deploy to Heroku button.
Enter a name for your Heroku application, for example username-agentforce-services, then, on App owner select the team-name provided by the instructor and click Deploy. Ignore the warning about the heroku-integration add-on not being available, this is because it is not available to the public yet.
TIP
- Heroku application names must be unique, the username is a proposal to make it unique. eg:
jduque-agentforce-services
- team-name will be provided by the instructor
- Heroku application names must be unique, the username is a proposal to make it unique. eg:
Deployment from Heroku CLI (Optional)
Clone this repository:
bashgit clone https://github.com/heroku-examples/heroku-tdx25-agentforce cd heroku-tdx25-agentforce
Login to Heroku using the CLI:
bashheroku login
Create an Heroku application:
bashheroku create <username>-agentforce-services -t <team-name>
TIP
Heroku application names must be unique, the username is a proposal to make it unique. eg:
jduque-agentforce-services
team-name will be provided by the instructor
Make sure that the git remote is setup:
bashheroku git:remote -a <username>-jduque-agentforce-services
Deploy application to Heroku by running:
bashgit push heroku main
Step 2. Heroku AppLink Add-on Configuration
To check that your Salesforce org has AppLink enabled go to Setup > Heroku > Apps
Install the Heroku AppLink CLI plugin:
bashheroku plugins:install @heroku-cli/plugin-applink
Provision the Heroku AppLink add-on:
INFO
ℹ️ This step is not needed if you deployed from the Heroku Dashboard
bashheroku addons:create heroku-applink --app <username>-agentforce-services
Configure the HEROKU_APP_ID environment variable:
Run the following command and take note of the application Id:
bashheroku apps:info --json
The application Id should appear in the
app
section of the JSON:{ "addons": ... "app": { ... "id": "2ce48014-dd24-4733-a1dc-707cf677d29e", }, "dynos": ... }
Run the following command with this id:
bashheroku config:set HEROKU_APP_ID=<appid>
Add the Heroku AppLink Service Mesh buildpack to your app:
INFO
ℹ️ This step is not needed if you deployed from the Heroku Dashboard
bashheroku buildpacks:add https://github.com/heroku/heroku-buildpack-heroku-applink-service-mesh
Connect your app to your Salesforce org:
INFO
💡 Make sure to replace
username
with the username used in your app name.bashheroku salesforce:connect applink-org --app <username>-agentforce-services
This will open a browser window to login to Salesforce, use the credentials you obtained for your Salesforce org in the previous steps.
Publish the OpenAPI specification to your org as the
ActionsService
Service, run the command where theapi-docs.yaml
file is located.TIP
💡 The
api-docs.yaml
file is in the GitHub repository, you can download it from api-docs.yaml. If you used the Heroku CLI deployment approach, it will be in the root of the repository you cloned.bashheroku salesforce:publish api-docs.yaml --client-name ActionsService --connection-name applink-org --app <username>-agentforce-services --authorization-connected-app-name ActionsServiceConnectedApp --authorization-permission-set-name ActionsServicePermissions
Trigger an application rebuild to install the Heroku AppLink buildpack:
INFO
ℹ️ This is not needed if you deployed from the Heroku Dashboard
bashgit commit --allow-empty -m "Rebuild app" git push heroku main
Verify the service is under Setup > Heroku > Apps
Now you can check the Heroku application in the Salesforce org by going to Setup > Heroku > Apps and clicking on the AgentforceServices app.
Step 3. Assign the Agentforce Services Permission Set
- From Setup, navigate to Permission Sets and click on the ActionsService permission set.
- Click on Manage Assignments
- Click on Add Assignments
- Select the EinsteinServiceAgent User profile and click Next
- Click Assign
- Repeat the above steps for the ActionsServicePermissions permission.
Step 4. Calling the Heroku Application from Agentforce
Create an Agent Action
From Setup, open Agentforce Assets and click on the Actions tab.
Click New Agent Action.
Configure the action as follows:
Field Value Reference Action Type API Reference Action Category Heroku Reference Action Calculate Finance Agreement
Agent Action Label Keep the default Agent Action API Name Keep the default Click Next.
Leave in place the default instructions (obtained from the Heroku app API documentation)
Uncheck the Loading Text checkbox
Check Show in conversation in the Output section for the 200 output (This is the success response from the Heroku app)
Click Finish
Step 5. Add the Agent Action to an Agent
From Setup, open Agentforce Agents (under Agentforce Studio).
Click on Koa Cars Dealership Agent in the list of agents.
Click Open in Builder.
Click Deactivate to deactivate the agent if its is Active, so that you can add a new custom action.
In the Topics sidebar, click the Koa Cars Salea Agent topic.
Go to This Topic's Actions tab.
Select New and from the dropdown list choose Add from Asset Library.
Check the Calculate Finance Agreement action and click Finish.
Confirm the Calculate Finance Agreement action is in the list of actions.
Step 6. Testing the Agent Action
Refresh the Conversation Preview panel click in the top right Refresh icon
In the Conversation Preview panel, enter the following prompt:
txtI want to buy the car with a $1,000 down payment, a max 5% interest rate, and a term over 3 years. Can you provide a competitive finance estimate?
The agent will request the contact email:
txtMy email is johnsmith@codey.com
The agent will ask for the car model:
txtI'm interested in the Zig M3 car
Navigate to the Contact record for
johnsmith@codey.com
and click Notes & Attachments to view the finance agreement in PDF form.
Now you can see how the Heroku application is called from Agentforce to provide a finance agreement estimate and generate a PDF.