{
  "id": "X5xgTiDwTjqy8RqW",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Agent AI Calendar [n8n pro]",
  "tags": [],
  "nodes": [
    {
      "id": "01b29a4c-25cf-4c03-ab87-810f070d4be3",
      "name": "Create Event",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        640,
        340
      ],
      "parameters": {
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', `Cand se termina evenimentul`, 'string') }}",
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', `Cand incepe evenimentul`, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "additionalFields": {
          "description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}"
        },
        "useDefaultReminders": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Use_Default_Reminders', `Daca vrei sa folosesti reminderul defaul de la calendar sau vrei unul special`, 'boolean') }}"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "1758e2e3-e25d-4b1b-b57d-c711ec8553ce",
      "name": "Get events",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        760,
        340
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9092f4dd-1982-4bb7-94f9-7f29e4fec6ef",
      "name": "Update Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        880,
        340
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "update",
        "updateFields": {},
        "useDefaultReminders": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Use_Default_Reminders', ``, 'boolean') }}"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "738a78e0-6256-4827-aac9-9eaf7c6ae91c",
      "name": "Detele Event",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1000,
        340
      ],
      "parameters": {
        "eventId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Event_ID', ``, 'string') }}",
        "options": {},
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Calendar', ``, 'string') }}",
          "__regex": "(^[a-zA-Z0-9.!#$%&\u2019*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*)"
        },
        "operation": "delete"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "19674d23-67eb-46a1-a975-d64a64b6188a",
      "name": "Receive User Input (Telegram)\t",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -360,
        0
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0159ed56-542d-4fa1-867f-cba130466061",
      "name": "Is Voice Message?\t",
      "type": "n8n-nodes-base.if",
      "position": [
        -80,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c64b00ea-20f1-4d44-aed6-1528d537fc84",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.voice.mime_type }}",
              "rightValue": "audio/ogg"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "008051e4-e006-4f18-a204-f64b322a4da6",
      "name": "Download Voice File\t",
      "type": "n8n-nodes-base.telegram",
      "position": [
        140,
        -100
      ],
      "parameters": {
        "fileId": "={{ $('Receive User Input (Telegram)\t').item.json.message.voice.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e738c52a-d6b4-4fde-8dd8-2095db8eaf88",
      "name": "Transcribe Voice to Text\t",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        320,
        -100
      ],
      "parameters": {
        "options": {
          "language": "en"
        },
        "resource": "audio",
        "operation": "transcribe"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "5563f7c4-a87a-4728-a5ae-6e17ba59ff99",
      "name": "Extract Text Message\t",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        100
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "41b525e6-a59f-47c7-b6ee-2b88eaa386fe",
              "name": "Text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7ee11667-7834-464d-92e8-07be97f7f18a",
      "name": "AI Calendar Assistant (LangChain)\t",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        520,
        100
      ],
      "parameters": {
        "text": "=You're my personal digital assistant. Your purpose is to help me manage my personal calendar efficiently, taking into account priorities, work-life balance, and recurring events.\n\nToday is {{ $now }}\n\nInstructions:\n{{ $json.text }}\n{{ $json.Text }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "8651b116-a5eb-4e21-b03f-5375efb0d8ed",
      "name": "GPT-4 Language Model\t",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        360,
        340
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d014339d-7cb6-4bfe-bfbe-3f319a4fdf2c",
      "name": "Send Response to Telegram\t",
      "type": "n8n-nodes-base.telegram",
      "position": [
        940,
        100
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Receive User Input (Telegram)\t').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6c74e5a0-56dc-4fbf-8826-fb1b16d96504",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -740
      ],
      "parameters": {
        "width": 1600,
        "height": 140,
        "content": "## Global Workflow Description\n  \n**\"AI-Powered Calendar Assistant: Voice & Text Input \u2192 GPT-4 \u2192 Google Calendar\"**  \n\n*Explains:* Built using Telegram, OpenAI (Whisper + GPT-4), and Google Calendar to help users manage events through natural language input."
      },
      "typeVersion": 1
    },
    {
      "id": "5728ff55-e8c3-4b3f-9c85-0b111c1e18ec",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -480
      ],
      "parameters": {
        "height": 320,
        "content": "## Start / Input\n\n**\"Start: Listen for Telegram input (text or voice message)\"**  \n \n*Explains:* This node triggers the workflow when a user sends a message via Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "a2d2cdbf-ad34-4931-a4c9-ba79c89e09ac",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -480
      ],
      "parameters": {
        "width": 200,
        "height": 320,
        "content": "## Decision: Voice or Text\n \n**\"Check if the incoming message is a voice note (.ogg)\"**  \n\n*Explains:* If the message is a voice file, the workflow follows the transcription path. Otherwise, it processes the text directly."
      },
      "typeVersion": 1
    },
    {
      "id": "92b826ed-4189-4d0e-911a-48ae3b44c45e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -480
      ],
      "parameters": {
        "width": 300,
        "height": 320,
        "content": "## Voice Transcription\n \n**\"Download the voice file and transcribe it to text \"**  \n\n\n*Explains:* Uses OpenAI Whisper to convert voice messages to plain text."
      },
      "typeVersion": 1
    },
    {
      "id": "fbdcd510-14b6-4d50-8fd7-352b421ac8a4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        300
      ],
      "parameters": {
        "height": 240,
        "content": "## Text Extraction\n\n**\"Extract plain text from user\u2019s message (if no voice)\"**  \n\n*Explains:* Gets the written message text for further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "76874498-00dc-499f-9930-8f02e143ad8d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        500
      ],
      "parameters": {
        "width": 640,
        "height": 360,
        "content": "## AI Interpretation\n\n**\"Analyze user intent using GPT-4 and decide next calendar action\"**  \n\n*Explains:* AI determines whether the user wants to create, update, fetch, or delete a calendar event.\n\n## Google Calendar Actions\n\n**\"Perform the selected Google Calendar action (Create / Update / Fetch / Delete)\"**  \n\n*Explains:* Executes the action chosen by the AI assistant using dynamic values."
      },
      "typeVersion": 1
    },
    {
      "id": "7d55eed3-9715-4759-a806-e6d56e38f892",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        820,
        -220
      ],
      "parameters": {
        "width": 340,
        "height": 240,
        "content": "## Send Response\n\n**\"Send a confirmation or result message back to the user\"**  \n\n*Explains:* Closes the loop by replying with the output from the assistant."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bca5c9d1-8464-47a8-aa76-0b864ef17a3f",
  "connections": {
    "Get events": {
      "ai_tool": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create Event": {
      "ai_tool": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Detele Event": {
      "ai_tool": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update Calendar": {
      "ai_tool": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Is Voice Message?\t": {
      "main": [
        [
          {
            "node": "Download Voice File\t",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract Text Message\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Voice File\t": {
      "main": [
        [
          {
            "node": "Transcribe Voice to Text\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text Message\t": {
      "main": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Language Model\t": {
      "ai_languageModel": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe Voice to Text\t": {
      "main": [
        [
          {
            "node": "AI Calendar Assistant (LangChain)\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Response to Telegram\t": {
      "main": [
        []
      ]
    },
    "Receive User Input (Telegram)\t": {
      "main": [
        [
          {
            "node": "Is Voice Message?\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Calendar Assistant (LangChain)\t": {
      "main": [
        [
          {
            "node": "Send Response to Telegram\t",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}