{
  "name": "My workflow 26",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "id": "820cfb14-45e9-4627-8ce8-2bcd57ff86c5",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.1,
      "position": [
        760,
        1360
      ],
      "webhookId": "667892ca-ca20-42ab-a97f-a70b01aa2887",
      "credentials": {
        "telegramApi": {
          "id": "FX7lU9nwFY5xXSq0",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "a3a2b343-3088-47fb-982c-3892f5aab618",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        1300,
        1660
      ],
      "credentials": {
        "openAiApi": {
          "id": "hdRYPqX7PaZRro2X",
          "name": "OpenAi account 4"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "contextWindowLength": 10
      },
      "id": "92b71327-cd74-4ec6-bb78-d90a2e74b412",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.2,
      "position": [
        1700,
        1620
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Audio"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "12abfa22-3fb9-4943-9f03-d8e832b81242",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "text"
            }
          ]
        },
        "options": {}
      },
      "id": "ef467bdc-1b56-4bb0-83ba-1dadd88352e2",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1000,
        1360
      ]
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "id": "2d311f1f-bfb3-4bf8-aaf1-2b469c88c96c",
      "name": "download a file",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1280,
        1160
      ],
      "credentials": {
        "telegramApi": {
          "id": "FX7lU9nwFY5xXSq0",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "id": "fac47018-0e44-4425-bb5c-921056e5c6ef",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        1500,
        1160
      ],
      "credentials": {
        "openAiApi": {
          "id": "hdRYPqX7PaZRro2X",
          "name": "OpenAi account 4"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "8b06acbc-8ec3-43f6-9286-709f2ca80045",
              "name": "text",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "bf61ec2d-8c00-4ae7-ab77-68fb5cc1f030",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1320,
        1400
      ]
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "id": "9345940c-0191-48cf-ad6e-a29301f9bd84",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2580,
        1440
      ],
      "credentials": {
        "telegramApi": {
          "id": "aTuP6ENyLloSCk3N",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "6ef42aa3-8cf6-4def-9e46-edf74bf2cd6f",
              "leftValue": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "8775e4ca-f820-4b55-801c-f57a1dad0c9c",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2080,
        1380
      ]
    },
    {
      "parameters": {
        "operation": "sendAudio",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "binaryData": true,
        "additionalFields": {
          "fileName": "data.mpga"
        }
      },
      "id": "a103248d-f864-4b65-aa61-7a41c4f9b560",
      "name": "Telegram1",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2880,
        1220
      ],
      "credentials": {
        "telegramApi": {
          "id": "FX7lU9nwFY5xXSq0",
          "name": "Telegram account 4"
        }
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "input": "={{ $('Supervisor AI Agent').item.json.output }}",
        "options": {}
      },
      "id": "c26fe90e-8688-4411-903c-8c843903c89b",
      "name": "Generate audio",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        2580,
        940
      ],
      "credentials": {
        "openAiApi": {
          "id": "hdRYPqX7PaZRro2X",
          "name": "OpenAi account 4"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.elevenlabs.io/v1/text-to-speech/Xb7hH8MSUJpSbSDYk0k2",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "xi-api-key",
              "value": "sk_6ef07e547dc1c9ee27727bb02b5efe2a2b3b833bc5d1cb33"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"text\": \"{{ JSON.stringify($json.message.content).replace(/(^\\\"|\\\"$)/g, '') }}\"\n}",
        "options": {}
      },
      "id": "78b23e7b-3f8f-415e-81d2-892326298812",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2580,
        1200
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o",
          "mode": "list",
          "cachedResultName": "Contact database",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1rP7rhJqPzOYO11UxARnceK46ViDhK56ikejVIDCke8o/edit#gid=0"
        },
        "options": {}
      },
      "id": "668e0e0c-f493-4e9f-a3bc-eb284cfb4897",
      "name": "Contacts Database",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4.5,
      "position": [
        1860,
        1720
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ZS5pOfdOdJWUb2JE",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "name": "email_Agent",
        "description": "Call this tool to ake action in email",
        "workflowId": {
          "__rl": true,
          "value": "L0o7ERpJEcGhcLI6",
          "mode": "list",
          "cachedResultName": "Email Agent"
        }
      },
      "id": "a8cf5015-9456-41f4-92c2-f242eb747cc2",
      "name": "Email Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        2000,
        1700
      ]
    },
    {
      "parameters": {
        "name": "Calendar_Agent",
        "description": "Call this tool to manage the calendar.",
        "workflowId": {
          "__rl": true,
          "value": "s0jeisV2lJvt3s8N",
          "mode": "list",
          "cachedResultName": "Calendar Agent"
        }
      },
      "id": "06f3df45-38fb-46a9-a652-bb968e47bd6e",
      "name": "Calendar Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        2120,
        1700
      ]
    },
    {
      "parameters": {
        "name": "Research_Agent",
        "description": "Call this tool to search the internet and answer the user's questions.",
        "workflowId": {
          "__rl": true,
          "value": "r48uIhIRNImfCDMs",
          "mode": "list",
          "cachedResultName": "Research Agent"
        }
      },
      "id": "9af5fac8-3d1a-463c-b685-17d9cd0460f0",
      "name": "Research Agent",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "typeVersion": 1.2,
      "position": [
        2280,
        1700
      ]
    },
    {
      "parameters": {
        "model": "deepseek-r1-distill-llama-70b",
        "options": {}
      },
      "id": "fcbd579e-ff8a-4a51-9042-9492a41ef5e7",
      "name": "Groq Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGroq",
      "typeVersion": 1,
      "position": [
        1520,
        1580
      ],
      "credentials": {
        "groqApi": {
          "id": "hqdsKbo1zaWuq2Ac",
          "name": "Groq account 3"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.text }}",
        "options": {
          "systemMessage": "=Summarize the following incoming data: {{ $json.output }}.\n\nFor calendar events, include only the event name and time.\nFor emails, provide only the email title and a brief summary of the body, excluding any timestamps.\nEnsure the output is in plain text format, without any symbols or markdown formatting."
        }
      },
      "id": "652a53f5-ebc0-47cb-b02f-97fa02e4a4d8",
      "name": "Supervisor AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.7,
      "position": [
        1700,
        1380
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "GPT-4O-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Summarize this incoming information:  {{ $json.output }}. if  asked forFor the calendar events provide only the name of the event and time. \n\nif asked for email provide just title of the email and summary of the body. no time\n\nOutput only plain text, there should be no markdown formatting or  any symbols."
            }
          ]
        },
        "options": {}
      },
      "id": "35e57a52-f9c4-4d8d-aa41-2d14c56ca272",
      "name": "Summarise",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        2200,
        1200
      ],
      "credentials": {
        "openAiApi": {
          "id": "hdRYPqX7PaZRro2X",
          "name": "OpenAi account 4"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "download a file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "download a file": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Summarise",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Contacts Database": {
      "ai_tool": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Email Agent": {
      "ai_tool": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Calendar Agent": {
      "ai_tool": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Research Agent": {
      "ai_tool": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Groq Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Supervisor AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Supervisor AI Agent": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarise": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "9ffc86f8-cb87-4451-a0a8-e515a9e3628b",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "d1853d6d92799d2de46a947c80ac9a5af91665397cc93a1b568769b332366e37"
  },
  "id": "8bEAV1JujTnAwy7i",
  "tags": []
}