Back to Integrations
integrationMongoDB node
integrationTelegram node

MongoDB and Telegram integration

Save yourself the work of writing custom integrations for MongoDB and Telegram and use n8n instead. Build adaptable and scalable Development, Data & Storage, Communication, and HITL workflows that work with your technology stack. All within a building experience you will love.

How to connect MongoDB and Telegram

  • Step 1: Create a new workflow
  • Step 2: Add and configure nodes
  • Step 3: Connect
  • Step 4: Customize and extend your integration
  • Step 5: Test and activate your workflow

Step 1: Create a new workflow and add the first step

In n8n, click the "Add workflow" button in the Workflows tab to create a new workflow. Add the starting point – a trigger on when your workflow should run: an app event, a schedule, a webhook call, another workflow, an AI chat, or a manual trigger. Sometimes, the HTTP Request node might already serve as your starting point.

MongoDB and Telegram integration: Create a new workflow and add the first step

Step 2: Add and configure MongoDB and Telegram nodes

You can find MongoDB and Telegram in the nodes panel. Drag them onto your workflow canvas, selecting their actions. Click each node, choose a credential, and authenticate to grant n8n access. Configure MongoDB and Telegram nodes one by one: input data on the left, parameters in the middle, and output data on the right.

MongoDB and Telegram integration: Add and configure MongoDB and Telegram nodes

Step 3: Connect MongoDB and Telegram

A connection establishes a link between MongoDB and Telegram (or vice versa) to route data through the workflow. Data flows from the output of one node to the input of another. You can have single or multiple connections for each node.

MongoDB and Telegram integration: Connect MongoDB and Telegram

Step 4: Customize and extend your MongoDB and Telegram integration

Use n8n's core nodes such as If, Split Out, Merge, and others to transform and manipulate data. Write custom JavaScript or Python in the Code node and run it as a step in your workflow. Connect MongoDB and Telegram with any of n8n’s 1000+ integrations, and incorporate advanced AI logic into your workflows.

MongoDB and Telegram integration: Customize and extend your MongoDB and Telegram integration

Step 5: Test and activate your MongoDB and Telegram workflow

Save and run the workflow to see if everything works as expected. Based on your configuration, data should flow from MongoDB to Telegram or vice versa. Easily debug your workflow: you can check past executions to isolate and fix the mistake. Once you've tested everything, make sure to save your workflow and activate it.

MongoDB and Telegram integration: Test and activate your MongoDB and Telegram workflow

University FAQ & calendar assistant with Telegram, MongoDB and Gemini AI

🤖 Interactive Academic Chatbot (Telegram + MongoDB)

Overview 📋

This project is a template for building a complete academic virtual assistant using n8n. It connects to Telegram, answers frequently asked questions by querying MongoDB, keeps the community informed about key dates (via web scraping), and collects user feedback for continuous improvement.

How It Works

Architecture and Workflow ⚙️

n8n: Orchestration of 3 workflows (chatbot, scraping worker, announcer).

Telegram: Frontend for user interaction and sending announcements.

MongoDB: Centralized database for FAQs, academic calendar, and feedback logs.

Web Scraping: HTTP Request and HTML Extract nodes to read the university's web calendar.

Cron: For automatic periodic executions (daily and weekly).

Core Processes 🧠

Real-time reception of user queries via Telegram.

Querying MongoDB collections for FAQ answers and calendar dates.

Daily scraping of the university website to keep the calendar updated.

Instant logging of user feedback (👍/👎) in MongoDB.

Proactive sending of weekly announcements to the Telegram channel.

Key Benefits ✅

Complete automation of student communication 24/7.

An always-accurate academic calendar database without manual intervention.

A built-in continuous improvement system through user feedback.

Proactive communication of important events to the entire community.

Use Cases 💼

Automation of student support in universities, colleges, and institutions.

A virtual assistant for any organization needing to manage FAQs and a dynamic calendar.

An automated announcements channel to keep a community informed.

Requirements 👨‍💻

n8n instance (self-hosted or cloud).

Credentials for a Telegram Bot (obtained from @BotFather).

Credentials for a MongoDB database (Connection URI).

URL of the academic calendar to be scraped.

Authors 👥
Doménica Amores
Nicole Guevara
Adrián Villamar
Mentor: Jaren Pazmiño

Applicants to the CIAP Polytechnic Artificial Intelligence Club

Nodes used in this workflow

Popular MongoDB and Telegram workflows

+4

University FAQ & Calendar Assistant with Telegram, MongoDB and Gemini AI

🤖 Interactive Academic Chatbot (Telegram + MongoDB) Overview 📋 This project is a template for building a complete academic virtual assistant using n8n. It connects to Telegram, answers frequently asked questions by querying MongoDB, keeps the community informed about key dates (via web scraping), and collects user feedback for continuous improvement. How It Works Architecture and Workflow ⚙️ n8n: Orchestration of 3 workflows (chatbot, scraping worker, announcer). Telegram: Frontend for user interaction and sending announcements. MongoDB: Centralized database for FAQs, academic calendar, and feedback logs. Web Scraping: HTTP Request and HTML Extract nodes to read the university's web calendar. Cron: For automatic periodic executions (daily and weekly). Core Processes 🧠 Real-time reception of user queries via Telegram. Querying MongoDB collections for FAQ answers and calendar dates. Daily scraping of the university website to keep the calendar updated. Instant logging of user feedback (👍/👎) in MongoDB. Proactive sending of weekly announcements to the Telegram channel. Key Benefits ✅ Complete automation of student communication 24/7. An always-accurate academic calendar database without manual intervention. A built-in continuous improvement system through user feedback. Proactive communication of important events to the entire community. Use Cases 💼 Automation of student support in universities, colleges, and institutions. A virtual assistant for any organization needing to manage FAQs and a dynamic calendar. An automated announcements channel to keep a community informed. Requirements 👨‍💻 n8n instance (self-hosted or cloud). Credentials for a Telegram Bot (obtained from @BotFather). Credentials for a MongoDB database (Connection URI). URL of the academic calendar to be scraped. Authors 👥 Doménica Amores Nicole Guevara Adrián Villamar Mentor: Jaren Pazmiño Applicants to the CIAP Polytechnic Artificial Intelligence Club
+2

N8N Automated Twitter Reply Bot Workflow

N8N Automated Twitter Reply Bot Workflow For latest version, check: dziura.online/automation Latest documentation can be find here You must have Apify community node installed before pasting the JSON to your workflow.  Overview This n8n workflow creates an intelligent Twitter/X reply bot that automatically scrapes tweets based on keywords or communities, analyzes them using AI, generates contextually appropriate replies, and posts them while avoiding duplicates. The bot operates on a schedule with intelligent timing and retry mechanisms. Key Features Automated tweet scraping** from Twitter/X using Apify actors AI-powered reply generation** using LLM (Large Language Model) Duplicate prevention** via MongoDB storage Smart scheduling** with timezone awareness and natural posting patterns Retry mechanism** with failure tracking Telegram notifications** for status updates Manual trigger** option via Telegram command Required Credentials & Setup 1\. Telegram Bot Create a bot via @BotFather on Telegram Get your Telegram chat ID to receive status messages Credential needed**: Telegram account (Bot token) 2\. MongoDB Database Set up a MongoDB database to store replied tweets and prevent duplicates Create a collection (default name: collection\_name) Credential needed**: MongoDB account (Connection string) Tutorial**: MongoDB Connection Guide 3\. Apify Account Sign up at Apify.com Primary actors used**: Search Actor: api-ninja/x-twitter-advanced-search - For keyword-based tweet scraping (ID: 0oVSlMlAX47R2EyoP) Community Actor: api-ninja/x-twitter-community-search-post-scraper - For community-based tweet scraping (ID: upbwCMnBATzmzcaNu) Credential needed**: Apify account (API token) 4\. OpenRouter (LLM Provider) Sign up at OpenRouter.ai Used for AI-powered tweet analysis and reply generation Model used**: x-ai/grok-3 (configurable) Credential needed**: OpenRouter account (API key) 5\. Twitter/X API Set up developer account at developer.x.com Note**: Free tier limited to ~17 posts per day Credential needed**: X account (OAuth2 credentials) Workflow Components Trigger Nodes 1\. Schedule Trigger Purpose**: Runs automatically every 20 minutes Smart timing**: Only active between 7 AM - 11:59 PM (configurable timezone) Randomization**: Built-in probability control (~28% execution chance) to mimic natural posting patterns 2\. Manual Trigger Purpose**: Manual execution for testing 3\. Telegram Trigger Purpose**: Manual execution via /reply command in Telegram Usage**: Send /reply to your bot to trigger the workflow manually Data Processing Flow 1\. MongoDB Query (Find documents) Purpose**: Retrieves previously replied tweet IDs to avoid duplicates Collection**: collection\_name (configure to match your setup) Projection**: Only fetches tweet\_id field for efficiency 2\. Data Aggregation (Aggregate1) Purpose**: Consolidates tweet IDs into a single array for filtering 3\. Keyword/Community Selection (Keyword/Community List) Purpose**: Defines search terms and communities Configuration**: Edit the JSON to include your keywords and Twitter community IDs Format:{   "keyword\_community\_list": \[     "SaaS",     "Entrepreneur",      "1488663855127535616"  // Community ID (19-digit number)   \],   "failure": 0 } 4\. Random Selection (Randomized community, keyword) Purpose**: Randomly selects one item from the list to ensure variety 5\. Routing Logic (If4) Purpose**: Determines whether to use Community search or Keyword search Logic**: Uses regex to detect 19-digit community IDs vs keywords Tweet Scraping (Apify Actors) Community Search Actor Actor**: api-ninja/x-twitter-community-search-post-scraper Purpose**: Scrapes tweets from specific Twitter communities Configuration:{   "communityIds": \["COMMUNITY\_ID"\],   "numberOfTweets": 40 } Search Actor Actor**: api-ninja/x-twitter-advanced-search Purpose**: Scrapes tweets based on keywords Configuration:{   "contentLanguage": "en",   "engagementMinLikes": 10,   "engagementMinReplies": 5,   "numberOfTweets": 20,   "query": "KEYWORD",   "timeWithinTime": "2d",   "tweetTypes": \["original"\],   "usersBlueVerifiedOnly": true } Filtering System (Community filter) The workflow applies multiple filters to ensure high-quality replies: Text length**: >60 characters (substantial content) Follower count**: >100 followers (audience reach) Engagement**: >10 likes, >3 replies (proven engagement) Language**: English only Views**: >100 views (visibility) Duplicate check**: Not previously replied to Recency**: Within 2 days (configurable in actor settings) AI-Powered Reply Generation LLM Chain (Basic LLM Chain) Purpose**: Analyzes filtered tweets and generates contextually appropriate replies Model**: Grok-3 via OpenRouter (configurable) Features**: Engagement potential scoring User authority analysis Timing optimization Multiple reply styles (witty, informative, supportive, etc.) <100 character limit for optimal engagement Output Parser (Structured Output Parser) Purpose**: Ensures consistent JSON output format Schema:{   "selected\_tweet\_id": "tweet\_id\_here",   "screen\_name": "author\_screen\_name",    "reply": "generated\_reply\_here" } Posting & Notification System Twitter Posting (Create Tweet) Purpose**: Posts the generated reply as a Twitter response Error handling**: Catches API limitations and rate limits Status Notifications Success**: Notifies via Telegram with tweet link and reply text Failure**: Notifies about API limitations or errors Format**: HTML-formatted messages with clickable links Database Storage (Insert documents) Purpose**: Saves successful replies to prevent future duplicates Fields stored**: tweet\_id, screen\_name, reply, tweet\_url, timestamp Retry Mechanism The workflow includes intelligent retry logic: Failure Counter (If5, Increment Failure Counter1) Logic**: If no suitable tweets found, increment failure counter Retry limit**: Maximum 3 retries with different random keywords Wait time**: 3-second delay between retries Final Failure Notification Trigger**: After 4 failed attempts Action**: Sends Telegram notification about unsuccessful search Recovery**: Manual retry available via /reply command Configuration Guide Essential Settings to Modify MongoDB Collection Name: Update collection\_name in MongoDB nodes Telegram Chat ID: Replace 11111111111 with your actual chat ID Keywords/Communities: Edit the list in Keyword/Community List node Timezone: Update timezone in Code node (currently set to Europe/Kyiv) Actor Selection: Enable only one actor (Community OR Search) based on your needs Filter Customization Adjust filters in Community filter node based on your requirements: Minimum engagement thresholds Text length requirements Time windows Language preferences LLM Customization Modify the AI prompt in Basic LLM Chain to: Change reply style and tone Adjust engagement criteria Modify scoring algorithms Set different character limits Usage Tips Start small: Begin with a few high-quality keywords/communities Monitor performance: Use Telegram notifications to track success rates Adjust filters: Fine-tune based on the quality of generated replies Respect limits: Twitter's free tier allows ~17 posts/day Test manually: Use /reply command for testing before scheduling Troubleshooting Common Issues No tweets found: Adjust filter criteria or check keywords API rate limits: Reduce posting frequency or upgrade Twitter API plan MongoDB connection: Verify connection string and collection name Apify quota: Monitor Apify usage limits LLM failures: Check OpenRouter credits and model availability Best Practices Monitor your bot's replies for quality and appropriateness Regularly update keywords to stay relevant Keep an eye on engagement metrics Adjust timing based on your audience's activity patterns Maintain a balanced posting frequency to avoid appearing spammy Documentation Links Full Documentation**: Google Doc Guide Latest Version**: dziura.online/automation MongoDB Setup Tutorial**: YouTube Guide This workflow provides a comprehensive solution for automated, intelligent Twitter engagement while maintaining quality and avoiding spam-like behavior.

Create and Manage Short URLs with Telegram Bot, MongoDB and Nginx Redirects

This workflow contains community nodes that are only compatible with the self-hosted version of n8n. This workflow allows you to create and manage custom short URLs directly via Telegram, with all data stored in MongoDB, and redirects handled efficiently via Nginx. How it works This flow provides a seamless URL shortening experience: Create via Telegram: Send a long URL to your bot. It will ask if you want a custom short code. Store in MongoDB: All long URLs and their corresponding short codes are securely stored in your MongoDB instance. Fast Redirects: When a user accesses a short URL, Nginx forwards the request to a dedicated n8n webhook, which then quickly redirects them to the original long URL. Set up steps This setup is straightforward, especially if you already have a running n8n instance and a VPS. Difficulty: Medium (Basic n8n/VPS knowledge required) Estimated Time: 15-30 minutes n8n Instance & VPS: Ensure you have n8n running on your VPS (e.g., 2 core 2GB, as you have). Telegram Bot: Create a new bot via @BotFather and get your Bot Token. Add this as a Telegram credential in n8n. MongoDB Database: Set up a MongoDB instance (either on your VPS or a cloud service like MongoDB Atlas). Create a database and a collection (e.g., url or short_urls). Add your MongoDB credentials in n8n. Here's MongoDB data structure JSON: >[ {"_id": "686a11946a48b580d72d0397", "longUrl": "https://longurl.com/abcdefghijklm/", "shortUrl": "short-code"} ] Domain/Subdomain: Point a domain or subdomain (e.g., s.yourdomain.com) to your VPS IP address. This will be your short URL base. Nginx/Caddy Configuration: Configure your web server (Nginx or Caddy) on the VPS to proxy requests from your short URL domain to the n8n webhook for redirects. (Detailed Nginx config is provided as sticky notes in the redirect workflow) Workflow Setup: Import both provided n8n workflows (Telegram URL Shortener Creator and URL Redirect Handler). Activate both workflows. Crucial: Set an environment variable in your n8n instance (or .env file) named SHORTENER_DOMAIN with the value of your short URL domain (e.g., https://s.yourdomain.com). Refer to sticky notes inside the workflows for detailed node configurations and expressions.
+7

Build a Multi-Modal Telegram AI Assistant with Gemini, Voice & Image Generation

How it works This workflow creates a multi-talented AI assistant named Simran that interacts with users via Telegram. It can handle text and voice messages, understand the user's intent, and perform various tasks. Step 1: Receive & Transcribe Input The workflow triggers on any new Telegram message. If it's a voice message, it uses AssemblyAI to transcribe it into text; otherwise, it processes the incoming text directly. Step 2: Understand User Intent Using a Large Language Model (LLM), the workflow analyzes the user's message to determine their goal, categorizing it as a general chat, a request to generate an image, a command to set a reminder, or a request to remember a specific piece of information. Step 3: Fetch Context & Route The assistant retrieves past conversation summaries from a MongoDB database to maintain context. Based on the user's intent, the workflow routes the task to the appropriate path. Step 4: Execute the Task Chat: Generates a response using an AI agent whose personality can be toggled between a standard assistant and a "Girlfriend Mode." It also analyzes the user's mood to tailor the response. Generate Image: Creates a detailed prompt and uses an image generation API to create and send a picture. Set Reminder: Parses the natural language request, creates an event in Google Calendar and a task in Google Tasks, and sends a confirmation. Remember Info: Saves specific user-provided information to a dedicated memory collection in MongoDB. Step 5: Respond and Save Memory The final output (text, voice message, or image) is sent back to the user on Telegram. The workflow then summarizes the interaction and saves it to the database to ensure continuity in future conversations. Set up steps Estimated Set up time: 20 - 30 minutes. Configure Credentials: You will need to add credentials for several services in your n8n instance: Telegram (Bot API Token) AssemblyAI (API Key) MongoDB Google (for Calendar, Tasks, Sheets, and Natural Language API) A Large Language Model (the workflow uses Google Gemini but can be adapted) An image generation service (the workflow uses the Together.xyz API) Set up External Services: Ensure your MongoDB instance has two collections: user_memory and memory_auto. Create a Google Sheet to manage the "Girlfriend Mode" status for different users. Ensure edge-tts is installed on the machine running your n8n instance for the text-to-speech functionality. Customize Nodes: Review the nodes with hardcoded IDs, such as Google Tasks and Google Sheets, and update them with your specific Task List ID and Sheet ID. The sticky notes inside the workflow provide more detailed instructions for specific nodes and segments.

Build your own MongoDB and Telegram integration

Create custom MongoDB and Telegram workflows by choosing triggers and actions. Nodes come with global operations and settings, as well as app-specific parameters that can be configured. You can also use the HTTP Request node to query data from any app or service with a REST API.

MongoDB supported actions

Create
Drop
List
Update
Aggregate
Aggregate documents
Delete
Delete documents
Find
Find documents
Find And Replace
Find and replace documents
Find And Update
Find and update documents
Insert
Insert documents
Update
Update documents

Telegram supported actions

Get
Get up to date information about a chat
Get Administrators
Get the Administrators of a chat
Get Member
Get the member of a chat
Leave
Leave a group, supergroup or channel
Set Description
Set the description of a chat
Set Title
Set the title of a chat
Answer Query
Send answer to callback query sent from inline keyboard
Answer Inline Query
Send answer to callback query sent from inline bot
Get
Get a file
Delete Chat Message
Delete a chat message
Edit Message Text
Edit a text message
Pin Chat Message
Pin a chat message
Send Animation
Send an animated file
Send Audio
Send a audio file
Send Chat Action
Send a chat action
Send Document
Send a document
Send Location
Send a location
Send Media Group
Send group of photos or videos to album
Send Message
Send a text message
Send and Wait for Response
Send a message and wait for response
Send Photo
Send a photo
Send Sticker
Send a sticker
Send Video
Send a video
Unpin Chat Message
Unpin a chat message

FAQs

  • Can MongoDB connect with Telegram?

  • Can I use MongoDB’s API with n8n?

  • Can I use Telegram’s API with n8n?

  • Is n8n secure for integrating MongoDB and Telegram?

  • How to get started with MongoDB and Telegram integration in n8n.io?

Need help setting up your MongoDB and Telegram integration?

Discover our latest community's recommendations and join the discussions about MongoDB and Telegram integration.
Trigi Digital
João Textor

Looking to integrate MongoDB and Telegram in your company?

Over 3000 companies switch to n8n every single week

Why use n8n to integrate MongoDB with Telegram

Build complex workflows, really fast

Build complex workflows, really fast

Handle branching, merging and iteration easily.
Pause your workflow to wait for external events.

Code when you need it, UI when you don't

Simple debugging

Your data is displayed alongside your settings, making edge cases easy to track down.

Use templates to get started fast

Use 1000+ workflow templates available from our core team and our community.

Reuse your work

Copy and paste, easily import and export workflows.

Implement complex processes faster with n8n

red iconyellow iconred iconyellow icon