A simple application demonstrating Botpress Webchat integration with user authentication using admin keys.
- Node.js (v14 or higher)
- pnpm
Edit backend/server.js and update these values with your Botpress credentials:
const BOTPRESS_WEBCHAT_URL = "https://webchat.botpress.cloud";
const BOTPRESS_WEBCHAT_CLIENT_ID = "your-client-id";
const BOTPRESS_ADMIN_SECRET = "your-admin-secret";
const BOTPRESS_USER_KEY_EXPIRATION = Date.now() + 30_000;Edit frontend/index.html and update these values:
window.botpress.init({
botId: "your-bot-id",
clientId: "your-client-id",
// ...
});cd backend
pnpm installcd backend
pnpm startThe server runs on http://localhost:3000
Simply open frontend/index.html in your web browser
- Open the frontend in your browser
- Enter a username in the input field
- Press Enter or tab out of the field
- The Botpress webchat will initialize and you can start chatting
- The backend creates Botpress users and generates temporary access keys (30-second expiration)
- The frontend fetches user credentials from the backend and initializes the Botpress webchat
- Users are stored in memory (restarting the server clears all users)
GET /- Health checkGET /users/:username- Get or create a user and return their credentials