{
  "name": "telegram2",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "88b53d3f-e90f-4d50-8197-d35cda54c661",
      "name": "Telegram Trigger",
      "webhookId": "5f3fe51b-27a9-41ba-927e-f00ea5ae79c2",
      "credentials": {
        "telegramApi": {
          "id": "sJmCCl04cDyvxGEp",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8d4b916c-d38a-455f-a10a-0c8e440bfe67",
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "audio"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        160,
        0
      ],
      "id": "6e397fb4-ebdd-44dc-98fa-40d71a909b3e",
      "name": "Switch"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e4145e69-b00c-43dc-bf65-7647a862fbe4",
              "name": "text",
              "value": "={{ $('Telegram Trigger').item.json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        340,
        -60
      ],
      "id": "b425fa18-a2fc-46f7-a1a2-5c01457e3ca3",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=# Role  \nYou are an assistant with access to multiple tools.  \n\n# Behavior  \nYou respond concisely and succinctly in a friendly and approachable style.\n\n# Date and Time: {{ $now }}\n\n# Tools  \nYou have access to multiple tools and always use the appropriate one depending on the task.  \n\n## Gmail_Summary  \nUse this tool to summarize emails.  \n\n## Gmail_Send  \nUse this tool to send emails. You sign every email with \"Arnie\" and never use empty placeholders for names.  \nEnsure that emails are well-formatted with a proper body.  \n\n## Calendar_Set  \nUse this tool to schedule appointments in the calendar.\n\n\n## Calendar_Get  \nUse this tool to find calendar events and inform me when I have an appointment."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        580,
        0
      ],
      "id": "624a31f0-6159-4fbe-bc6f-3b2cf97fe0bd",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        420,
        400
      ],
      "id": "94480461-4de3-473c-bf2a-eca4f87075b8",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "mto8GpgTDXNCXksO",
          "name": "YT Test"
        }
      }
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        280,
        160
      ],
      "id": "33b81c9d-5052-4714-8aa3-e5f71eac367a",
      "name": "Telegram",
      "webhookId": "52f4d0ed-5036-4014-bdcd-8ff723ddfb33",
      "credentials": {
        "telegramApi": {
          "id": "sJmCCl04cDyvxGEp",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        420,
        160
      ],
      "id": "da2a5615-d425-4db9-ac21-71dbe70045ee",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "mto8GpgTDXNCXksO",
          "name": "YT Test"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Switch').item.json.message.chat.id }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        560,
        280
      ],
      "id": "fd065b20-53d6-44f3-8e5d-0c9d1dbfe1d9",
      "name": "Window Buffer Memory"
    },
    {
      "parameters": {
        "chatId": "={{ $('Switch').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        940,
        0
      ],
      "id": "a124e895-8107-4c7d-b356-f2997bfbe228",
      "name": "Telegram1",
      "webhookId": "19dc4578-bd30-4424-ba2e-23e9d33a6db7",
      "credentials": {
        "telegramApi": {
          "id": "sJmCCl04cDyvxGEp",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "limit": 10,
        "filters": {}
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        700,
        300
      ],
      "id": "eb1d4333-8a51-4ee5-8f85-bec0a6175962",
      "name": "Gmail_Summary",
      "webhookId": "13391f05-03c0-477a-89ce-6800f33178b2",
      "credentials": {
        "gmailOAuth2": {
          "id": "BefzfszAZ9biUPaV",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('To', ``, 'string') }}",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "emailType": "text",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.1,
      "position": [
        820,
        300
      ],
      "id": "93836f47-584a-44eb-8a9f-79fba0831291",
      "name": "Gmail",
      "webhookId": "77da1f26-3d43-4d35-a434-03e026bcacc1",
      "credentials": {
        "gmailOAuth2": {
          "id": "BefzfszAZ9biUPaV",
          "name": "Gmail account"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "arnio93@gmail.com",
          "mode": "list",
          "cachedResultName": "arnio93@gmail.com"
        },
        "start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
        "end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
        "additionalFields": {
          "summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        940,
        300
      ],
      "id": "b7143330-3053-4b23-8233-2b77969ed497",
      "name": "Calendar_Set",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "UM5avnmMmy6JghyJ",
          "name": "Google Calendar account"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "calendar": {
          "__rl": true,
          "value": "arnio93@gmail.com",
          "mode": "list",
          "cachedResultName": "arnio93@gmail.com"
        },
        "timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
        "options": {}
      },
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        1080,
        300
      ],
      "id": "c62dc1b7-3768-4c3a-9813-a1c185edac67",
      "name": "Calendar_Get",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "UM5avnmMmy6JghyJ",
          "name": "Google Calendar account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail_Summary": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gmail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar_Set": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar_Get": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "4f7274b1-d38b-4e18-a625-7832461f9520",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "89d6b5241e3d0c6b62682a09a72213abeeffd34a6110f442c15fc0b560f12919"
  },
  "id": "wgzXvw7kEQnH4YJ3",
  "tags": []
}