Learn how you can use Harmonized Unstructured data with Data 360 and Agentforce.
This application demonstrates Salesforce Data Cloud's unstructured data harmonization capabilities integrated with Agentforce. It provides an interactive chat interface where users can query harmonized unstructured data through natural language conversations.
The demo showcases how Data Cloud can:
- Process and vectorize unstructured data chunks
- Store vectorized data as HTML objects with semantic search capabilities
- Enable Agentforce to retrieve relevant information with proper citations
- Provide transparent insights into AI-generated responses with metrics and source references
Data Processing Pipeline:
- Data Ingestion: Unstructured data is uploaded to Data Cloud
- Chunking: Data is split into manageable chunks for processing
- Harmonization: Each chunk is converted into an Harmonized Unstructured Data Lake Object (HUDLO)
- Storage: Vectorized data is stored as HTML objects in Data Cloud and mapped to Harmonized Unstructured Data Model Object (HUDMO)
- Retrieval: Agentforce uses RAG (Retrieval-Augmented Generation) to query relevant HUDMO
User Interaction Flow:
- User opens the chat widget and initiates an Agentforce session
- User sends natural language queries about the data
- Frontend generates HMAC-SHA256 signature for API authentication
- Backend validates the request and forwards it to Agentforce
- Agentforce retrieves relevant data using its internal logic
- Response includes the answer and response message metadata
- User can view detailed metadata
- You can fetch the underlying HTML used for the Agentforce response generation
The application exposes four RESTful endpoints, all protected by HMAC-SHA256 signature validation:
GET /api/v1/start-session
- Initializes a new Agentforce session
- Query Parameters:
sessionId(external session key) - Headers:
X-Timestamp,X-Signature - Returns:
{ sessionId, messages }(Agentforce internal session ID and welcome message)
POST /api/v1/send-message
- Sends a message to an active Agentforce session
- Headers:
X-Timestamp,X-Signature,Content-Type: application/json - Body:
{ sessionId, message, sequenceId } - Returns:
{ messages }(Array containing Agentforce response with metadata)
DELETE /api/v1/delete-session
- Terminates an active Agentforce session
- Headers:
X-Timestamp,X-Signature,Content-Type: application/json - Body:
{ sessionId } - Returns:
{ success: true }
POST /api/v1/get-hudmo
- Retrieves harmonized unstructured data model object (HUDMO) content
- Headers:
X-Timestamp,X-Signature,Content-Type: application/json - Body:
{ hudmoName, dccid }(HUDMO name and Data Cloud Content ID) - Returns:
{ data }(Harmonized HTML content with metadata and source URL)
Authentication: All requests require HMAC-SHA256 signature in headers:
X-Timestamp: Current timestamp in millisecondsX-Signature: HMAC-SHA256(API_SECRET, timestamp + method + path)
Client
- React - UI framework
- TypeScript - Type-safe JavaScript
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Component library
- Web Crypto API - HMAC-SHA256 signature generation
Server
- Node.js - JavaScript runtime
- Express - Web framework
- Salesforce Einstein Agentforce API v1 - AI agent integration
- OAuth 2.0 Client Credentials Flow - Salesforce authentication
- HMAC-SHA256 - Request signature validation
For a more detailed overview of the development & production dependencies, please check server package.json or client 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 Salesforce account enabled with Agentforce
-
Clone the repository
git clone https://github.com/mvrzan/salesforce-data-cloud-unstructured-harmonization.git cd salesforce-data-cloud-unstructured-harmonization -
Configure Server Environment Variables
Copy the example file and fill in your Salesforce credentials:
cd server cp .env.example .envEdit
server/.envwith your values:SALESFORCE_LOGIN_URL=https://your-instance.my.salesforce.com CLIENT_ID=your_salesforce_client_id CLIENT_SECRET=your_salesforce_client_secret AGENTFORCE_AGENT_ID=your_agentforce_agent_id API_SECRET=your_generated_secret_key
Generate a secure API secret:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" -
Configure Client Environment Variables
cd ../client cp .env.example .envEdit
client/.envwith the same API secret and local API URL:VITE_API_URL=http://localhost:3000 VITE_API_SECRET=your_generated_secret_key
⚠️ Important: TheAPI_SECRETon the server must matchVITE_API_SECRETon the client. -
Install Dependencies
Install server dependencies:
cd server npm installInstall client dependencies:
cd ../client npm install -
Start the Application
Start the server (from the
serverdirectory):npm run dev
In a new terminal, start the client (from the
clientdirectory):npm run dev
-
Access the Application
Open your browser and navigate to
http://localhost:5173
Once you are happy with your application, you can deploy it to Heroku!
Prerequisites:
- Heroku CLI installed
- Heroku account created
Deployment Steps:
-
Create a Heroku App
heroku create your-app-name
-
Set Environment Variables
Configure all required environment variables in Heroku:
heroku config:set SALESFORCE_LOGIN_URL=https://your-instance.my.salesforce.com heroku config:set CLIENT_ID=your_salesforce_client_id heroku config:set CLIENT_SECRET=your_salesforce_client_secret heroku config:set AGENTFORCE_AGENT_ID=your_agentforce_agent_id heroku config:set API_SECRET=your_generated_secret_key
-
Build and Deploy Client
Build the client with production environment variables. Set both the API URL (pointing to your Heroku app) and the API secret:
cd client VITE_API_URL=https://your-app-name.herokuapp.com VITE_API_SECRET=your_generated_secret_key npm run buildThe built files will be in
client/dist/and should be served by your server.Note: Make sure the
VITE_API_URLpoints to your Heroku app URL and theVITE_API_SECRETmatches theAPI_SECRETyou set in step 2. -
Deploy to Heroku
git push heroku main
-
Open Your App
heroku open
For more detailed deployment instructions, please follow the official Heroku documentation.
Security Note: When deploying publicly, be aware that the API_SECRET will be visible in the client bundle. For production use with external users, consider implementing additional security measures such as user authentication or IP whitelisting.
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.







