A complete ChatKit implementation with React frontend and Python FastAPI backend, containerized with Docker.
- Docker installed on your system
- OpenAI API key
- ChatKit workflow ID
- OpenAI domain key (for domain verification)
git clone [email protected]:mertz1999/SalesForce_demo.git
cd SalesForce_demoCreate a .env file in the root directory:
# Required: OpenAI API Key
OPENAI_API_KEY=your_openai_api_key_here
# Required: ChatKit Workflow ID
CHATKIT_WORKFLOW_ID=wf_your_workflow_id_here
# Required: OpenAI Domain Key (from domain allowlist)
OPENAI_DOMAIN_KEY=domain_pk_your_domain_key_here
# Optional: User ID
USER_ID=user_default_id
# Optional: Server Port
PORT=8000docker build -t chatkit-demo .# Run with environment file
docker run -p 8000:8000 --env-file .env chatkit-demo
# OR run with inline environment variables
docker run -p 8000:8000 \
-e OPENAI_API_KEY=your_openai_api_key \
-e CHATKIT_WORKFLOW_ID=wf_your_workflow_id \
-e OPENAI_DOMAIN_KEY=domain_pk_your_domain_key \
chatkit-demoOpen your browser and navigate to:
http://localhost:8000
- React Frontend: Modern chat interface using ChatKit web components
- Python Backend: FastAPI server for ChatKit session creation
- Single Container: Everything runs in one Docker container
- Health Checks: Built-in health monitoring
- CORS Support: Cross-origin requests enabled
- Security: Runs as non-root user
-
Frontend:
npm install npm start
-
Backend:
pip install -r requirements.txt python server.py
The Docker build process:
- Builds React app as static files
- Sets up Python environment
- Creates combined server that serves both API and frontend
- Configures health checks and security
OPENAI_API_KEY: Your OpenAI API key (required)CHATKIT_WORKFLOW_ID: Your ChatKit workflow ID (required)OPENAI_DOMAIN_KEY: Domain verification key (required)USER_ID: Default user ID (optional, defaults to "user_default_id")PORT: Server port (optional, defaults to 8000)
- Add your domain to OpenAI's domain allowlist
- Get your domain key from OpenAI dashboard
- Set
OPENAI_DOMAIN_KEYin your environment
- 401 Unauthorized: Check your
OPENAI_API_KEY - Domain verification failed: Ensure
OPENAI_DOMAIN_KEYis correct - Workflow not found: Verify
CHATKIT_WORKFLOW_ID - Container won't start: Check Docker logs for errors
The container includes a health check endpoint:
curl http://localhost:8000/api/healthView container logs:
docker logs <container_id>- Base Image: Python 3.11-slim with Node.js 18-alpine for building
- Port: 8000
- Health Check: Every 30 seconds
- User: Non-root for security
- Size: Optimized with multi-stage build
- Runs as non-root user
- Environment variables for secrets
- CORS configured for cross-origin requests
- Health checks for monitoring
- No secrets in image layers