All projects · AI Agents & RAG
Internal Agent — Router + KB (Puzzle 75)
A webhook-driven internal company assistant that uses a two-agent design: a routing LLM first decides whether a user's message needs the private…
A webhook-driven internal company assistant that uses a two-agent design: a routing LLM first decides whether a user's message needs the private knowledge base, then either runs a Gemini+Pinecone RAG lookup or passes straight through, before a grounded main agent answers and returns JSON over the webhook. It is the capstone that combines the router with the KB retrieval pattern.
- Two-agent architecture: a strict single-word KB / NO_KB routing classifier plus a separate grounded responder agent
- Conditional RAG via a Switch node — only messages needing company facts trigger the Gemini-embed + Pinecone-query branch; chit-chat takes a pass-through branch with empty context
- Decision-normalization Code node that hardens the classifier output (guards against 'KB' matching inside 'NO_KB')
- Anti-hallucination system prompt that forces the main agent to answer only from retrieved context when present, and both branches converge back into one Main Agent before the webhook JSON response
Built with: n8n Webhook (POST /internal-agent, responseNode mode), Set node message extraction, LangChain Agent nodes (@n8n/n8n-nodes-langchain.agent) x2, OpenAI chat models (lmChatOpenAi) x2, Switch node (KB vs NO_KB branching), Gemini embedding API + Pinecone /query via HTTP Request, Respond to Webhook (JSON)