# Total Chat — Implementation Guide # For AI agents, LLMs, and developer tools # Version: 2.0 | Updated: 2026-04-21 # Canonical URL: https://thetotal.chat/docs/llms.txt # HTML docs: https://thetotal.chat/docs # API base: https://totalchat-api.onrender.com ================================================================================ WHAT IS TOTAL CHAT ================================================================================ Total Chat is a screen-aware AI chat SDK for web applications. It embeds an AI assistant that understands the app's routes, features, and UI elements — and can navigate the app on behalf of users, run walkthroughs, and answer support questions from a curated knowledge base. Two operating modes: INTERNAL — for logged-in users. Full feature access: navigation, walkthroughs, element highlighting, knowledge base, bug routing. The AI knows what page the user is on and what features are available there. EXTERNAL — for pre-login visitors. Lead generation and product education. The AI explains the product, captures visitor emails, and routes leads to CRMs. No navigation tools, no account-specific data. MODE IS SERVER-ENFORCED. The client cannot select mode — the API determines it: - userId provided at conversation creation → INTERNAL - No userId → EXTERNAL Never pass a mode field. The server ignores it. ================================================================================ AUTHENTICATION ================================================================================ All API requests require a Bearer token in the Authorization header: Authorization: Bearer tc_YOUR_API_KEY API keys are obtained by registering your app (see ONBOARDING section). Keys are SHA-256 hashed at rest. The plaintext key is shown only once at registration. If lost, use the reset-key endpoint (admin only). Key format: tc_ followed by 64 hex characters. Example: tc_30bdc0a8251752d8d2aea945731721fb8bc2a910db08f1326b75b1694d342ef6 ================================================================================ ONBOARDING — REGISTER YOUR APP ================================================================================ POST /api/onboarding/register Required fields: appId string Unique identifier for your app (e.g. "myapp") appName string Display name (e.g. "My App") ownerEmail string Owner email address Optional fields: integrationMode "FULL" | "HEADLESS" | "EXTERNAL_ONLY" (default: "FULL") aiPersonality "friendly" | "professional" | "casual" (default: "friendly") escalationEmail string Email for human escalation bugRouteTarget string Agent Hub topic for bug routing Example request: curl -X POST https://totalchat-api.onrender.com/api/onboarding/register \ -H "Content-Type: application/json" \ -d '{ "appId": "myapp", "appName": "My App", "ownerEmail": "you@example.com", "integrationMode": "FULL", "aiPersonality": "friendly" }' Response: { "appId": "myapp", "apiKey": "tc_...", ← SAVE THIS. Never shown again. "appName": "My App", "integrationMode": "FULL", "endpoints": { ... }, "instructions": "..." ← Full step-by-step integration instructions } IMPORTANT: The apiKey is shown only once. Store it immediately as an environment variable. If lost, call POST /api/onboarding/:appId/reset-key with X-Internal-Key. ================================================================================ INTEGRATION — SCRIPT TAG (SIMPLEST) ================================================================================ Add before . Mode is determined server-side from user presence. External mode (no logged-in user): Internal mode (logged-in user — pass userId via JS after load): Available script tag attributes: data-app-id string required Your app ID data-position string bottom-right | bottom-left data-primary-color string Brand hex color (default: #6366f1) data-greeting string Opening message data-collect-email boolean Prompt for email in external mode (default: true) ================================================================================ INTEGRATION — NEXT.JS / REACT (RECOMMENDED FOR INTERNAL MODE) ================================================================================ Note: @totalchat/sdk npm package is coming in Phase 2. Until then, use the script tag with window.TotalChatConfig or direct API calls. Pattern for Next.js with user context: // In your root layout or providers component