Extends Salesforce Agentforce with a custom action that processes unstructured data with AI. This example is covered in more detail within this blog and video. Also checkout our other Agentforce demo and sample code here.
Heroku applications can supercharge Agentforce because they:
- Can process unstructured data in variety of ways in real-time
- Can vertically scale to use large in memory data structures to support analytics of that data on the fly
- Can leverage AI LLM to generate data queries from natural language prompts
- Can leverage common libraries such as Java and Spring that have purpose built components
- Can leverage different programming languages, such as Python often used when building AI applications.
This demo includes:
- Java and Spring Boot to build a Agentforce action
- Archive data (
/invoices
) is ingested into an in-memory database (H2) (optional persisted DB) - Spring AI takes the natural language Agentforce prompt and converts it to SQL via ChatGPT
- The AI generated SQL query is run and the query result is returned in the action response to Agentforce
- The library org.springdoc is used to automatically generate OpenAPI schema and Swagger UI interfaces
These are some of the prompts it can handle:
- Which product invoiced had the most units sold?
- What was the total invoiced amount on Planning Meetings?
- From the invoices what were the total units sold for Consulting Hours?
- Total invoiced amount in 2009?
- Can you list the invoice numbers for 2008?
- Can you list the products included in the invoices in 2008?
- What was the total invoiced amount on 'Planning Meetings' OR TOTALPRICE = 0?
Its good practice for any API that exposes information to have authentication. Java Spring (the library used in this example) makes it very easy to configure a number of security approaches. To keep things simple for this example HTTP Basic authentication is enabled with a hard coded user heroku
and password agent
.
IMPORTANT: Please do change this authentication configuration before deploying to production. Typically JWT authentication is used for APIs.
Use the following command to run locally:
./mvnw spring-boot:run
To test the API use the
Swagger UI with user, heroku
and password agent
. Make sure to provide a valid OPENAI_API_KEY
. This demo highlights that Heroku applications are ideal candidates to host Agentforce actions that require complex intensive compute.
You will need to deploy this API before you can connect it to Agentforce. Heroku makes this very easy. First create a Heroku app to deploy this application by running:
heroku create <app-name>
Use the following command to configure your OPENAI_API_KEY
heroku config:set OPENAI_API_KEY=<value>
Finally deploy the API to Heroku.
git push heroku main
More detailed instructions for how to deploy using Heroku Git can be found here.
Complete this tutorial to learn how configure this action within your org.
Good news! Since publishing this demo, we’ve also released an additional demo video and sample code, diving deeper into how Heroku enhances Agentforce agents' capabilities. In this expanded version of the popular Coral Cloud Resort demo, vacationing guests can use Agentforce to browse and book unique experiences. With Heroku, the agent can even generate personalized adventure collages for each guest, showcasing how custom code on Heroku enables dynamic digital media creation directly within the Agentforce experience.