{
  "id": "hPCsJqWAybB64q2H",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Intelligent Voice Assistant for Email & Calendar Automation (Whisper API & AI Agent)",
  "tags": [],
  "nodes": [
    {
      "id": "50a8c242-3b8e-4cf6-8d9b-5a52f7bab9a2",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -160,
        416
      ],
      "parameters": {
        "updates": [
          "*"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e997cef-3a6f-4822-80c3-25b47dfabac1",
      "name": "Get a file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        64,
        416
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "92b651b8-c176-4fd9-95b0-8de8970ea9dc",
      "name": "Wisper API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        352,
        416
      ],
      "parameters": {
        "url": "http://whisper-api:9000/asr",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "name": "task",
              "value": "transcribe"
            },
            {
              "name": "language",
              "value": "en"
            },
            {
              "name": "output",
              "value": "json"
            },
            {
              "name": "audio_file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "a3ae6cae-10c9-4ed1-8a8c-fa661888d76c",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        960,
        -96
      ],
      "parameters": {
        "text": "=You are an Email Automation Assistant.\n\nConvert user instructions into a structured email.\n\nExtract:\n- recipient (email or role like HR/manager/client)\n- subject\n- professional email body\n\nRules:\n- Always be formal and professional\n- If recipient email is missing, assume role-based (HR, Manager, Support)\n- Do NOT send email, only prepare it\n- Keep body concise and clear\n\nInput:\n{{ $('Wisper API').item.json.data }}\n\nOutput ONLY JSON:\n{\n  \"to\": \"\",\n  \"subject\": \"\",\n  \"body\": \"\"\n}\nReturn ONLY valid JSON.\nNo markdown.\nNo explanation.\nNo comments.\nNo extra text.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "cc15df7a-52d4-43d6-97c6-5c809fb9a907",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        960,
        112
      ],
      "parameters": {
        "model": "phi3:mini",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dded48fa-1544-40d7-8aae-426144e937d8",
      "name": "Text Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        592,
        400
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $json.data }}",
        "categories": {
          "categories": [
            {
              "category": "SendEmail",
              "description": "if user wants to send an email"
            },
            {
              "category": "BookAnEvent",
              "description": "If user want to book/schedule an event on calender"
            },
            {
              "category": "Normal Query",
              "description": "everything else (questions, greetings, info, chat)"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "eba9106e-46cc-4888-bdf0-ab05b4dfedf2",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        944,
        784
      ],
      "parameters": {
        "text": "=You are a helpful voice assistant.\n\nRules:\n- Respond naturally like spoken conversation\n- Keep answers short and clear\n- If user asks technical questions, explain simply\n- If unclear, ask a short follow-up question\n\nInput:\n{{ $('Wisper API').item.json.data }}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "596dea72-2512-426b-86e1-e6c0d2299dc5",
      "name": "Ollama Model",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "position": [
        672,
        656
      ],
      "parameters": {
        "model": "phi3:mini",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "26f7537c-cc6e-4006-a9fd-817d7dfac5b9",
      "name": "Ollama Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        944,
        1008
      ],
      "parameters": {
        "model": "phi3:mini",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f354297d-01a7-40e6-a89e-37a13f4b95ef",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1296,
        800
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "forceReply": {
          "selective": true
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "978c200b-9f07-4a06-9278-f1ceac35b713",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1536,
        912
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b3f0c5c6-f0a8-401a-93ae-0d827a91cdcd",
      "name": "Send message and wait for response",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1520,
        -16
      ],
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "message": "=\ud83d\udce7 *Email Approval Required*\n\nPlease review the email below:\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udc64 *To:* {{ $json.to }}\n\n\ud83d\udcdd *Subject:* {{ $json.subject }}\n\n\ud83d\udce9 *Message:*\n{{ $json.body }}\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nDo you want to send this email?\n",
        "options": {
          "appendAttribution": false
        },
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "disapproveLabel": "\u274c Reprhrase Data"
          }
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0b934e00-3748-4d0a-bc14-54caa8ebd05c",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1744,
        -16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6f26c69f-80fe-4ab4-8fb3-bff39ffdeeb6",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved.toString() }}",
              "rightValue": "=true"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "f5bf368e-659d-441d-9a69-b6dd85c99bcc",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3200,
        -32
      ],
      "parameters": {
        "sendTo": "={{ $json.to }}",
        "message": "={{ $json.body }}",
        "options": {},
        "subject": "={{ $json.subject }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "62f77a41-d705-485d-b1b1-5550cedaa832",
      "name": "Send a text message1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3440,
        -32
      ],
      "parameters": {
        "text": "=\ud83d\udce8 Message sent successfully!\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udccc Subject: {{ $('Code in JavaScript').item.json.subject }}\n\ud83d\udce4 To: {{ $('Code in JavaScript').item.json.to }}\n\n\ud83d\udcac Body:\n{{ $('Code in JavaScript').item.json.body }}\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "forceReply": {
          "selective": true
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2ac04afc-9ac8-4ae1-b4c0-358953d4df0e",
      "name": "No Operation, do nothing2",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3648,
        -32
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ac3b3702-beda-4fd6-b3e5-f5f98451091b",
      "name": "Code in JavaScript1",
      "type": "n8n-nodes-base.code",
      "position": [
        1296,
        -16
      ],
      "parameters": {
        "jsCode": "let raw = $input.first().json.output;\n\n// remove markdown blocks if present\nraw = raw.replace(/```json/g, '').replace(/```/g, '').trim();\n\n// parse safely\nconst parsed = JSON.parse(raw);\n\nreturn [\n  {\n    json: parsed\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "9ff7dd6d-c9f0-4813-b519-720630d26b60",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        2928,
        -32
      ],
      "parameters": {
        "jsCode": "let raw2 = $('AI Agent2').first().json.output;\n\n// remove markdown if present\nraw2 = raw2.replace(/```json/g, '').replace(/```/g, '').trim();\n\n// parse safely\nconst parsed2 = JSON.parse(raw2);\n\nreturn [\n  {\n    json: parsed2\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "af87d6aa-6239-48cc-9efa-dcf42096ce86",
      "name": "Ollama Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        1984,
        288
      ],
      "parameters": {
        "model": "phi3:mini",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3e7701b1-ddb3-4f36-bf7e-a26e1374c7d8",
      "name": "Send message and wait for response1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2320,
        128
      ],
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "message": "=\u2728 Rephrased Email Ready\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udce4 To: {{ $json.to }}\n\n\ud83d\udccc Subject:\n{{ $json.subject }}\n\n\ud83d\udcac Body:\n{{ $json.body }}\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",
        "options": {},
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "disapproveLabel": "\u274c Cancel"
          }
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "201a86e7-04d3-49e6-ae46-328d26aa1a3e",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        2656,
        128
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6f26c69f-80fe-4ab4-8fb3-bff39ffdeeb6",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved.toString() }}",
              "rightValue": "=true"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ec8363db-4c89-47f0-a20b-ff0caea5f63a",
      "name": "No Operation, do nothing3",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2944,
        144
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9fa4ab03-fd68-4466-aaab-7c82a8bf7c66",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -192
      ],
      "parameters": {
        "color": 3,
        "width": 4032,
        "height": 1568,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "12330fa4-5b4d-4055-a5cb-d55633ef4578",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -336
      ],
      "parameters": {
        "width": 4032,
        "content": "# Turn voice messages into structured emails and calendar events with AI-powered automation and human approval via Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "716250cb-0cf5-4601-9e5a-7dbda2ef165d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -336
      ],
      "parameters": {
        "color": 6,
        "width": 624,
        "height": 1712,
        "content": "\n## \ud83e\udde0 Overview\n\nThis workflow is an AI-powered personal productivity assistant that converts voice or text inputs from Telegram into structured actions such as **email generation** and **calendar event scheduling**, using local LLMs (Ollama), speech-to-text (Whisper), and human-in-the-loop approval.\n\nIt acts as a unified assistant for communication and scheduling, enabling users to manage emails and calendar events directly through natural language voice commands.\n\n---\n\n## \u2699\ufe0f Workflow Capabilities\n\nThe system supports two core automation modes:\n\n### \ud83d\udce7 Email Automation\n- Converts voice into structured professional emails\n- Extracts recipient, subject, and body\n  \n- Sends for human approval before dispatch\n- Sends final email via Gmail\n\n---\n\n### \ud83d\udcc5 Calendar Automation\n- Converts user instructions into structured calendar events\n- Extracts title, date, time, duration, location, and description\n- Sends event details for approval via Telegram\n- Creates event after confirmation\n\n---\n\n## \ud83c\udfd7\ufe0f Workflow Architecture\n\n---\n\n## \ud83c\udfa4 1. Voice Input Capture (Telegram Trigger)\n\nUsers send voice messages or text instructions via Telegram.\n\n- Accepts natural language input\n- Supports both email and calendar requests\n- Acts as the entry point for the workflow\n\n---\n\n## \ud83c\udfa7 2. Speech-to-Text Processing (Whisper API)\n\nVoice messages are processed using Whisper ASR.\n\n- Converts audio \u2192 text\n- Ensures accurate transcription\n- Passes clean text to AI classification layer\n\n---\n\n## \ud83e\udde0 3. Intent Classification Layer (AI Router)\n\nThe system classifies user intent into:\n\n- \ud83d\udce7 Email Request\n- \ud83d\udcc5 Calendar Event Request\n- \ud83d\udcac General Conversation\n\nThis enables dynamic routing of tasks.\n\n---\n\n## \u2709\ufe0f 4. Email Generation Pipeline (AI Agent)\n\nIf intent = Email:\n\n- Extracts structured email fields:\n  - recipient\n  - subject\n  - body\n- Ensures professional tone and formatting\n- Outputs structured JSON\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "81ca840c-1f2f-4093-abcf-f00ca04e3357",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        192
      ],
      "parameters": {
        "width": 320,
        "height": 432,
        "content": "## Converts speech-to-text using Whisper ASR model. Outputs structured transcription for downstream AI processing."
      },
      "typeVersion": 1
    },
    {
      "id": "634715fb-906e-4390-a2dc-676a268975ee",
      "name": "Ollama Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        944,
        560
      ],
      "parameters": {
        "model": "phi3:mini",
        "options": {}
      },
      "credentials": {
        "ollamaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "4c7c0b82-609c-4907-bfbe-425e7bcfd14d",
      "name": "Code in JavaScript3",
      "type": "n8n-nodes-base.code",
      "position": [
        1296,
        464
      ],
      "parameters": {
        "jsCode": "let raw = $('AI Agent3').first().json.output;\n\n// 1. Remove markdown\nraw = raw.replace(/```json/g, '').replace(/```/g, '').trim();\n\n// 2. Find ALL possible JSON-like blocks\nconst candidates = raw.match(/\\{[\\s\\S]*?\\}/g);\n\nif (!candidates || candidates.length === 0) {\n  return [{\n    json: {\n      error: \"No JSON candidates found\",\n      raw\n    }\n  }];\n}\n\n// 3. Try parsing from LAST to FIRST (IMPORTANT)\nfor (let i = candidates.length - 1; i >= 0; i--) {\n  try {\n    const parsed = JSON.parse(candidates[i]);\n    return [{ json: parsed }];\n  } catch (e) {\n    continue;\n  }\n}\n\n// 4. fallback\nreturn [{\n  json: {\n    error: \"No valid JSON could be parsed\",\n    raw\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "589eac90-739f-4396-be55-24b43a0731c4",
      "name": "AI Agent3",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        944,
        336
      ],
      "parameters": {
        "text": "=You are a Calendar Event Automation Assistant.\nINPUT: {{ $json.data }}\nReturn ONLY valid JSON.\n\nCRITICAL RULES:\n- Output must be ONLY JSON\n- NO markdown (no ``` )\n- NO explanations\n- NO comments (// or /* */ are not allowed)\n- NO extra text before or after JSON\n- MUST be valid JSON parseable by JSON.parse()\n\nOutput format:\n{\n  \"title\": \"\",\n  \"date\": \"\",\n  \"time\": \"\",\n  \"duration\": \"\",\n  \"location\": \"\",\n  \"description\": \"\"\n}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "d21a04ee-97f3-44ab-8870-55b70d449ec6",
      "name": "AI Agent2",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1984,
        80
      ],
      "parameters": {
        "text": "=You are an email writing assistant.\n\nRewrite the email body to make it more natural, professional, and human-like.\n\nRules:\n- Keep the same meaning\n- Do not change the subject or recipient\n- Improve grammar and tone\n- Make it sound smooth and polite\n- Do NOT add extra information\n- Output ONLY JSON\n\nOutput ONLY JSON:\n{\n  \"to\": \"\",\n  \"subject\": \"\",\n  \"body\": \"\"\n}\nReturn ONLY valid JSON.\nNo markdown.\nNo explanation.\nNo comments.\nNo extra text.\nINPUT : {{ $('AI Agent').item.json.output }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "6b061be7-dcad-47e1-a84b-51fe28807706",
      "name": "Send message and wait for response2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1488,
        464
      ],
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "message": "=\ud83d\udcc5 Calendar Event Approval Required\n\nPlease review the event details below:\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\ud83d\udccc Title: {{ $json.title }}\n\n\ud83d\udcc6 Date: {{ $json.date }}\n\n\u23f0 Time: {{ $json.time }}\n\n\u23f1\ufe0f Duration: {{ $json.duration }} minutes\n\n\ud83d\udccd Location: {{ $json.location }}\n\n\ud83d\udcdd Description:\n{{ $json.description }}\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nDo you want to schedule this event in your calendar?",
        "options": {
          "appendAttribution": false
        },
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double"
          }
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6bd47346-682c-4968-b107-aa1d3a72952d",
      "name": "If3",
      "type": "n8n-nodes-base.if",
      "position": [
        1728,
        464
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6f26c69f-80fe-4ab4-8fb3-bff39ffdeeb6",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.approved.toString() }}",
              "rightValue": "=true"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "ca388d20-26db-49fe-81a2-87098176591f",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2912,
        448
      ],
      "parameters": {
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {}
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a84d39c6-fad5-4727-8431-475aa18d154e",
      "name": "Send a text message2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3168,
        448
      ],
      "parameters": {
        "text": "=\ud83d\udce8 Event Booked successfully!\n\n\ud83d\udcac Body:\n{{ $('Code in JavaScript2').item.json.body }}\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "forceReply": {
          "selective": true
        },
        "replyMarkup": "forceReply",
        "additionalFields": {
          "reply_to_message_id": "={{ $('Telegram Trigger').item.json.message.message_id }}"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cebc6e89-438b-4b54-86ae-185eea60a820",
      "name": "No Operation, do nothing4",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3440,
        448
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "23ddcd11-fe0f-4fd2-8f50-408b3b5656dd",
      "name": "No Operation, do nothing5",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2032,
        624
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "64779079-2ed9-454a-aa81-dcd881fcfab0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -176
      ],
      "parameters": {
        "height": 352,
        "content": "## Displays refined email to user for final confirmation before sending via Gmail."
      },
      "typeVersion": 1
    },
    {
      "id": "cbfb2d3b-aed0-4f94-995e-61c51b02e205",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        16
      ],
      "parameters": {
        "width": 352,
        "height": 384,
        "content": "## Displays refined email to user for final confirmation before sending via Gmail."
      },
      "typeVersion": 1
    },
    {
      "id": "f0cb8f4d-5123-45ba-955a-eae59d4aee80",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        304
      ],
      "parameters": {
        "height": 336,
        "content": "## Displays refined Data to user for final confirmation before scheduling."
      },
      "typeVersion": 1
    },
    {
      "id": "f3c7eb52-be24-4633-9e09-bb30f846cf5b",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        688
      ],
      "parameters": {
        "width": 1088,
        "height": 464,
        "content": "## Handles general conversational queries when intent is not email-related. Provides short, natural voice-style responses."
      },
      "typeVersion": 1
    },
    {
      "id": "d746ad22-1954-4c39-9ee6-67c165d70621",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3296,
        1184
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 192,
        "content": "##  \ud83e\uddea Known Risk Areas\n\n- LLM may return invalid JSON \u2192 handled by Code nodes\n- Whisper transcription may include noise \u2192 affects classification\n- Calendar date formats must be ISO-compliant\n- Telegram approval timeout may block workflow execution\n\nUse execution logs for debugging failures."
      },
      "typeVersion": 1
    },
    {
      "id": "e058d4ab-6bc7-4ffa-8691-b87d22439e9c",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 352,
        "content": "## Download audio files from Telegram"
      },
      "typeVersion": 1
    },
    {
      "id": "07a400f8-f2d0-43d7-b6a5-5abf24327672",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 352,
        "content": "## Classify audio based on extracted audio text"
      },
      "typeVersion": 1
    },
    {
      "id": "25fb1fc6-c5d1-468d-afcb-688d6d4fd225",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 288,
        "content": "## Extracts recipient, subject, and body"
      },
      "typeVersion": 1
    },
    {
      "id": "8184cb71-bfd3-435d-9ee5-83a3a6069e7d",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        224
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 352,
        "content": "## Extracts title, date, time, duration, location, and description"
      },
      "typeVersion": 1
    },
    {
      "id": "c2bcb3a3-f174-4edf-9f3d-a788069a324e",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        -128
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 352,
        "content": "##  Improves tone and grammar using LLM"
      },
      "typeVersion": 1
    },
    {
      "id": "2df7300c-81f1-4f40-97fa-c853e7072ab2",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3152,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 352,
        "content": "## Sends final email via Gmail"
      },
      "typeVersion": 1
    },
    {
      "id": "51ad7e4a-250b-4511-9df6-8447a883ae5f",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2816,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 352,
        "content": "## Creates event after confirmation\n"
      },
      "typeVersion": 1
    },
    {
      "id": "edbd2632-e4c2-476d-920b-be02a2ff7ce9",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2608,
        48
      ],
      "parameters": {
        "color": 4,
        "height": 272,
        "content": "## checking approved or rejected"
      },
      "typeVersion": 1
    },
    {
      "id": "8ebfa7a7-d44f-4085-ba93-71c67a23567e",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1712,
        -112
      ],
      "parameters": {
        "color": 4,
        "height": 272,
        "content": "## checking approved or rejected"
      },
      "typeVersion": 1
    },
    {
      "id": "6bd75cd2-ae24-43be-b349-08b6b5a489fe",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        368
      ],
      "parameters": {
        "color": 4,
        "height": 272,
        "content": "## checking approved or rejected"
      },
      "typeVersion": 1
    },
    {
      "id": "d5cb51fe-0522-4809-baad-3528d2a959c6",
      "name": "Sticky Note19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3376,
        -128
      ],
      "parameters": {
        "color": 4,
        "height": 272,
        "content": "## Success message"
      },
      "typeVersion": 1
    },
    {
      "id": "899f37ce-0f68-4d2a-8d7c-5fe93db678ce",
      "name": "Sticky Note20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3104,
        368
      ],
      "parameters": {
        "color": 4,
        "height": 272,
        "content": "## Success message"
      },
      "typeVersion": 1
    },
    {
      "id": "08a219e4-bdd8-4878-89f6-56bfe00ebec3",
      "name": "Sticky Note21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        -64
      ],
      "parameters": {
        "color": 6,
        "width": 192,
        "height": 208,
        "content": "## JSON Parser"
      },
      "typeVersion": 1
    },
    {
      "id": "3ad1c781-60ff-49b9-87aa-de808542e863",
      "name": "Sticky Note22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        400
      ],
      "parameters": {
        "color": 6,
        "width": 192,
        "height": 208,
        "content": "## JSON Parser"
      },
      "typeVersion": 1
    },
    {
      "id": "912497ad-9988-4d33-befc-190228cfe782",
      "name": "Sticky Note23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2896,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 192,
        "height": 208,
        "content": "## JSON Parser"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "ae42e794-10c3-4a16-9b06-08d7209e8e12",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If3": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent2": {
      "main": [
        [
          {
            "node": "Send message and wait for response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent3": {
      "main": [
        [
          {
            "node": "Code in JavaScript3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a file": {
      "main": [
        [
          {
            "node": "Wisper API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wisper API": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        [
          {
            "node": "Send a text message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        [
          {
            "node": "Send a text message2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "Send message and wait for response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript3": {
      "main": [
        [
          {
            "node": "Send message and wait for response2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message1": {
      "main": [
        [
          {
            "node": "No Operation, do nothing2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a text message2": {
      "main": [
        [
          {
            "node": "No Operation, do nothing4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response1": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send message and wait for response2": {
      "main": [
        [
          {
            "node": "If3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}