Documentation

Chat Client overview

An embeddable React + Socket.IO widget that talks to AppEngine's chat module.

The chat client is the front-end half of AppMint's customer-support and AI-assistant product. The widget renders a chat bubble in the corner of any web page, opens to a panel, and connects to AppEngine over Socket.IO.

How it ships

The chat-client repo (/Users/imzee/projects/chat-client) is private: true and has no exports field — there is no @appmint/chat npm package today. Delivery is a single CDN-hosted UMD bundle: https://web.appmint.space/chat-client/appmint-chat.js. The bundle exposes window.AppmintChat.init(config) which mounts the panel into a DOM container. Every install path on this site (vanilla, React, Next.js) is a small wrapper around that script tag.

What you get

  • Real-time messaging between a visitor and a live agent or AI assistant.
  • Typing indicators, presence, and read receipts.
  • File attachments via drag-and-drop.
  • Markdown-rendered messages with GitHub-flavoured syntax (tables, fenced code, task lists).
  • Emoji picker (emoji-mart).
  • Localised UI via react-i18next — English ships in src/locales/en/translation.json; add a folder per locale.
  • Two modes: a full chat experience (ChatApp) and a knowledge-base Q&A flavour (ChatQAApp).
  • Server-rendered variant (AppmintChatServer) for Next.js consumers that want the panel rendered on the server with its initial state hydrated.

Build outputs

The chat-client repo produces two outputs:

ModeBuild scriptOutputConsumer
Standalone app (canonical)yarn build (react-scripts + update-script-hashes.js)build/ static SPA + appmint-chat.jsThe CDN-hosted bundle every install path uses
Library bundle (experimental)yarn build:lib (Rollup)dist/bundle.js UMDCurrently unused outside local experiments — no consumer ships from dist/ today

Every install path on this site loads the standalone bundle from the CDN. There is no published npm package; integrations differ only in how they inject the script tag.

  • A static site, a CMS template, or Webflow — drop in the script tag.
  • A React or Vite app — wrap the script-tag pattern in a tiny client component. See the React integration.
  • Next.js App Router — use the same wrapper pattern, plus a server component that reads env vars on the server. See the yugo reference at /Users/imzee/projects/yugo/src/components/AppmintChat.tsx and Next.js integration.

How it talks to the platform

The widget bootstraps in three steps:

  1. Pulls a chat config from AppEngine — restHelper.getChatConfig({ orgId, configId, appId }). The config decides theming, availability windows, AI assistants, the welcome screen, and whether the conversation is gated by registration.
  2. Authenticates the visitor. For unauthenticated guests it creates a guest record (email-only) and stores { token, user } in localStorage under appmint-chat-session.
  3. Opens a Socket.IO connection to AppEngine's ChatGateway and joins the right rooms (visitor, conversation, broadcast).

From there every message, typing event, presence change, and AI streaming chunk flows over the socket. AppEngine routes messages to a queue, an assigned agent, or an AI assistant depending on the chat config.

The widget is the read/write surface only — every persisted message, attachment, and assignment lives in AppEngine. See AppEngine integration for the wire protocol.

Source layout

The repo lives at /Users/imzee/projects/chat-client/. Useful files:

  • src/index.tsx — script-tag entry. Exposes window.AppmintChatClient.init(container, config) — note the bundled global at the CDN is also accessible as window.AppmintChat via the wrapper conventions used in yugo.
  • src/chat-app.tsx — full chat panel.
  • src/chat-qa-app.tsx — Q&A-only variant.
  • src/chat-store.ts — Zustand store. Single source of truth for messages, presence, AI streaming, and queue state.
  • src/components/chat-socket.tsx — owns the socket connection and event subscriptions.
  • src/locales/ — translation JSONs.
  • rollup.config.mjs — library build config.
  • update-script-hashes.js — copies the hashed CRA bundle to a stable main.js for CDN consumers.

When to read which page