Skip to main content

Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter

Workflow preview

Workflow preview
100%
Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter preview
Open on n8n.io

1. Workflow Overview

WHAT IT DOES This workflow turns a plain JSON file sitting in a GitHub repository into a fully functional Telegram chatbot with retrieval augmented generation (RAG) — no Pinecone, no Qdrant, no vec...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.telegramtrigger, n8n-nodes-base.if, n8n-nodes-base.telegram, n8n-nodes-base.code, n8n-nodes-base.github, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.chainllm

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Do Thanh Vinh.

Original n8n.io source

1.1 Workflow description

Title
Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter
Workflow name
Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter

WHAT IT DOES

  • This workflow turns a plain JSON file sitting in a GitHub repository into a fully functional Telegram chatbot with retrieval-augmented generation (RAG) — no Pinecone, no Qdrant, no vector database, no extra subscription.

  • A user sends /ask <question> to your Telegram bot. The workflow pulls the knowledge base from GitHub, runs a local keyword-matching engine to find the most relevant chunks, feeds them as context to a Qwen 3 model via OpenRouter, and sends the answer back as a reply to the original message.

HOW IT WORKS

1. Telegram Trigger Listens for messages starting with /ask. Anything shorter than 7 characters is rejected with an error message explaining the correct format.

2. Input Validation If a user sends just /ask without a question, or sends a message shorter than 7 characters, the workflow catches it immediately and replies with a clear instruction: "Please use: /ask <your question>". This prevents unnecessary API calls to GitHub and the LLM, and teaches the user the correct format on the first try.

3. GitHub File Fetch Pulls a JSON file from a GitHub repository using a Personal Access Token. If the file doesn't exist or the token is invalid, the user gets a specific error message instead of a silent failure or a generic n8n error. Same applies when the LLM returns an empty response — the user always gets a message, never silence.

4. Binary Decode & Parse Reads the raw binary output from the GitHub node, decodes it to UTF-8, and parses the JSON array. Each entry in the array is expected to have a "text" field (other field names like "content", "answer", "title" also work).

5. Rough Keyword Match Splits the user's question into individual words, scores every knowledge base entry by counting how many words appear in it, and picks the top 2 matches. This is intentionally simple — no embeddings, no vector math, no external API calls for retrieval. It works well for small-to-medium knowledge bases (up to a few hundred entries) where exact keyword overlap is a reliable signal.

6. LLM Call (Qwen 3 via OpenRouter) Sends the matched context and the original question to Qwen 3 235B through OpenRouter. The prompt instructs the model to answer strictly from the provided context. If the context doesn't contain relevant information, the model says so instead of hallucinating.

7. Output Formatting Strips any thinking tags from the model response, capitalizes the first letter, enforces Telegram's 4000-character limit, and appends a branded footer.

8. Telegram Reply Sends the formatted answer as a reply to the user's original message, so conversations stay threaded.

WHY THIS APPROACH

  • Most RAG setups require a vector database, an embedding model, and ongoing infrastructure costs. This workflow skips all of that. The trade-off is precision — keyword matching won't catch semantic synonyms the way vector search does. But for knowledge bases that are focused on a specific topic (FAQ, product info, internal docs, local business info), keyword overlap is surprisingly effective and the setup cost is zero.

  • The LLM handles the fuzzy part. Even if the keyword match pulls in slightly noisy context, the model can usually extract the right answer. This division of labor - simple retrieval plus smart generation - keeps the workflow fast, cheap, and easy to maintain.

SETUP (5-10 minutes)

  1. Create a GitHub Fine-grained Personal Access Token with read access to the repository containing your knowledge base file.

  2. Add the GitHub credential in n8n and configure the "get gh file" node with your repository owner, name, and file path.

  3. Prepare your knowledge base as a JSON array: [ { "text": "your knowledge entry here" }, { "text": "another knowledge entry" } ]

  4. Add your Telegram Bot credential to all four Telegram nodes.

  5. Add your OpenRouter credential to the Qwen model node. You can swap Qwen for any model supported by OpenRouter by changing the model name field.

  6. Activate the workflow and send /ask <your question> to your Telegram bot.

CUSTOMIZATION

  • Swap the LLM: Change the model field in the "qwen model" node to any OpenRouter-compatible model (GPT-4o, Claude, Gemini, etc.). You can also point to a self-hosted model by changing the base URL.

  • Change retrieval depth: Edit the "rough match" node to return top 3 or top 5 chunks instead of 2. More chunks = more context for the LLM but higher token cost per request.

  • Add more knowledge: Just edit the JSON file on GitHub. The workflow fetches fresh data on every request — no redeployment needed.

  • Multi-language: The workflow works with any language in the knowledge base. The LLM will respond in the same language as the question.

WHAT'S NEXT

This workflow is designed as a foundation. The keyword matching engine works well for small knowledge bases, but here's where it can grow:

  • Vector search: Replace the rough keyword match node with an embedding-based retrieval step (OpenAI embeddings + Qdrant or Pinecone) for larger knowledge bases where keyword overlap isn't enough.

  • Multi-source KB: Pull from multiple GitHub files, Notion databases, or Google Sheets instead of a single JSON file.

  • Conversation memory: Add a short-term memory buffer so the bot remembers the last 3-5 messages in a conversation.

  • Web interface: Add a Webhook trigger alongside the Telegram trigger to serve a chat widget on any website.

  • Auto-sync: Watch the GitHub file for changes and rebuild the search index automatically instead of fetching on every request.

The current version is intentionally simple. Simple means it runs cheap, breaks rarely, and is easy to debug. Complexity can be added when the use case demands it.

REQUIREMENTS

  • n8n instance (self-hosted or cloud)
  • Telegram Bot token
  • GitHub Personal Access Token (fine-grained, read-only, scoped to the KB repository)
  • OpenRouter API key (or OpenAI-compatible endpoint)

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - When Message Received

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 9 - Validate Input

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 10 - Send Telegram Error

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 11 - Handle GitHub Error

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Send GitHub Error

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 13 - Fetch GitHub File

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 14 - Initialize Variables

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Perform Rough Match

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - OpenAI Qwen Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 17 - Request AI Assistance

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.9

Block 18 - Format AI Output

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 19 - Check AI Output

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 20 - Build Telegram Message

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 21 - Send Telegram Message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

3. Summary Table

Workflow Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter
Complexity advanced
Nodes 21
Categories Internal Wiki, AI RAG
Author Do Thanh Vinh
Published 09 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15570/15570.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Turn a GitHub knowledge base into a Telegram RAG bot with Qwen via OpenRouter do?

WHAT IT DOES This workflow turns a plain JSON file sitting in a GitHub repository into a fully functional Telegram chatbot with retrieval augmented generation (RAG) — no Pinecone, no Qdrant, no vec...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.