This is a custom chat interface implementation for the Agentforce Service Agent using Salesforce's Messaging for In-App and Web APIs using React + Typescript.
Note: You need to create a Custom Client deployment of your Service Agent to get your SALESFORCE_SCRT_URL
and SALESFORCE_DEVELOPER_NAME
. To build an agent:
- Create and deploy your agent. You can follow along with the codeLive: How To Set Up Agentforce Service Agent From Scratch Youtube tutorial or complete the Configure an Agentforce Service Agent Trailhead module.
- Create a Custom Client. Create a Custom Client using the messaging channel you created in Step 1.
- Node.js (v20.x)
- pnpm (v8.x)
- Salesforce org with Messaging for In-App and Web configured
- Clone and install dependencies:
git clone <repository-url>
cd <repository-url>
pnpm install
- Configure environment:
cd server
cp .env.example .env
- Update
.env
:
SALESFORCE_SCRT_URL=your-scrt-url
SALESFORCE_ORG_ID=your-org-id
SALESFORCE_DEVELOPER_NAME=your-developer-name
PORT=8080
- Start development:
# In server directory
pnpm dev
# In client directory (new terminal)
pnpm dev
Client runs at http://localhost:5173
, server at http://localhost:8080
Build and start:
pnpm build
pnpm start
agentforce-custom-client/
├── client/ # React frontend
├── server/ # Fastify backend
└── package.json # Workspace config
pnpm dev:client
- Start client in devpnpm dev:server
- Start backend in devpnpm build:client
- Build client and copy to serverpnpm build:server
- Build serverpnpm build
- Build bothpnpm start
- Start production server
Required in server/.env
:
SALESFORCE_SCRT_URL
- Salesforce SCRT URLSALESFORCE_ORG_ID
- Salesforce Org IDSALESFORCE_DEVELOPER_NAME
- Salesforce Developer NamePORT
- Server port (default: 8080)