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
Automate Telegram chat with n8n and OpenAI

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

Learn how to Build this Workflow with AI:

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.


Automate Telegram chat with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.