Skip to content

πŸ’¬ Chatbot that Knows Your Documents (OpenRouter + Product Management Agent)

πŸ”€ Workflow: Chatbot that Knows Your Documents

This blog contains the Webhook + Retrieval-Augmented Generation (RAG) workflow for n8n, powered by OpenRouter’s deepseek-chat model. It demonstrates how prompt wording and topic specificity change the AI’s response β€” while adding a RAG tool for Product Management insights.


✨ Overview

This workflow expands the 201-basic pattern by introducing memory, OpenRouter free-tier LLM, and a RAG API tool for contextual answers. It creates a Product Management AI Agent that:

  • 🧠 Uses RAG for Product Management questions
  • πŸ’¬ Uses the LLM (deepseek-chat) for general or AWS-related questions
  • πŸ™… Politely declines out-of-scope or non-relevant questions
  • 🧍 Keeps short, simple replies (2–3 sentences), emphasizing clarity and prompt impact

πŸ”„ How It Works

graph LR
  A["🌐 Webhook (POST)"] --> B["🧠 AI Agent"]
  B --> C["πŸ€– OpenRouter Chat Model (deepseek-chat)"]
  B --> D["πŸ› οΈ RAG Tool (Product Management API)"]
  B <--> E["πŸ—‚οΈ Memory (sessionKey = username)"]
  B --> F["↩️ Respond to Webhook"]
  1. Webhook receives JSON (query, username).
  2. AI Agent decides how to respond:

  3. If the topic involves Product Management β†’ call the RAG Tool.

  4. Otherwise β†’ use the deepseek-chat model directly.
  5. For vague questions β†’ respond generally and guide users to be more specific.

  6. Memory Buffer (Window) stores short-term conversation context by username.

  7. Response Node returns the generated reply to the client.

πŸ›οΈ Architecture

Chatbot that Knows Your Documents


πŸ›‚ Inputs (JSON Body)

Field Type Required Description
query string βœ… User’s input message
username string 🟒 Recommended Session key for conversational memory

Example

{
  "query": "What are best practices for Product Managers when prioritizing features?",
  "username": "demo-user-1"
}

πŸ“€ Output

  • HTTP 200 OK with a short AI reply.
  • Reply style examples:

  • β€œ(Answer from Product Management knowledge base)” β€” via RAG Tool

  • β€œ(General or AWS-based answer)” β€” via model
  • β€œ(Out-of-scope polite refusal)” β€” for unrelated queries

βš™οΈ Setup

  1. Import 301-webhook-rag.json into your n8n Cloud workspace.
  2. Credentials β†’ Configure:

  3. πŸ”‘ OpenRouter API (create a free account at openrouter.ai)

  4. πŸ”‘ Optional: API key for the Traversaal Product Docs API (used by the RAG Tool)

  5. In the β€œRAG Tool” node, replace:

bash Authorization: your_traversaal_api_auth_brearer_token_here

with your actual bearer token.

  1. Activate the workflow and copy the Production Webhook URL (from the Webhook node).
  2. Optionally adjust the systemMessage inside the AI Agent node to modify tone or domain focus.

πŸ§ͺ Try It

  1. Open the instructor’s Colab notebook: 301 Webhook + RAG β€” Client (Colab)
  2. Click File β†’ Save a copy in Drive.
  3. Replace WEBHOOK_URL with your Production Webhook URL from n8n.
  4. Run all cells and test:

  5. 🧠 β€œWhat are best practices for Product Managers?”

  6. ☁️ β€œTell me about AWS S3 buckets.”
  7. πŸ™οΈ β€œWhat is the capital of France?”

πŸ’‘ Use the same username to maintain context; new names start fresh sessions.


Option B β€” cURL

WEBHOOK_URL="https://<your-n8n>/webhook/<id>"   # Use Production URL
curl -X POST "$WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  -d '{"query":"List key principles of Product Management","username":"demo-user-1"}'

Option C β€” Postman

  1. Create a POST request β†’ Production Webhook URL
  2. Body β†’ Raw β†’ JSON:

json { "query": "How can I improve sprint planning as a Product Manager?", "username": "demo-user-1" }

  1. Click Send β†’ view AI reply.

🧠 What to Notice (Teaching Points)

  • Demonstrates how prompt wording changes the model’s specificity.
  • Shows AI tool routing (LLM vs RAG) within a single workflow.
  • Highlights the benefit of contextual memory via sessionKey.
  • Provides a budget-friendly OpenRouter setup (deepseek-chat is free tier).
  • Encourages experimentation with tone and system instructions.

πŸ“š References


πŸͺ„ Learn how to chain OpenRouter, RAG, and custom APIs in your own workflows β€” the same pattern used here.


Don’t forget to check out my Agentic AI System Design for PMs course on Maven if you are interested to be a part of something bigger.

AI Bootcamp


➑️ Next