Build a chatbot with Reinforced Learning Human Feedback (RLHF) and RAG
Who is this for? This template is designed for internal support teams, product specialists, and knowledge managers who want to build an AI-powered knowledge assistant with retrieval-augmented generation (RAG) and reinforcement learning from human feedback (RLHF) via Telegram. What problem is this workflow solving? Manual knowledge management and answering support queries can be time-consuming and error-prone. This solution automates importing and indexing official documentation into Mon
At a glance
Build a chatbot with Reinforced Learning Human Feedback (RLHF) and RAG is a ready-made n8n workflow you import as a workflow JSON file — no build required. It connects OpenAI, Telegram. It's free to download. Follow the 5-step import below to go live in minutes.
- Platform
- n8n
- Connects
- OpenAI, Telegram
- Modules
- 23
- Price
- Free
- Version
- v1.0

About this workflow
Who is this for? This template is designed for internal support teams, product specialists, and knowledge managers who want to build an AI-powered knowledge assistant with retrieval-augmented generation (RAG) and reinforcement learning from human feedback (RLHF) via Telegram. What problem is this workflow solving? Manual knowledge management and answering support queries can be time-consuming and error-prone. This solution automates importing and indexing official documentation into MongoDB vector search and enhances AI responses with Telegram-based user feedback to continuously improve answer quality. What these workflows do Workflow 1: Document ingestion & indexing - Manually triggered workflow imports product documentation from Google Docs. - Documents are split into manageable chunks and embedded using OpenAI embeddings. - Embedded document chunks are stored in MongoDB Atlas vector store to enable semantic search. Workflow 2: Telegram chat with RLHF feedback loop - Listens for user messages via Telegram bot integration. - Uses vector similarity search on MongoDB to retrieve relevant documentation chunks. - Generates answers with OpenAI GPT-4o-mini model using retrieval-augmented generation. - Sends answers back via Telegram and waits for user feedback (approval or disapproval). - Captures feedback, maps it as positive or negative, and stores it with the conversation data for future model improvement. Setup Setting up vector embeddings 1. Authenticate Google Docs and connect your Google Docs URL containing the product documentation you want to index. 2. Authenticate MongoDB Atlas and connect the collection where you want to store the vector embeddings. Create a search index on this collection to support vector similarity queries. 3. Ensure the index name matches the one configured in n8n (dataindex). 4. See the example MongoDB search index template below for reference. Setting up chat with Telegram RLHF 1. Create a bot in Telegram with @botFather using the /newbot command. 2. Connect the MongoDB database and search index used for vector search in the previous workflow. Also create two new collections in MongoDB Atlas: one for feedback and one for chat history. Create a search index for feedback, copying the provided template. 3. Configure the AI system prompt in the “Knowledge Base Agent” node, making sure it references all three tools connected (productDocs, feedbackPositive, feedbackNegative) as provided in the template prompt. Make sure - Product documentation and feedback collections must connect to the same MongoDB database. - There are three distinct MongoDB collections: one for product documentation, one for feedback, and one for chat history (chat history collection can be separate). - Telegram API credentials are valid and webhook URLs are correctly set up. MongoDB Search Index Templates Documentation Collection Index { "mappings": { "dynamic": false, "fields": { "id": { "type": "string" }, "text": { "type": "string" }, "embedding": { "type": "knnVector", "dimensions": 1536, "similarity": "cosine" }, "source": { "type": "string" }, "docid": { "type": "string" } } } } Feedback Collection Index { "mappings": { "dynamic": false, "fields": { "prompt": { "type": "string" }, "response": { "type": "string" }, "text": { "type": "string" }, "embedding": { "type": "knnVector", "dimensions": 1536, "similarity": "cosine" }, "feedback": { "type": "token" } } } }
How to import this n8n workflow
- 1
Download the workflow JSON file after purchase.
- 2
Open n8n → click the menu → Import from File.
- 3
Select the downloaded JSON and import.
- 4
Set up credentials for each node that requires them.
- 5
Click Execute Workflow to test, then activate.
Setup guide
Setup guide included
Purchase to unlock the full step-by-step guide
Related N8n workflows
Send automated email responses using ChatGPT and trigger new emails (seconds delay included)
Automatic news summarization & email digest with GPT-4, NewsAPI and Gmail
Transcribe audio files using OpenAI and send messages with Z-API
Google Play review intelligence with Bright Data & Telegram alerts
Summarise MS Teams channel activity for weekly reports with AI
AI-powered lead scoring with Salesforce, GPT-4o, and Slack with data masking
Query and monitor Shopify orders via Telegram bot commands
Competitor LinkedIn monitor with Airtop
Reviews
No reviews yet
Be the first to buy and share your experience.
Leave a review
Sign in to share your experience with this workflow.
Create a free account to purchase workflows.
- JSON blueprint — instant download
- Setup guide PDF included
- 5 downloads · valid 30 days
- Works with n8n
Need help setting this up?
Book a 3-hour live setup session with an Agility consultant.
- Configure live on Google Meet / Zoom
- Free follow-up if workflow has defects
- Platform expert assigned to you