AutomationFlowsAI & RAG › AI Telegram Assistant with OpenAI

AI Telegram Assistant with OpenAI

Original n8n title: Telegramassistant

telegramAssistant. Uses telegramTrigger, agent, lmChatOpenAi, memoryBufferWindow. Event-driven trigger; 17 nodes.

Event trigger★★★★☆ complexityAI-powered17 nodesTelegram TriggerAgentOpenAI ChatMemory Buffer WindowTelegramTool Serp ApiGmail ToolTool Calculator
AI & RAG Trigger: Event Nodes: 17 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow follows the Agent → Chainllm 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": "telegramAssistant",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -1248,
        16
      ],
      "id": "76aac8b2-be81-425b-b65b-34420036e757",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Reply the user message with your intelligence\n{{ $json.text }}\nName of the user {{ $('Telegram Trigger').item.json.message.chat.first_name }}",
        "options": {
          "systemMessage": "You are a helpful assistant, able to call the tool based on user requirements.\n\n1. serapi call this tool when user ask to check the latest data in the internet or current news do websearch\n\n2. gmail tool You are an AI assistant with access to a Gmail tool that allows you to compose, send, and manage emails. When interacting with Gmail, follow these guidelines:\nGmail Tool Usage\nWhen to Use the Gmail Tool\n\nUser explicitly requests to send an email\nUser asks to draft an email\nUser wants to compose a message to someone\nContext clearly indicates email communication is needed\n\nEmail Structure Guidelines\nWhen composing emails, structure them with the following components:\n1. Recipient Information\n\nto: Primary recipient email address(es)\ncc: Carbon copy recipients (optional)\nbcc: Blind carbon copy recipients (optional)\n\n2. Subject Line\n\nClear and concise (5-10 words ideal)\nIndicates the email's purpose\nProfessional and relevant to content\nExamples:\n\n\"Meeting Request: Q4 Planning Session\"\n\"Follow-up: Project Proposal Discussion\"\n\"Quick Question About [Topic]\"\n\n\n\n3. Email Body Structure\nGreeting:\n\nFormal: \"Dear [Name],\" or \"Hello [Name],\"\nSemi-formal: \"Hi [Name],\"\nCasual: \"Hey [Name],\"\n\nOpening:\n\nBrief context or pleasantry\nState purpose immediately if urgent\n\nBody:\n\nMain content organized in clear paragraphs\nUse bullet points for multiple items\nKeep paragraphs short (2-4 sentences)\nHighlight action items or key information\n\nClosing:\n\nSummary or call-to-action\nNext steps if applicable\nOffer for follow-up questions\n\nSign-off:\n\nFormal: \"Best regards,\" \"Sincerely,\" \"Kind regards,\"\nSemi-formal: \"Best,\" \"Thanks,\" \"Regards,\"\nCasual: \"Cheers,\" \"Talk soon,\"\n\n4. Signature\n\nSender's name\nTitle/position (if professional)\nContact information (optional)\nCompany name (if applicable)\n\nEmail Tone Guidelines\nAdapt tone based on context:\n\nProfessional/Formal: Business communications, first contacts, senior stakeholders\nSemi-formal: Regular work colleagues, professional acquaintances\nCasual: Close colleagues, informal situations, internal team communications\n\nFunction Call Format\ngmail_tool({\n  \"action\": \"send_email\",\n  \"parameters\": {\n    \"to\": \"recipient@example.com\",\n    \"cc\": \"cc@example.com\",\n    \"subject\": \"Clear Subject Line\",\n    \"body\": \"Formatted email content...\",\n    \"attachments\": [\"file1.pdf\", \"file2.docx\"]  // optional\n  }\n})\nBest Practices\n\nClarity: Be direct and clear about the purpose\nBrevity: Respect the recipient's time\nCourtesy: Maintain professional tone\nProofreading: Ensure correct grammar and spelling\nAction-oriented: Include clear next steps or requests\nContext: Provide enough background without over-explaining\n\nUser Confirmation\nBefore sending emails:\n\nShow the user the complete email draft\nConfirm recipient addresses are correct\nAsk for approval before sending\nAllow user to request modifications\n\nError Handling\nIf missing information:\n\nPolitely ask for required fields (recipient, subject, content)\nSuggest default values when appropriate\nClarify ambiguous requests\n\nPrivacy & Security\n\nNever send emails without explicit user consent\nConfirm sensitive information before including\nWarn about potential privacy concerns\nVerify recipient addresses carefully\n\nExample Workflow\nUser: \"Send an email to john@company.com about tomorrow's meeting\"\nAssistant Response:\n\nAcknowledge request\nAsk for missing details (meeting time, agenda, etc.)\nDraft email with proper structure\nShow draft to user\nRequest confirmation\nSend email using gmail_tool\nConfirm successful delivery\n\n\nTemplate Variations\nQuick Email Template\nTo: [recipient]\nSubject: [concise subject]\n\nHi [Name],\n\n[One sentence context]\n\n[Main message in 1-2 paragraphs]\n\n[Call to action or next steps]\n\nBest,\n[Your name]\nFormal Email Template\nTo: [recipient]\nSubject: [Professional subject line]\n\nDear [Title] [Last Name],\n\n[Introduction paragraph with context]\n\n[Body paragraphs with detailed information]\n\n[Closing paragraph with clear next steps]\n\n[Action items or requests, if any]\n\nThank you for your time and consideration.\n\nSincerely,\n[Full Name]\n[Title]\n[Contact Information]\nFollow-up Email Template\nTo: [recipient]\nSubject: Re: [Original Subject] - Follow-up\n\nHi [Name],\n\nI wanted to follow up on [previous topic/email sent on date].\n\n[Brief recap of previous communication]\n\n[New information or request]\n\nPlease let me know if you need any additional information.\n\nBest regards,\n[Your name]\n\nNotes\n\nAlways adapt the structure to the specific context and relationship\nCultural considerations may affect formality levels\nTime-sensitive emails should be marked appropriately\nConsider time zones when sending emails"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        64,
        16
      ],
      "id": "d057bf11-a0bd-4db7-9e3e-56e07ab14e52",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -128,
        240
      ],
      "id": "ce5014d5-60c7-4ca1-a7cd-54ae011aed55",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "=telgram_ {{ $('Telegram Trigger').item.json.message.chat.id }}"
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        0,
        240
      ],
      "id": "f3cd1826-6cae-45b5-a05f-2e5a78746827",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        656,
        -144
      ],
      "id": "546786b6-847f-4e64-aee7-becff405913e",
      "name": "Send a text message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "typeVersion": 1,
      "position": [
        128,
        240
      ],
      "id": "ffd80346-d737-412c-8854-dcf14bb8b7ba",
      "name": "SerpAPI",
      "credentials": {
        "serpApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        256,
        240
      ],
      "id": "d11c574b-949a-4b56-bd0e-e4d88e507fe0",
      "name": "Send a message in Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "typeVersion": 1,
      "position": [
        384,
        240
      ],
      "id": "566ed4b1-fa39-4a2c-98eb-b1926dc25906",
      "name": "Calculator"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "=",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "id": "c87e3455-378a-415e-ae89-5204fd388a15"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "voice"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "3872c635-ab28-42d0-9260-f250c3e9dc6d",
                    "leftValue": "={{ $json.message.text || ' ' }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.3,
      "position": [
        -1024,
        16
      ],
      "id": "6af55ce7-2510-46a7-a229-cc19bf27590a",
      "name": "Switch1"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "26a45a07-342f-41c4-9769-ad383e5561e5",
              "name": "text",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -352,
        112
      ],
      "id": "7c38fc20-f2d4-4cc5-9a29-81900ab3907a",
      "name": "Edit Fields1"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -800,
        -96
      ],
      "id": "d4c5ef1c-7e17-4732-89f4-8dc4066b4cae",
      "name": "Get a voice file",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {
          "language": "ta",
          "temperature": 0.8
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -576,
        -96
      ],
      "id": "e44e3404-1039-488d-98b8-f9c476f8c274",
      "name": "Transcribe a recording",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3ee8ac0f-a48f-4240-92fe-f26f2f3949b3",
              "name": "text",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -352,
        -96
      ],
      "id": "a6964be1-7694-4406-b263-c787cb533c55",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.output }}",
        "messages": {
          "messageValues": [
            {
              "message": "summarize the input with the high accuracy, ensuring clarity and conciseness. Focus on delivering a contextually rich summary for speech synthesis.  remove redundant phrases, introductory statements or closing remarks The oputput should be natural and engaging for an audio format"
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        592,
        160
      ],
      "id": "298d5071-19c4-4585-abb0-a44afeb3dfae",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        672,
        384
      ],
      "id": "ab8a2c50-4460-4f31-b4c3-3068e587ed5b",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendAudio",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1168,
        160
      ],
      "id": "79afe452-9127-45f2-a014-a3fbfd9c26d6",
      "name": "Send an audio file",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "input": "={{ $json.text }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        944,
        160
      ],
      "id": "d0880692-8d67-4a95-a723-ba9faaa7d460",
      "name": "Generate audio",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send a message in Gmail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Switch1": {
      "main": [
        [
          {
            "node": "Get a voice file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a voice file": {
      "main": [
        [
          {
            "node": "Transcribe a recording",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe a recording": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Generate audio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send an audio file": {
      "main": [
        []
      ]
    },
    "Generate audio": {
      "main": [
        [
          {
            "node": "Send an audio file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "351e5102-af87-45dc-a127-a96bf62a67e9",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "yY5eiFfC4xprsMZc",
  "tags": []
}

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

telegramAssistant. Uses telegramTrigger, agent, lmChatOpenAi, memoryBufferWindow. Event-driven trigger; 17 nodes.

Source: https://github.com/paari24/genAI/blob/30bfbd32b1e76049e3795e5e94449ce5c7a2d915/n8n/telegramAssistant.json — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

Telegram Trigger receives incoming messages (text, voice, photo, document). Switch routes by message type to appropriate processors: Text → forwarded as-is. Voice → downloaded and sent to Transcribe a

Memory Buffer Window, Telegram Trigger, Telegram +12
AI & RAG

Digital marketers, content creators, social media managers, and businesses who want to use AI marketing automation for YouTube Shorts without spending hours on production. This AI workflow helps anyon

OpenAI, HTTP Request, OpenAI Chat +7
AI & RAG

Jarvis is a powerful multi-agent productivity assistant built in n8n. It works directly from Telegram and can understand both text messages and voice notes.

Telegram Trigger, Telegram, OpenAI +10
AI & RAG

Unlock the Power of Language with Personalized AI Learning! MOTION TUTOR is a revolutionary AI-powered language learning platform that adapts to your progress and guides you from basic vocabulary to c

Agent, Airtable Tool, OpenAI Chat +6
AI & RAG

Automate your personal productivity with this intelligent n8n workflow that integrates Telegram, Google Sheets, and OpenAI (GPT-4o). This system uses multiple AI agents to manage work hours, tasks, fi

Agent, OpenAI Chat, Telegram +9