This guide shows you how to integrate Deep Chat with Salesforce Agentforce using the Agent API. With this setup, you can create a streaming chat interface that connects directly to your Salesforce agents.
npm install deep-chat<deep-chat
style="width: 100%; height: 600px; border-radius: 10px"
connect='{"url": "/api/salesforce/agentforce-stream", "stream": true}'
request-body-limits='{"maxMessages": -1}'
error-messages='{"displayServiceErrorMessages": true}'>
</deep-chat>- Salesforce org with Agentforce enabled
- At least one activated agent (not "Agentforce (Default)" type)
- See Salesforce Agent API Documentation
- Go to Setup > Apps > External Client Apps > Settings
- Turn on Allow creation of connected apps
- Click New Connected App
- Configure the app:
- Connected App Name: Choose a name for your app
- Contact Email: Your admin email
- Enable OAuth Settings: ✓
- Callback URL:
https://login.salesforce.com - OAuth Scopes: Add these scopes:
- Access chatbot services (chatbot_api)
- Access the Salesforce API Platform (sfap_api)
- Manage user data via APIs (api)
- Perform requests at any time (refresh_token, offline_access)
- Enable Client Credentials Flow: ✓
- Issue JSON Web Token (JWT)-based access tokens: ✓
- After saving, go to Manage > Edit Policies
- Set Permitted Users to appropriate users
- Set Run As to a user with API access
- Save the configuration
- Go to Setup > Agentforce Agents
- Select your agent
- Go to Connections tab
- Click Add and select your connected app
- Go to Setup > App Manager
- Find your connected app and click View
- Click Manage Consumer Details
- Copy the Consumer Key and Consumer Secret
- Get your My Domain URL from Setup > My Domain
Create a .env file with your Salesforce credentials:
SALESFORCE_INSTANCE_URL=https://yourdomain.my.salesforce.com
SALESFORCE_CLIENT_ID=your_consumer_key
SALESFORCE_CLIENT_SECRET=your_consumer_secret
SALESFORCE_AGENT_ID=your_agent_idnpm install-
Clone the repository:
git clone https://github.com/Think2Corp/deep-chat.git cd deep-chat/example-servers/sveltekit -
Install dependencies:
npm install
-
Configure environment variables: Create a
.envfile with your Salesforce credentials -
Start the development server:
npm run dev
-
Open your browser and navigate to the chat interface
You can customize the appearance of Deep Chat:
<deep-chat
connect='{"url": "/api/salesforce/agentforce-stream", "stream": true}'
style="width: 100%; height: 600px; border-radius: 10px;"
theme='{"colors": {"primary": "#0176D3"}}'>
</deep-chat><deep-chat
connect='{"url": "/api/salesforce/agentforce-stream", "stream": true}'
avatars='{"default": {"src": "agent-avatar.png"}, "user": {"src": "user-avatar.png"}}'>
</deep-chat>