AutomationFlowsSlack & Telegram › Telegram OpenAI AI Chat Bot

Telegram OpenAI AI Chat Bot

Original n8n title: Telegram AI Bot Template

Telegram AI Bot Template. Uses telegramTrigger, telegram, openAi. Event-driven trigger; 6 nodes.

Event trigger★★★★☆ complexityAI-powered6 nodesTelegram TriggerTelegramOpenAI
Slack & Telegram Trigger: Event Nodes: 6 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the OpenAI → Telegram recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Telegram AI Bot Template",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "telegram-trigger",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "message_text",
              "value": "={{ $json.message.text }}"
            },
            {
              "name": "user_id",
              "value": "={{ $json.message.from.id }}"
            },
            {
              "name": "username",
              "value": "={{ $json.message.from.username || $json.message.from.first_name }}"
            }
          ]
        },
        "options": {}
      },
      "id": "preprocess-message",
      "name": "Preprocess Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "system_prompt",
              "value": "You are a helpful AI assistant. Provide clear, concise, and accurate responses to user questions."
            },
            {
              "name": "temperature",
              "value": "0.7"
            },
            {
              "name": "max_tokens",
              "value": "500"
            }
          ]
        },
        "options": {}
      },
      "id": "bot-settings",
      "name": "Bot Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.3,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('preprocess-message').item.json.user_id }}",
        "action": "typing"
      },
      "id": "send-typing",
      "name": "Send Typing Action",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        900,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": "gpt-3.5-turbo",
        "messages": {
          "messageValues": [
            {
              "content": "={{ $('bot-settings').item.json.system_prompt }}",
              "role": "system"
            },
            {
              "content": "={{ $('preprocess-message').item.json.message_text }}",
              "role": "user"
            }
          ]
        },
        "options": {
          "temperature": "={{ $('bot-settings').item.json.temperature }}",
          "maxTokens": "={{ $('bot-settings').item.json.max_tokens }}"
        }
      },
      "id": "openai-chat",
      "name": "OpenAI Chat",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1.3,
      "position": [
        1120,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('preprocess-message').item.json.user_id }}",
        "text": "={{ $('openai-chat').item.json.choices[0].message.content }}"
      },
      "id": "send-response",
      "name": "Send Response",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1340,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Preprocess Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preprocess Message": {
      "main": [
        [
          {
            "node": "Bot Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bot Settings": {
      "main": [
        [
          {
            "node": "Send Typing Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Typing Action": {
      "main": [
        [
          {
            "node": "OpenAI Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat": {
      "main": [
        [
          {
            "node": "Send Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2025-01-27T00:00:00.000Z",
  "versionId": "1"
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Telegram AI Bot Template. Uses telegramTrigger, telegram, openAi. Event-driven trigger; 6 nodes.

Source: https://github.com/Zie619/n8n-workflows/blob/main/templates/communication/telegram-ai-bot-template.json — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

Auto-create and publish AI social videos with Telegram, GPT-4 and Blotato. Uses httpRequest, stickyNote, telegramTrigger, telegram. Event-driven trigger; 42 nodes.

HTTP Request, Telegram Trigger, Telegram +2
Slack & Telegram

This workflow handles customer order complaints submitted via Telegram by looking up order details in Google Sheets, using OpenAI to classify message sentiment, and routing each case to auto-approval,

Telegram Trigger, Google Sheets, Telegram +3
Slack & Telegram

This workflow handles COD order confirmation and abandoned-cart recovery by combining webhooks, Google Sheets logging, OpenAI message generation, and Telegram messaging with inline buttons, plus Slack

Telegram Trigger, Google Sheets, Telegram +3
Slack & Telegram

This workflow runs a Telegram restaurant ordering flow that uses OpenAI to parse orders and suggest an upsell, sends a Razorpay payment link, confirms paid orders via a Razorpay webhook, logs orders a

Telegram Trigger, OpenAI, Telegram +3
Slack & Telegram

This workflow handles dental clinic patient conversations in Telegram, using OpenAI to answer treatment-plan and general questions, logging bookings and payment plans in Google Sheets, sending automat

Telegram Trigger, Google Sheets, Telegram +3