Glow is a structured AI chat system that powers conversational flows on Zooly. It enables guided, graph-based conversations where the AI assistant follows a defined flow (nodes and edges), uses context-specific tools, and can switch between different conversation contexts.
The Glow system enables:
changeChatContext and returnToContextEach flow is defined by GlowSettings:
backstage-mini-app, support)A GlowChat represents a chat session:
Each node in the flow has metadata:
systemInstructions)Tools are either:
askUserToUploadImage, askUserToChooseOptionWithBtns)glow_tool table with urlApi)The AI can only use tools specified in the current node's metadata.
┌─────────────────────────────────────────────┐
│ App (zooly-app) │
│ API routes: /api/glow-chat-client/* │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ @zooly/glow-server │
│ handleGlowChatStream, handleGlowChatCore │
│ handleGlowChatWithCache, getOrCreateGlowChat │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ @zooly/glow-client │
│ GlowChatClient, GlowAIProvider │
│ useGlowChat, TOOL_REGISTRY │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ @zooly/db │
│ glow_chat, glow_settings, glow_tool │
│ cached_answer_state, question_cache │
└─────────────────────────────────────────────┘
/api/glow-chat-client with messages and glowChatIdquestion_cache for similar questions via embedding similaritycached_answer_state, streams cached answer via cacheStreamingLLMhandleGlowChatCore:
glowSettings by glowCurrentSlugnodesMetadatastreamText with AI SDK (OpenAI GPT-4.1 by default)prepareStep / onStepFinish handle tool calls, moveToNodeId, changeChatContext, etc.useChat / GlowChatMessageQueueA special tool that updates currentNodeId when the flow transitions to a new node. The AI must call it before following the new node's instructions so that the correct tools are available.
Tools that switch the chat to a different flow (different glowCurrentSlug). Used for cross-flow navigation (e.g., "Go to support").
When enableCache is true, the system:
question_cache for similar questionsFor testing, mockStateId can be set on a chat to use @zooly/llm-mock instead of the real model, enabling deterministic or scripted responses.