Learn how you can leverage Heroku AppLink with a Node.js Express server to build an Agentforce tool. This tool will allow you to use natural language to get insights into Salesforce opportunities.
This project demonstrates how to leverage Heroku AppLink to build fast and reliable tools for Agentforce. Specifically, how a Node.js Express application enables Agentforce with natural language processing of Salesforce CRM opportunities.
The tool accepts SOQL (Salesforce Object Query Language) statements and executes them against your Salesforce org to retrieve opportunity data. It intelligently handles user ID placeholders and returns both detailed opportunity records and mathematical calculations.
- Natural Language Input: Users interact with Agentforce using natural language to ask about opportunities
- SOQL Generation: An LLM generates appropriate SOQL queries based on the user's intent
- Query Processing: The Express server receives the SOQL query and processes user ID placeholders
- Salesforce Integration: The server uses Heroku AppLink to securely execute queries against Salesforce
- Response Handling: Results are returned as structured JSON with support for both data records and mathematical calculations
The API provides a single endpoint for querying Salesforce opportunities:
Endpoint: POST /v1/opportunities
Request Body:
{
"query": "SELECT Id, Name, Amount FROM Opportunity WHERE OwnerId = 'USER_ID'"
}Response:
{
"message": "success",
"opportunities": [
{
"Id": "006Ka00000TJEZUIA5",
"Name": "Omega Technologies",
"StageName": "Closed Won",
"Amount": 65500,
"CloseDate": "2025-09-10",
"AccountId": "001Ka00004PqZCIIA3",
"OwnerId": "005Ka000004UsT0IAK",
"Probability": 100,
"Description": "This deal is looking good so far."
}
],
"mathResult": ""
}βββ api-spec.yaml # OpenAPI 3.0 specification
βββ package.json # Root package configuration
βββ README.md # Project documentation
βββ screenshots/ # Logo and visual assets
βββ server/ # Express server code
β βββ index.js # Main server file
β βββ package.json # Server dependencies
β βββ src/
β βββ controllers/
β β βββ opportunitiesHandler.js # Main query handler
β βββ middleware/
β β βββ heroku-service-mesh.js # Salesforce integration
β βββ routes/
β β βββ salesforce-routes.js # API routes
β βββ utils/
β βββ loggingUtil.js # Logging utilities
For a more detailed overview of the development & production dependencies, please check package.json.
To run this application locally, you will need the following:
- An active Salesforce account with Data Cloud
- Node.js version 20 or later installed (type
node -vin your terminal to check). Follow instructions if you don't have node installed - npm version 10.0.0 or later installed (type
npm -vin your terminal to check). Node.js includesnpm - git installed. Follow the instructions to install git
- A Heroku account
The first step is to clone the repository and install the project dependencies via a terminal interface by running the npm install in the server folder:
cd salesforce-agentforce-opportunity-tool/server
npm install
The second step is to create a .env file in the server folder. Find the .env.example file, copy it and rename it to .env.
cd salesforce-agentforce-opportunity-tool/server
cp .env.example .env
Edit the newly created .env files and update the variables with your account specific information.
# Heroku integration details
HEROKU_INTEGRATION_API_URL=
HEROKU_INTEGRATION_TOKEN=
Start the development server
npm run dev
In order to get the appropriate .env variables for local development and to make the Heroku AppLink integration actually work, please follow the setup guide.
Once all of this is done, your server will be available at http://localhost:3000
Once you are happy with your application, you can deploy it to Heroku!
To deploy the application to Heroku, please follow the official instructions.
This software is to be considered "sample code", a Type B Deliverable, and is delivered "as-is" to the user. Salesforce bears no responsibility to support the use or implementation of this software.



