AutomationFlowsAI & RAG › Gmailassistent

Gmailassistent

Gmailassistent. Uses gmailTrigger, telegram, dataTable, telegramTrigger. Event-driven trigger; 47 nodes.

Event trigger★★★★★ complexityAI-powered47 nodesGmail TriggerTelegramData TableTelegram TriggerOpenAIGmail
AI & RAG Trigger: Event Nodes: 47 Complexity: ★★★★★ AI nodes: yes Added:
Gmailassistent — n8n workflow card showing Gmail Trigger, Telegram, Data Table integration

This workflow follows the Datatable → Gmail 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": "Gmailassistent",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "labelIds": [
            "UNREAD",
            "CATEGORY_PERSONAL"
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.4,
      "position": [
        0,
        -96
      ],
      "id": "1fc7aaeb-5a48-473f-b2eb-19ff543ee8ea",
      "name": "Gmail Trigger",
      "notesInFlow": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "notes": "Tracks new emails arriving "
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "={{ $json.chunkNumber === 1 ? 'Von: ' + $json.from + '\\nBetreff: ' + $json.subject + '\\n\\n' : '' }}{{ $json.totalChunks > 1 ? '(Teil ' + $json.chunkNumber + '/' + $json.totalChunks + ')\\n\\n' : '' }}{{ $json.chunkText }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1744,
        -112
      ],
      "id": "777caba0-27d2-4891-82ab-1ee960452975",
      "name": "Send a text message",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "draft_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.callback_query.message.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        624,
        512
      ],
      "id": "a3df78a6-988e-4134-8648-af4a705aea90",
      "name": "Get draft for sending"
    },
    {
      "parameters": {
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "from": "={{ $('Get full email text').item.json.headers.from.replace(/^From:\\s*/i, '') }}",
            "subject": "={{ $('Get full email text').item.json.subject.replace(/^Subject:\\s*/i, '') }}",
            "body": "={{ $('Remove quoted history from email').item.json.cleanBody }}",
            "email_id": "={{ $('Get full email text').item.json.id }}",
            "date": "={{ $now }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "schedule_prompt_message_id",
              "displayName": "schedule_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "scheduled_time",
              "displayName": "scheduled_time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "edit_prompt_message_id",
              "displayName": "edit_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1296,
        -112
      ],
      "id": "4a8f814d-6556-4e22-9c73-e1a0ad9be0c8",
      "name": "Save new email to database"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "telegram_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.message.reply_to_message.message_id }}"
            },
            {
              "keyName": "edit_prompt_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.message.reply_to_message.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1120,
        256
      ],
      "id": "c5d046a6-1115-4801-ad49-6a52d3fb08c7",
      "name": "Find email by notification ID",
      "notesInFlow": true,
      "notes": "Sucht in der Mail-Tabelle nach der Telegram-Benachrichtigungsnummer, um die Sprachantwort zuzuordnen."
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $('Gmail Trigger').item.json.id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "telegram_message_id": "={{ $('Ask user to reply here').item.json.result.message_id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2416,
        -112
      ],
      "id": "ab726c65-733e-486c-8719-9ccd5d22c20d",
      "name": "Save Telegram notification ID",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "updates": [
          "message",
          "callback_query"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.5,
      "position": [
        -64,
        224
      ],
      "id": "31c2fb34-b044-4955-a5df-638756e4d25c",
      "name": "Listen for voice or button press",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Responds to voice commands and button presses"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        560,
        208
      ],
      "id": "de17e267-7ca2-4586-9dcf-ec224123552a",
      "name": "Download voice file",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Downloads the audio file of a voice message from Telegram's servers"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        864,
        208
      ],
      "id": "3d5cb3f8-a1c7-45fa-b8ab-163acd8c8b83",
      "name": "Convert voice to text",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "8e92819e-10fb-4e39-969a-b38b3cf3e363",
              "leftValue": "={{ $json.message.voice }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        256,
        224
      ],
      "id": "e8b8d6d3-870e-4f41-9585-b6e1659df5a0",
      "name": "Check: voice or button?",
      "notesInFlow": true,
      "notes": "Splits the stream :1- voice message 2-  a button press"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1376,
        224
      ],
      "id": "9be9b0cc-9306-4879-8840-b7dc03c1e250",
      "name": "Combine email and voice data",
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "Du bist ein Assistent, der auf Deutsch professionelle E-Mails im Namen von [DEIN NAME] schreibt.\n\nWICHTIGE REGELN:\n\n1. STIL UND ANREDE:\nW\u00e4hle die passende Anrede basierend auf dem Empf\u00e4nger und dem Ton der vorherigen E-Mail:\n- \"Sehr geehrte Frau [Nachname],\" / \"Sehr geehrter Herr [Nachname],\" \u2013 f\u00fcr formelle, distanzierte Korrespondenz\n- \"Sehr geehrte Damen und Herren,\" \u2013 wenn kein konkreter Ansprechpartner bekannt ist\n- \"Liebe Frau [Nachname],\" / \"Lieber Herr [Nachname],\" \u2013 f\u00fcr halbformelle, bereits etwas pers\u00f6nlichere Korrespondenz\n- \"Guten Tag Herr/Frau [Nachname],\" \u2013 als neutrale Variante\n\nAnalysiere den Ton der vorherigen E-Mail (falls vorhanden), um zu entscheiden, ob \"Sehr geehrte\" oder \"Liebe\" passender ist.\n\n2. STRUKTUR DER E-MAIL:\n- Anrede (siehe oben)\n- Hauptteil: Formuliere den Inhalt, den die Nutzerin per Sprachnachricht mitgeteilt hat, in vollst\u00e4ndigen, h\u00f6flichen, professionellen S\u00e4tzen\n- Ein abschlie\u00dfender Satz vor dem Gru\u00df \u2013 je nach Kontext zum Beispiel: Dank f\u00fcr Unterst\u00fctzung, Vorfreude auf R\u00fcckmeldung, gute W\u00fcnsche f\u00fcr die Woche/das Wochenende\n- Gru\u00dfformel:\n  - \"Mit freundlichen Gr\u00fc\u00dfen\" \u2013 bei formeller Anrede (Sehr geehrte/r)\n  - \"Liebe Gr\u00fc\u00dfe\" \u2013 bei halbformeller Anrede (Liebe Frau/Lieber Herr)\n- Immer gefolgt vom Namen: [DEIN NAME]\n\n3. TON:\nFreundlich, respektvoll, klar und professionell. Nicht zu f\u00f6rmlich-steif, aber auch nicht zu locker.\n\n4. AUSGABEFORMAT:\nGib NUR den fertigen E-Mail-Text aus, ohne zus\u00e4tzliche Erkl\u00e4rungen, ohne Anf\u00fchrungszeichen, ohne Betreffzeile.\n\nBEISPIELE F\u00dcR DEN GEW\u00dcNSCHTEN STIL:\n\nBeispiel 1:\nLiebe Frau Meinert,\nvielen Dank f\u00fcr Ihre R\u00fcckmeldung und die Information \u00fcber meine Bewerbungsunterlagen.\nIch freue mich auf die weitere R\u00fcckmeldung zu meiner Bewerbung.\nIch w\u00fcnsche Ihnen einen guten Start in die neue Woche!\nMit freundlichen Gr\u00fc\u00dfen\n[DEIN NAME]\n\nBeispiel 2:\nSehr geehrter Herr Splettst\u00f6\u00dfer,\nvielen Dank nochmals f\u00fcr das freundliche Gespr\u00e4ch gestern und die M\u00f6glichkeit, mich pers\u00f6nlich kennenzulernen. Wie von Ihnen vorgeschlagen, habe ich mir die Ausbildung zur Elektronikerin f\u00fcr Betriebstechnik genauer angesehen.\nDabei habe ich festgestellt, dass ich mir diese Position ebenfalls gut vorstellen kann. Besonders interessant finde ich die Verbindung aus technischen Systemen, Fehlersuche sowie Programmierung und Steuerung von Anlagen. Gerade diese Kombination spricht mich an. Daher k\u00f6nnen Sie meine Bewerbung gerne auch f\u00fcr diese Ausbildungsstelle ber\u00fccksichtigen.\nIch freue mich auf Ihre R\u00fcckmeldung und w\u00fcnsche Ihnen eine angenehme Restwoche.\nMit freundlichen Gr\u00fc\u00dfen\n[DEIN NAME]\n\nBeispiel 3:\nSehr geehrte Frau Duro,\nvielen Dank f\u00fcr die Zusendung der Unterlagen und der Bildungsempfehlung.\nDie Weiterbildung ist f\u00fcr mich weiterhin sehr interessant.\nDer geplante Kursstart am 06.05.2026 \u00fcberschneidet sich jedoch mit meiner sprachlichen Qualifizierung, die noch bis 08.05 dauert.\nAus diesem Grund w\u00fcrde ich gerne mit dem Kursstart am 08.06.2026 beginnen.\nW\u00e4re es m\u00f6glich, mir die Bildungsempfehlung mit diesem neuen Starttermin auszustellen?\nGrundlegende Kenntnisse im Bereich Elektrotechnik bringe ich mit. Mein Abschluss im Bereich Telekommunikationstechnik wurde von der Zentralstelle f\u00fcr ausl\u00e4ndisches Bildungswesen (ZAB) mit der Entsprechung eines deutschen Hochschulabschlusses auf Bachelor-Ebene bewertet.\nVielen Dank im Voraus f\u00fcr Ihre Unterst\u00fctzung.\nMit freundlichen Gr\u00fc\u00dfen\n[DEIN NAME]\nWICHTIGER HINWEIS ZUR NAMENSANALYSE:\n\nUm den Namen der Ansprechperson f\u00fcr die Anrede zu bestimmen, gehe in dieser Reihenfolge vor:\n\n1. PRIORIT\u00c4T: Suche in der Unterschrift/Gru\u00dfformel am ENDE des E-Mail-Textes (body) der urspr\u00fcnglichen E-Mail (z.B. \"Mit freundlichen Gr\u00fc\u00dfen, Maria Schmidt\"). Dies ist oft die zuverl\u00e4ssigste Quelle.\n\n2. PARALLEL PR\u00dcFEN: Pr\u00fcfe auch das \"from\"-Feld auf einen erkennbaren Personennamen. In Deutschland enthalten gesch\u00e4ftliche E-Mail-Adressen oft den Namen der Person (z.B. \"maria.schmidt@firma.de\" oder \"m.schmidt@firma.de\") \u2013 das ist ein g\u00fcltiger Hinweis auf den Namen.\n\n3. UNTERSCHEIDE zwischen pers\u00f6nlichen und funktionalen Adressen:\n   - Pers\u00f6nliche Adresse (enth\u00e4lt erkennbaren Vor-/Nachnamen, z.B. \"j.mueller@firma.de\") \u2192 Name daraus verwenden, falls kein anderer Name in der Unterschrift zu finden ist.\n   - Funktionale/generische Adresse (z.B. \"karriere@firma.de\", \"info@firma.de\", \"noreply@firma.de\", oder technische Domains ohne erkennbaren Namen) \u2192 KEIN Name daraus ableiten; stattdessen auf die Unterschrift im Text (body) verlassen oder, falls auch dort kein Name zu finden ist, \"Sehr geehrte Damen und Herren,\" verwenden.\n\n4. BEI UNSICHERHEIT \u00dcBER DAS GESCHLECHT: Falls der Vorname geschlechtsneutral ist oder nicht eindeutig einer Anrede (Frau/Herr) zugeordnet werden kann, verwende den vollst\u00e4ndigen Namen ohne Anrede-Titel, z.B. \"Guten Tag Kim Fischer,\" anstelle von \"Sehr geehrte Frau/Sehr geehrter Herr\".\n\n5. FALLS GAR KEIN NAME AUFFINDBAR ist: Verwende \"Sehr geehrte Damen und Herren,\".\n\nVerwende f\u00fcr die Anrede immer den NACHNAMEN (Familienname), nicht nur den Vornamen, sofern der vollst\u00e4ndige Name verf\u00fcgbar ist."
            },
            {
              "content": "=Hier ist die urspr\u00fcngliche E-Mail, auf die geantwortet werden soll:\n\nVon: {{ $json.from }}\nBetreff: {{ $json.subject }}\nText: {{ $json.body }}\n\n{{ $json.draft_text ? \"Hier ist der vorherige Entwurf, der bereits erstellt wurde:\\n\\n\" + $json.draft_text + \"\\n\\nDie Nutzerin m\u00f6chte diesen Entwurf \u00dcBERARBEITEN (nicht komplett neu schreiben). Behalte den bestehenden Text so weit wie m\u00f6glich bei und \u00e4ndere NUR das, was in der folgenden Sprachnachricht als \u00c4nderungswunsch genannt wird.\" : \"Dies ist eine neue Anfrage ohne vorherigen Entwurf. Erstelle die E-Mail komplett neu basierend auf der folgenden Sprachnachricht.\" }}\n\nHier ist die Sprachnachricht (transkribiert):\n\n{{ $json.text }}\n\nBitte formuliere basierend darauf eine vollst\u00e4ndige, professionelle E-Mail auf Deutsch gem\u00e4\u00df den oben genannten Regeln."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2.3,
      "position": [
        1584,
        224
      ],
      "id": "41e2ec38-0ea5-48dc-8e1b-23c040ef24c5",
      "name": "Generate German email draft",
      "notesInFlow": true,
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Generates a complete email in German based on a letter and a voice response"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $('Find email by notification ID').item.json.email_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "draft_message_id": "={{ $json.result.message_id }}",
            "draft_text": "={{ $json.result.text }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        2176,
        240
      ],
      "id": "296b19b2-25a1-4656-b893-e2a8243ecbf6",
      "name": "Save draft to database",
      "notesInFlow": true,
      "notes": "Saves the draft text and the message number to the Mail table"
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for voice or button press').item.json.message.chat.id }}{{ $('Listen for voice or button press').item.json.callback_query.from.id }}",
        "text": "={{ $json.output[0].content[0].text }}",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Send",
                    "additionalFields": {
                      "callback_data": "send"
                    }
                  },
                  {
                    "text": "Edit",
                    "additionalFields": {
                      "callback_data": "redo"
                    }
                  },
                  {
                    "text": "Senden planen",
                    "additionalFields": {
                      "callback_data": "schedule"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1936,
        224
      ],
      "id": "5a084876-0a2f-4d14-90e1-8daef151570c",
      "name": "Send draft to me for review",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Sends the generated draft to Telegram with Send/Edit/Schedule buttons"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "send",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Send"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "baed7724-5851-4a93-a679-b27b804ae015",
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "schedule",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Senden planen"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "945e886c-99ba-48b8-88b3-06cffa460050",
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "redo",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Edit"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "79f20036-7854-42b5-a983-a3042f7660ca",
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "tomorrow_8",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Tomorrow8"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "68c79f05-c8fe-4f73-aad2-7616932c2d1c",
                    "leftValue": "={{ $json.callback_query.data }}",
                    "rightValue": "nextbizday_8",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "NextBizDay8"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        256,
        672
      ],
      "id": "f6e6abc5-7f9c-47ac-a79c-419655831b18",
      "name": "Route by button choice",
      "notesInFlow": true,
      "notes": "Splits the stream based on the button pressed: Send / Schedule / Redo"
    },
    {
      "parameters": {
        "sendTo": "={{ $json.from }}",
        "subject": "=  Re: {{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.draft_text }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        912,
        512
      ],
      "id": "b9ee9478-0bc8-40f0-9fd9-0a2a937f0869",
      "name": "Send final email to recipient",
      "notesInFlow": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "notes": "Sends the completed email to the actual recipient via Gmail"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "draft_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.callback_query.message.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        640,
        720
      ],
      "id": "80116d5e-3f3a-489a-b63c-ce7c72ac1e89",
      "name": "Get draft for scheduling",
      "notesInFlow": true,
      "notes": "Finds the message and draft in the Mail table by message number, using the Send/Edit/Schedule buttons, to prepare a request to select a send time"
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for voice or button press').item.json.callback_query.from.id }}",
        "text": " Wann soll diese E-Mail versendet werden?",
        "replyMarkup": "inlineKeyboard",
        "inlineKeyboard": {
          "rows": [
            {
              "row": {
                "buttons": [
                  {
                    "text": "Morgen um 8:00 Uhr",
                    "additionalFields": {
                      "callback_data": "tomorrow_8"
                    }
                  },
                  {
                    "text": "n. W. 8:00 Uhr",
                    "additionalFields": {
                      "callback_data": "nextbizday_8"
                    }
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        880,
        720
      ],
      "id": "f54cf9ef-0056-459f-bcba-c65d461b1373",
      "name": "Ask for time choice",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Sends the user two time options for scheduling the email: tomorrow at 8:00 or next business day at 8:00"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $('Get draft for scheduling').item.json.email_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "schedule_prompt_message_id": "={{ $json.result.message_id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "schedule_prompt_message_id",
              "displayName": "schedule_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "scheduled_time",
              "displayName": "scheduled_time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1120,
        720
      ],
      "id": "73fc0e93-ddc0-4a07-abc6-e8552b642761",
      "name": "Save time-prompt message ID",
      "notesInFlow": true,
      "notes": "Saves the message ID of the time-choice prompt so we can later match the button press to the correct email"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "schedule_prompt_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.callback_query.message.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        432,
        1200
      ],
      "id": "18507cc0-53a2-46cf-8f9c-cff3f46a399d",
      "name": "Get email for time calculation",
      "notesInFlow": true,
      "notes": "Finds the email record using the time-choice prompt message ID"
    },
    {
      "parameters": {
        "jsCode": "const choice = $('Listen for voice or button press').item.json.callback_query.data;\n\nconst now = new Date();\nlet targetDate = new Date(now);\n\nif (choice === 'tomorrow_8') {\n  targetDate.setDate(now.getDate() + 1);\n} else if (choice === 'nextbizday_8') {\n  const dayOfWeek = now.getDay();\n  let daysToAdd = 1;\n  if (dayOfWeek === 5) {\n    daysToAdd = 3;\n  } else if (dayOfWeek === 6) {\n    daysToAdd = 2;\n  } else if (dayOfWeek === 0) {\n    daysToAdd = 1;\n  }\n  targetDate.setDate(now.getDate() + daysToAdd);\n}\n\n// We format the date in the \u201cyear-month-day\u201d format for a specific calendar day\nconst year = targetDate.getFullYear();\nconst month = String(targetDate.getMonth() + 1).padStart(2, '0');\nconst day = String(targetDate.getDate()).padStart(2, '0');\n\n// We use Luxon (built into n8n) to accurately determine 8:00 a.m. Berlin time,\n// with automatic adjustment for daylight saving time\nconst berlinTime = DateTime.fromObject(\n  { year: Number(year), month: Number(month), day: Number(day), hour: 8, minute: 0, second: 0 },\n  { zone: 'Europe/Berlin' }\n);\n\nreturn {\n  json: {\n    ...$input.item.json,\n    scheduled_time: berlinTime.toUTC().toISO()\n  }\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        1200
      ],
      "id": "25195c0e-ee26-4686-8e73-ebd70f345ba0",
      "name": "Calculate exact send date",
      "notesInFlow": true,
      "notes": "Calculates the exact date and time for sending based on the user's time choice (tomorrow or next business day, both at 8:00 AM)"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $json.email_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "scheduled_time": "={{ $json.scheduled_time }}",
            "status": "scheduled"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "schedule_prompt_message_id",
              "displayName": "schedule_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "scheduled_time",
              "displayName": "scheduled_time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        1040,
        1200
      ],
      "id": "09e0ce74-8936-4691-af2f-e4aa05f8f459",
      "name": "Save scheduled time to database",
      "notesInFlow": true,
      "notes": "Saves the calculated send date/time and marks the email status as 'scheduled'"
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for voice or button press').item.json.callback_query.message.chat.id }}",
        "text": "=\u2705 E-Mail wurde geplant f\u00fcr: {{ $('Calculate exact send date').item.json.scheduled_time.toDateTime().setZone('Europe/Berlin').toFormat('dd.MM.yyyy, HH:mm') }} Uhr",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1280,
        1200
      ],
      "id": "d68bfecd-6a9a-4bf2-80d1-eada9f624af5",
      "name": "Confirm scheduling to user",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Sends a confirmation message showing when the email is scheduled to be sent"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        64,
        -480
      ],
      "id": "54e8012c-6098-40f4-87e0-0b2d41f26d64",
      "name": "Daily check at 8 AM",
      "notesInFlow": true,
      "notes": "Runs every day at 8:00 AM to check for scheduled emails that are ready to be sent"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "matchType": "allConditions",
        "filters": {
          "conditions": [
            {
              "keyName": "status",
              "keyValue": "scheduled"
            },
            {
              "keyName": "scheduled_time",
              "condition": "lte",
              "keyValue": "={{ $now.toISO() }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        272,
        -480
      ],
      "id": "a0c7463e-7545-4c52-93f8-9eda3e65bfa1",
      "name": "Find emails ready to send",
      "notesInFlow": true,
      "notes": "Searches the Mail table for emails with status 'scheduled' whose scheduled_time has already passed"
    },
    {
      "parameters": {
        "sendTo": "={{ $json.from }}",
        "subject": "=Re: {{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.draft_text }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        480,
        -480
      ],
      "id": "4ec49c48-f35a-4863-8b79-ac77d53cfd3b",
      "name": "Send scheduled email",
      "notesInFlow": true,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "notes": "Sends the scheduled email to the original sender via Gmail"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $('Find emails ready to send').item.json.email_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "status": "sent"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "schedule_prompt_message_id",
              "displayName": "schedule_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "scheduled_time",
              "displayName": "scheduled_time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        688,
        -480
      ],
      "id": "0c199369-6735-4652-8c6c-716a93ff3b9d",
      "name": "Mark email as sent",
      "notesInFlow": true,
      "notes": "Updates the email status to 'sent' to prevent it from being sent again in future scheduled checks"
    },
    {
      "parameters": {
        "operation": "get",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "draft_message_id",
              "keyValue": "={{ $('Listen for voice or button press').item.json.callback_query.message.message_id }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1.1,
      "position": [
        560,
        944
      ],
      "id": "3223a631-5c6f-4222-b57d-f7fe40a72e86",
      "name": "Get draft for editing",
      "notesInFlow": true,
      "notes": "Finds the email and current draft in the Mail table using the draft message ID, when the user clicks Edit"
    },
    {
      "parameters": {
        "chatId": "={{ $('Listen for voice or button press').item.json.callback_query.message.chat.id }}",
        "text": "Bitte senden Sie eine Sprachnachricht mit den gew\u00fcnschten \u00c4nderungen f\u00fcr diesen Entwurf.",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        816,
        944
      ],
      "id": "d1567bf3-70e3-4903-966f-c5e0e5a86458",
      "name": "Ask for voice correction",
      "notesInFlow": true,
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "notes": "Asks the user to send a voice message describing the desired changes to the draft"
    },
    {
      "parameters": {
        "operation": "update",
        "dataTableId": {
          "__rl": true,
          "value": "WQ0ZhRccYS2HYFfm",
          "mode": "list",
          "cachedResultName": "Mail",
          "cachedResultUrl": "/projects/OUfn6GH4OQEc2SUs/datatables/WQ0ZhRccYS2HYFfm"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "email_id",
              "keyValue": "={{ $('Get draft for editing').item.json.email_id }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "edit_prompt_message_id": "={{ $json.result.message_id }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "telegram_message_id",
              "displayName": "telegram_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "from",
              "displayName": "from",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_text",
              "displayName": "draft_text",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "draft_message_id",
              "displayName": "draft_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "date",
              "displayName": "date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "schedule_prompt_message_id",
              "displayName": "schedule_prompt_message_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "scheduled_time",
              "displayName": "scheduled_time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "edit_prompt_message_id",
              "displayName": "edit_prompt_message_id",
   

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

Gmailassistent. Uses gmailTrigger, telegram, dataTable, telegramTrigger. Event-driven trigger; 47 nodes.

Source: https://github.com/smilikhihi/gmail-telegram-email-assistant/blob/main/workflow.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

This workflow acts as your personal inbox assistant. It automatically filters, classifies, and responds to incoming emails using AI, saving you from manually sorting through leads or inquiries 24/7.

OpenAI, Gmail Trigger, Google Sheets +3
AI & RAG

Email Automation. Uses gmailTrigger, textClassifier, lmChatOpenAi, openAi. Event-driven trigger; 13 nodes.

Gmail Trigger, Text Classifier, OpenAI Chat +5
AI & RAG

Alfred (funcional). Uses gmailTool, googleCalendarTool, gmail, embeddingsOpenAi. Event-driven trigger; 83 nodes.

Gmail Tool, Google Calendar Tool, Gmail +24
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

Agent IA Projet Client. Uses executeWorkflowTrigger, lmChatOpenAi, toolWorkflow, vectorStoreQdrant. Event-driven trigger; 79 nodes.

Execute Workflow Trigger, OpenAI Chat, Tool Workflow +16