Chat Message Flow
End-to-end flow for a single chatbot message — moderation, agent selection, RAG retrieval, tool execution, and streaming response from /api/chatbot/stream
End-to-end flow for a single chatbot message — moderation, agent selection, RAG retrieval, tool execution, and streaming response from /api/chatbot/stream
Technical architecture of the chatbot request pipeline — moderation, RAG retrieval, agent routing, tool calling, streaming response, and the LLM provider strategy (Claude primary / GPT-4o-mini fallback)
Definitive source of truth for the entire chatbot request lifecycle, from HTTP request arrival to response return. Every code path, every tool, every third-party call, every expected result. Generated 2026-04-02 from a full read of every file in the pipeline.
Durable reference for what makes a world-class agentic chatbot. Principles are permanent; vendor/model choices are pluggable and must be re-evaluated quarterly.
Diagnose chatbot problems — wrong responses, tools not saving, widget not loading, LLM errors — using Vercel logs, Supabase queries, and the RAG debug flow
Decision
End-to-end explanation of the ChurchWiseAI voice agent — body analogy, service map, call flow, and fallback chain
OpenAI text-embedding-3-small for all RAG vector embeddings (unified_rag_content), plus gpt-4o-mini as the chatbot LLM fallback when Claude is unavailable
How RAG queries work — embedding the user query, pgvector cosine search against unified_rag_content, theological lens filtering, and injecting results into LLM context
Regenerate OpenAI text-embedding-3-small vectors for unified_rag_content rows — identify rows with null embeddings, run the embedding script, and verify RAG search improves
How church denomination is mapped to a theological lens, and how that lens filters RAG results and adjusts vocabulary in chatbot and voice agent responses
Non-technical walkthrough of a complete voice call — from phone ring through greeting, RAG lookup, tool use, potential Care Agent handoff, and post-call DB writes
Step-by-step pipeline for each voice turn — noise filtering, moderation check, RAG retrieval, LLM inference, tool execution, and TTS output — implemented via on_user_turn_completed callbacks and call_handler.py utilities