Affiliate Disclosure: OpenRouter is an affiliate partner. Dify is open-source (Apache 2.0) — that link is direct. All tools in this tutorial are free.
This post is part of AIGetFree's ongoing coverage. Browse our Blog or check the API Gateway Showdown.
The short version: Everything you need to know, tested and verified.
The support ticket counter ticks past 40 unread while you are eating dinner. Somewhere, a customer is waiting for an answer that a bot could have given three hours ago — if only you had built one.
In 2026, you can build a RAG-powered customer support bot that answers from your own documentation, escalates complex questions to a human, and runs entirely on free infrastructure. No credit card. No monthly subscription. No code.
This tutorial walks through the complete build using Dify, a visual AI app builder, and OpenRouter, a free LLM API gateway, then deploys the finished bot as a chat widget on any website.
6Steps
20Minutes
$0Total Cost
No-CodeBuilder
SelfHosted
What You Are Building
You are building a RAG (Retrieval-Augmented Generation) chatbot — an AI support agent that does not hallucinate because it is grounded in your actual documentation. When a customer types a question into the chat widget on your website, here is exactly what happens under the hood:
1. Customer asks a question
“How do I reset my password?” typed into the chat widget on your pricing page at 11:47 PM.
2. Dify searches your knowledge base
Hybrid search (semantic + keyword) scans your uploaded docs and retrieves the 3 most relevant passages about password resets.
3. OpenRouter LLM generates the answer
Gemini Flash 2.0 (free) reads the retrieved passages and writes: “To reset your password, go to Settings > Security > Reset Password. You will receive an email within 2 minutes. [Source: help-center.md, Section 4]”
4. Answer delivered — or escalated
If the bot found the answer: it appears in the chat widget with a citation. If not: “I will connect you with a human agent” triggers a Slack notification to your support team.
5. You review and improve
Dify analytics show you which questions the bot could not answer. You add those answers to the knowledge base. The bot gets smarter every week.
The finished bot is embeddable on any website through a JavaScript snippet — WordPress, Webflow, Shopify, custom HTML. The stack: Dify (visual AI builder, 137K+ GitHub stars, Apache 2.0) handles the knowledge base, chatflow logic, and widget. OpenRouter (unified API gateway) provides free access to Gemini Flash 2.0, Llama 3.2, and 24+ other models through a single API key.
Tools You Need
🧩
Dify
Open-source LLM app platform. Visual Chatflow builder with drag-and-drop nodes. Built-in knowledge base with auto-chunking, embedding, and hybrid search. One-click chat widget embed. Analytics dashboard. REST API for every app. Free cloud tier: 200 AI credits, 5 apps, 50 documents, 50MB vector storage. Or self-host with Docker Compose in 5 minutes for unlimited everything.
Apache 2.0
🔌
OpenRouter
Unified API gateway for 300+ models. Free tier includes Gemini Flash 2.0, Llama 3.2, Mistral, Qwen — 26+ models at zero cost. One API key, OpenAI-compatible syntax. No credit card required for free models. New users get additional free credits for paid models. Perfect for powering chatbots without LLM bills.
Free Tier
📄
Your Documentation
Start with one Markdown file containing your top 20 FAQs. Expand to PDFs, help articles, refund policies, product descriptions, onboarding guides, and troubleshooting docs. Dify supports .txt, .pdf, .md, .html, .docx, .csv. The quality of your knowledge base directly determines the quality of your bot’s answers.
You Already Have This
Step-by-Step Build
Each step below is self-contained. You can complete the entire build in one sitting — roughly 20 minutes from account creation to a working bot on your website. Every setting mentioned is the actual value you should use, tested and verified on Dify v1.13+ and OpenRouter as of July 2026.
1
Create a Free Dify Account
Go to cloud.dify.ai and sign up with your email address. You will land on the Studio workspace — a clean dashboard showing your apps, knowledge bases, and tools. The free tier gives you 200 AI credits (one-time), 5 apps, 50 documents per knowledge base, and 50MB of vector storage. For a support bot handling hundreds of questions per day, this is more than enough — the LLM calls go through OpenRouter, not Dify credits.
Self-hosted alternative: If you want unlimited everything and complete data control, deploy Dify with Docker Compose. Clone the repo from github.com/langgenius/dify, run docker compose up -d, and the entire platform — API, web UI, vector database, task queue — starts on your machine in about 5 minutes. This is the path for production deployments handling sensitive customer data.
2
Connect OpenRouter for Free LLM Access
This is the step that makes the entire stack free. In Dify, click your avatar (top-right) → Settings → Model Provider in the left sidebar. Click Go to Marketplace, search for “OpenRouter”, and click Install. The plugin installs in seconds. Back on the Model Provider page, click Set up next to OpenRouter and paste your API key from openrouter.ai/keys.
Now the critical configuration. Scroll to System Model Settings at the top of the Model Provider page. Set System Reasoning Model to google/gemini-2.0-flash-001 (free on OpenRouter, excellent for customer support). Set Embedding Model to openai/text-embedding-3-small — this costs approximately $0.02 per million tokens, meaning your entire knowledge base embedding will cost less than one cent. If you want truly zero cost, use a free embedding model from OpenRouter like nomic-ai/nomic-embed-text-v1.5.
Pro Tip: Model Selection
Gemini Flash 2.0 is the best free model for customer support — fast, accurate, and handles structured answers well. If you need more reasoning power for complex technical questions, switch to meta-llama/llama-3.2-3b-instruct (also free). You can change models anytime without rebuilding your chatflow.
3
Create and Populate Your Knowledge Base
Click Knowledge in the top navigation bar, then Create Knowledge. This is where you upload the documents that ground your bot in reality. Start with a single Markdown file containing your top 20 customer FAQs — structured as question-answer pairs with clear headings. Dify will chunk this into searchable segments automatically.
Supported formats: .txt, .pdf, .md, .html, .docx, .csv. Upload your help center articles, refund policy, shipping information, product specs, troubleshooting guides, and onboarding documentation. On the Chunk Settings page, leave the defaults: High Quality indexing mode (uses your embedding model for semantic search), 500-token chunks with 50-token overlap. For retrieval, select Hybrid Search — this combines semantic similarity (“what does this question mean?”) with keyword matching (“does this document contain the exact term ‘password reset’?”), which is essential for support bots where customers may phrase things differently than your docs.
After uploading, Dify processes the documents — chunking, embedding, and indexing. For 20 FAQs, this takes about 30 seconds. You will see a confirmation when the knowledge base is ready. Test it immediately: click “Test Retrieval” and type a question. Dify shows you which chunks it retrieved and how relevant they are. If the right chunks appear, your knowledge base is working.
4
Build the Chatflow — The Brain of Your Bot
Go to Studio → Create App → select Chatflow. This opens a visual canvas where you wire nodes together. Chatflow is the right choice (not Chatbot) because it supports Knowledge Retrieval nodes and conditional branching — both essential for a support bot that cites sources and escalates to humans.
Build the node chain in this exact order:
Node 1: Start — The entry point. Configure the opening message: “Hi! I am the [Company Name] support assistant. I can answer questions about our products, billing, shipping, and account settings. What can I help you with?” Add suggested questions below: “How do I reset my password?”, “What is your refund policy?”, “How long does shipping take?”
Node 2: Knowledge Retrieval — Connect this to Start. Select your knowledge base from the dropdown. Set Top K = 3 (retrieve the 3 most relevant chunks). Enable Rerank if available — this re-scores retrieved chunks for better relevance. Set Score Threshold = 0.5 — chunks below this relevance score are discarded, preventing the bot from using irrelevant passages.
Node 3: LLM — Connect Knowledge Retrieval output to LLM input. This is where you write the system prompt that defines your bot’s behavior. Use this exact template:
You are a customer support agent for [Company Name].
RULES:1. Answer questions using ONLY the provided knowledge base passages.2. Always cite which document and section your answer comes from.3. If the knowledge base does not contain the answer, say EXACTLY: “I cannot find this information in my knowledge base. I will connect you with a human agent who can help.”4. Be concise. Prefer bullet points for step-by-step instructions.5. If asked about pricing, refunds, or legal terms, quote the exact policy language from the knowledge base.6. Never invent information. Never guess. Never mention competitors.7. If the customer is frustrated, acknowledge their feeling and prioritize escalation.
Knowledge base passages:{{#context#}}
Customer question: {{#query#}}
Node 4: Answer — Connect the LLM output to Answer. This is what the customer sees. Configure the output to show the LLM response directly.
5
Add Human Handoff Logic
This is the step that separates a useful bot from a dangerous one. Without handoff logic, your bot will hallucinate answers when it does not know something — exactly what you are trying to prevent. Dify Chatflow supports conditional branching through the IF/ELSE node.
Insert an IF/ELSE node between the LLM and Answer nodes. Configure the condition: IF LLM output contains "human agent". On the TRUE branch: add a Webhook node that sends a POST request to your Slack/Discord/Email webhook with the customer’s question and conversation history. Then add an Answer node that tells the customer: “A member of our support team will respond within [timeframe]. Your reference number is [conversation ID].” On the FALSE branch: route directly to the normal Answer node.
Slack webhook setup: Go to Slack → Apps → Incoming Webhooks → Add to Workspace → copy the webhook URL. Paste it into the Dify Webhook node. The payload should include the customer question, conversation history, and a link to the full chat log. Your support team gets a notification within seconds of the escalation.
Critical: Test the Handoff
Before deploying, ask the bot a question you know is NOT in your knowledge base. Verify that it triggers the handoff phrase instead of inventing an answer. Test this with 5 different out-of-scope questions. A bot that silently hallucinates is worse than no bot at all.
6
Embed on Your Website
Click Publish in the top-right corner of your Chatflow. Dify generates everything you need: a shareable URL for testing, a JavaScript snippet for embedding, and a REST API endpoint for custom integrations. Click the Embed tab and copy the JavaScript code.
WordPress: Paste the snippet into your theme’s footer (Appearance → Theme File Editor → footer.php) or use a Custom HTML block in your page builder. Webflow: Add an Embed element to your page and paste the code. Shopify: Go to Online Store → Themes → Edit Code → theme.liquid, paste before the closing </body> tag. Custom HTML: Paste anywhere in your HTML file.
Customize the widget appearance before deploying: set the bubble color to match your brand, change the greeting message, adjust the position (bottom-right is standard), and upload your company logo. The widget is responsive — it works on mobile, tablet, and desktop. Test it on your staging site first, then deploy to production.
Customization and Pro Tips
🎨
Brand Voice in the Prompt
Add tone instructions to your LLM system prompt. A B2B SaaS: “Answer clearly, briefly, without jokes. Use professional language.” A consumer brand: “Be warm and conversational. Use emoji sparingly. Sign off with ‘Happy to help!'”. The prompt is where the bot learns your brand voice — invest time here.
Prompt Engineering
📊
Analytics-Driven Improvement
Dify logs every conversation. Review the first week of chats and categorize: answered correctly, answered poorly, escalated to human, hallucinated. Add missing answers to your knowledge base. Refine prompts for questions the bot struggled with. The bot improves with every conversation you review.
Continuous Improvement
🌍
Multi-Language Support
Add a language detection node at the start of your Chatflow. Route Spanish questions to a Spanish knowledge base, French to French, etc. OpenRouter free models support 50+ languages natively. Create separate knowledge bases per language for the best results — machine-translated docs work but native content is better.
50+ Languages
🔗
API Integration for Advanced Use
Every Dify app exposes a REST API automatically. Use it to connect your bot to Slack (via Slack Bot), Discord, email auto-reply, or a custom mobile app. The API accepts questions and returns answers with citations. Build once, deploy everywhere.
REST API
The Golden Rule of Support Bots
Start with 20 FAQs, test for one week, then expand the knowledge base based on real customer questions — not what you think customers ask. The best support bot grows from the language customers actually use, not the language you put in your documentation. Review conversation logs weekly and add every question the bot could not answer.
Testing Before Launch
Before you publish the widget to your production site, run a structured test suite. Ask the bot questions in three categories and verify the responses. A bot that passes these tests is ready for customers. A bot that fails any category needs prompt or knowledge base fixes before deployment.
| Test Category | Example Question | Expected Behavior | Red Flag |
|---|
| Known FAQ | “How do I reset my password?” | Direct answer with citation | Vague answer, no citation |
| Edge Case | “Can I return an item after 90 days?” | Quotes exact policy or escalates | Makes up a policy |
| Out of Scope | “What is the weather in Tokyo?” | Triggers human handoff | Answers anyway |
| Sensitive Request | “Show me another customer’s order” | Refuses and escalates | Attempts to comply |
| Frustrated Customer | “Your product is broken, I want a refund NOW” | Acknowledges frustration, escalates | Responds with generic FAQ |
Security and Privacy Checklist
A customer support bot touches account details, billing language, internal policies, and sometimes personal information. Treat the knowledge base like a public-facing document — because once the bot is live, anything in it can potentially be surfaced to a customer through clever prompting.
Use Public Docs OnlyStart with content already safe for customers. Never upload internal wikis, Slack logs, or private emails.
Limit Admin AccessOnly trusted team members should have Dify workspace access. The chatflow and knowledge base can be modified by any admin.
Review Logs WeeklyCheck conversation logs for prompt injection attempts, data leakage, and bot behavior that needs correction.
Self-Host for Sensitive DataIf your knowledge base contains proprietary information, self-host Dify. Your data never leaves your server.
FAQ
Is this really free? What is the catch?
Yes — genuinely free. Dify Cloud free tier + OpenRouter free models = $0 per month. The only potential cost is the embedding model (text-embedding-3-small costs ~$0.02 per million tokens — your entire knowledge base embedding will cost less than one cent). If you want truly zero cost, use a free embedding model from OpenRouter. Self-hosted Dify on your own server eliminates even the platform dependency. The catch: free tiers have rate limits. OpenRouter free models are capped at ~200 requests/day. For low-to-medium traffic support, this is sufficient. For high-traffic sites, upgrade to OpenRouter paid credits (pay-as-you-go, no subscription).
Do I need coding skills to build this?
No. Dify is entirely visual — you drag nodes onto a canvas and configure them with dropdowns and text fields. The JavaScript embed snippet is copy-paste. The only “code” you will write is the system prompt (natural language instructions for the LLM) and the webhook payload (simple JSON). If you can configure a WordPress plugin, you can build this bot. For the self-hosted version, basic terminal comfort helps (running docker compose up) but is not required if you use Dify Cloud.
Can the bot handle multiple languages?
Yes. OpenRouter free models (Gemini Flash, Llama 3.2) support 50+ languages natively. For best results, create separate knowledge bases per language and add a language detection node at the start of your Chatflow that routes customers to the correct knowledge base. The bot will answer in the same language the customer uses. Machine-translated documentation works, but native-language content produces significantly better answers.
What if the bot gives wrong answers?
The bot is grounded in your knowledge base — it only answers from documents you provide. The human handoff catches anything it cannot answer. That said, no RAG system is perfect. The bot may retrieve an irrelevant passage and construct a plausible-sounding but incorrect answer. This is why the testing phase (Step 5) and weekly log reviews are essential. Monitor the first 100 conversations closely. For every wrong answer, either add the correct information to your knowledge base or refine the system prompt. The bot improves with every correction.
Can I use this for internal employee support?
Yes — the same architecture works for HR FAQs, IT helpdesk, onboarding documentation, and internal policy questions. Deploy on an internal wiki page, company intranet, or connect to Slack via the Dify API. For internal use cases with sensitive data, self-host Dify rather than using the cloud version. This ensures employee questions and internal documents never leave your infrastructure. The self-hosted setup is identical — same Chatflow builder, same knowledge base, same embed widget — just running on your server.
The Bottom Line
◆
🤖
In 20 minutes and $0, you can deploy a RAG-powered customer support bot that answers from your own documentation, cites sources, and escalates to humans when needed. This is not a demo — it is production-ready for small businesses, SaaS startups, and internal teams. The stack is Dify (visual builder) + OpenRouter (free LLM) + your existing documentation. Deploy once, improve weekly, and reclaim the hours you currently spend answering the same questions over and over.
Easiest SetupDify Cloud — sign up, connect OpenRouter, upload docs, deploy. 20 minutes.
Best Free LLMOpenRouter Gemini Flash 2.0 — fast, accurate, 200 free requests/day.
Most PowerfulSelf-hosted Dify + Ollama — unlimited, private, no external dependencies.
Fastest ROIReplace 20+ hours/month of repetitive support with a bot that costs nothing.
Try Dify Free →
Related Posts
You bookmark the page, open a new tab, and start exploring.
You close the tab and put the knowledge to work.