Build a Telegram AI Chatbot with n8n and OpenAI

This workflow automates AI-powered responses on Telegram using n8n and OpenAI. It solves the challenge of providing instant, helpful, and engaging chatbot replies, saving time and enhancing user interaction.
telegramTrigger
lmChatOpenAi
agent
+1
Workflow Identifier: 1074
NODES in Use: Telegram Trigger, OpenAI Chat Model, AI Agent, Telegram

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow connects Telegram messages with OpenAI AI to reply automatically.

When someone sends a message in a Telegram group, the system reads it, sends it to OpenAI, and gets a friendly answer with emojis.

Then, the answer goes right back to the same Telegram chat. This helps reply faster without people typing all the time.


Tools and Services Used

  • Telegram Bot API: Receives user messages and sends replies.
  • n8n Automation Platform: Ties nodes together to run the workflow.
  • OpenAI Chat Model (LangChain package): Creates AI chat replies from message text.

Inputs, Processing, and Outputs

Inputs

  • User text messages sent to the Telegram bot in a chat or group.

Processing Steps

  • Telegram Trigger listens for new messages from Telegram.
  • AI Agent sends the message text to the OpenAI Chat Model to get a reply.
  • The AI Agent forms a helpful, emoji-rich response.

Outputs

  • The Telegram node sends the AI response back to the chat as a message.

Who Should Use This Automation

Anyone who manages a Telegram chat where many questions repeat often can use this to save time.

This helps small teams or individuals reply faster without typing every answer manually.

No deep tech skills are needed once the workflow is imported and running.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Import the Workflow

  1. Download the workflow file using the Download button on this page.
  2. In the n8n editor, use the menu “Import from File” to load the workflow.

Step 2: Add API Credentials and Settings

  1. Open each node that requires credentials.
  2. Enter your Telegram Bot API Key in the Telegram Trigger and Telegram nodes.
  3. Add your OpenAI API Key in the OpenAI Chat Model node.
  4. If needed, update any chat IDs or channel details to match your target Telegram chat.

Step 3: Test the Workflow

  1. Send a message to your Telegram bot in the specified chat.
  2. Watch the workflow run inside n8n to check for errors.
  3. Confirm the bot replies with an AI generated message including emojis.

Step 4: Activate for Production Use

  1. Turn on the workflow inside n8n to run automatically.
  2. Make sure the Telegram bot webhook is set and valid so messages reach n8n.
  3. Monitor response times and logs to ensure smooth operation.

Customization Ideas

  • Change the AI Agent prompt to adjust the chatbot’s style.
  • In the AI Agent text parameter, edit the prompt for different tone like “professional and short”.
  • Add support for other Telegram updates such as edited messages or callback queries in the Telegram Trigger node.
  • Connect nodes to log conversation data for analysis, like Google Sheets or Airtable.

Troubleshooting Common Problems

No Messages Received in Telegram Trigger

Check the Telegram bot webhook setup.

Make sure the Telegram Bot API Key is correct and active.

AI Agent Returns No Output

Verify the AI Agent node prompt syntax uses {{ $json.message.text }} exactly.

Confirm the OpenAI Chat Model node is linked via the ai_languageModel connection.


Pre-Production Checklist

  • Verify Telegram Bot API Key validity and permissions.
  • Test Telegram webhook by sending test messages.
  • Ensure OpenAI API key has enough quota and no restrictions.
  • Confirm AI replies appear as expected in the test runs.
  • Activate the workflow only after the above checks pass.

Deployment Guide

Activate the workflow in n8n to make the chatbot live.

Check n8n execution logs during live message flows.

This workflow handles multiple Telegram chats well due to n8n’s event driven design.

For those who control their own servers, consider self-host n8n to keep full data privacy and control.


Key Prompt Example Used in AI Agent Node

The prompt tells AI to be helpful and use emojis.

=Respond to this as a helpful assistant with emojis: {{ $json.message.text }}

Summary of What You Get

✓ Automatic replies to Telegram messages that sound natural and friendly.
✓ Saves time so no more typing repeated answers.
✓ Near real-time responses to customer questions.
Easy to configure for your Telegram bot and OpenAI account.
✓ Scales nicely without needing extra staff for chatting.


Frequently Asked Questions

Verify that the Telegram bot webhook is set up correctly and the Bot API Key is valid.
Check the prompt syntax uses {{ $json.message.text }} properly and the OpenAI Chat Model node is linked correctly.
Yes, every processed message consumes OpenAI API credits according to account usage.
Yes, but Telegram Trigger and Telegram nodes must be replaced with nodes for other platforms like Slack or WhatsApp.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free