{
  "name": "Personal Assistent Telegram",
  "nodes": [
    {
      "parameters": {
        "promptType": "define",
        "text": "=Twoje zadanie to rozpoznanie intencji u\u017cytkownika na podstawie podanego tekstu.\n\nMasz do wyboru trzy mo\u017cliwe odpowiedzi:\n- \"sprawd\u017a kalendarz\" \u2014 je\u015bli u\u017cytkownik chce sprawdzi\u0107, zobaczy\u0107, zapyta\u0107 o kalendarz, wydarzenia, spotkania lub terminy.\n- \"utw\u00f3rz wydarzenie\" \u2014 je\u015bli u\u017cytkownik chce zaplanowa\u0107, utworzy\u0107, doda\u0107 nowe wydarzenie lub um\u00f3wi\u0107 spotkanie.\n- \"nieznana akcja\" \u2014 je\u015bli intencja u\u017cytkownika nie jest jasna albo nie pasuje do \u017cadnej z powy\u017cszych kategorii.\n\nPrzyk\u0142ady:\n\nU\u017cytkownik: \"Co mam zaplanowane na jutro?\"\nOdpowied\u017a: sprawd\u017a kalendarz\n\nU\u017cytkownik: \"Zaplanuj spotkanie z Janem jutro o 10\"\nOdpowied\u017a: utw\u00f3rz wydarzenie\n\nU\u017cytkownik: \"Jaka b\u0119dzie jutro pogoda?\"\nOdpowied\u017a: nieznana akcja\n\nZasady:\n- Wybierz tylko jedn\u0105 z trzech podanych odpowiedzi.\n- Nie dodawaj \u017cadnych dodatkowych wyja\u015bnie\u0144 ani komentarzy.\n- Je\u015bli tre\u015b\u0107 u\u017cytkownika jest pusta lub nie dotyczy kalendarza/wydarze\u0144, wybierz \"nieznana akcja\".\n\nTeraz oce\u0144 poni\u017csze zdanie:\n\nU\u017cytkownik: \"{{ $json.message.text }}\"\nOdpowied\u017a:\n"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        560,
        -1080
      ],
      "id": "82775106-02a9-42a2-82de-152431449912",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        648,
        -860
      ],
      "id": "5fe6521b-90de-4235-bb49-18aea29a7821",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $('Basic LLM Chain').item.json.text }}",
                    "rightValue": "utw\u00f3rz wydarzenie",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "9c641949-ac5c-4ec3-b15b-6062e9e2b362"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Utw\u00f3rz wydarzenie"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "a4cdb3a2-5ec1-4c9e-b117-8c54ba50bd0b",
                    "leftValue": "={{ $('Basic LLM Chain').item.json.text }}",
                    "rightValue": "sprawd\u017a kalendarz",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Sprawd\u017a kalendarz"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "03f5ba93-bc60-4a32-baf4-36ab84b55cff",
                    "leftValue": "={{ $('Basic LLM Chain').item.json.text }}",
                    "rightValue": "nieznana akcja",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Nieznana akcja"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        936,
        -1080
      ],
      "id": "743e6554-ae08-4d60-865b-cbcd896e9eb4",
      "name": "Switch"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Na podstawie poni\u017cszego tekstu wyci\u0105gnij szczeg\u00f3\u0142y dotycz\u0105ce wydarzenia.\n\nTekst u\u017cytkownika:\n{{ $('Telegram Trigger').first().json.message.text || $('Code3').first().json.message.text }}\n\nDzisiejsza data: {{ $now.format('yyyy-LL-dd') }}\n\nTwoje zadanie:\n- Rozpoznaj tytu\u0142 wydarzenia (mo\u017ce to by\u0107 np. \"spotkanie z Janem\", \"kolacja z klientem\", itp.).\n- Rozpoznaj dat\u0119 wydarzenia.\n  - Je\u015bli u\u017cytkownik poda np. \"jutro\", \"w poniedzia\u0142ek\" \u2014 przelicz to na pe\u0142n\u0105 dat\u0119 w formacie `YYYY-MM-DD`, u\u017cywaj\u0105c dzisiejszej daty jako punktu odniesienia.\n- Rozpoznaj godzin\u0119 wydarzenia.\n  - Je\u015bli u\u017cytkownik poda godzin\u0119 (\"o 10\", \"o 18:30\"), zapisz j\u0105 w formacie `HH:mm`.\n\nZwr\u00f3\u0107 odpowied\u017a wy\u0142\u0105cznie w formacie JSON dok\u0142adnie takim jak poni\u017cej:\n\n```json\n{\n  \"title\": \"<tytu\u0142 wydarzenia>\",\n  \"date\": \"<data wydarzenia w formacie YYYY-MM-DD>\",\n  \"time\": \"<godzina wydarzenia w formacie HH:mm>\"\n}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1156,
        -1580
      ],
      "id": "2f617590-6cbb-447b-84ed-d04a129adce6",
      "name": "Basic LLM Chain1"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1244,
        -1360
      ],
      "id": "3386d4d7-1e05-48ab-886e-42ce115a5050",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// 1. Parsowanie tekstu JSON\nconst inputText = $json.text;\nconst cleanJson = inputText.replace(/```json|```/g, '').trim();\nconst eventDetails = JSON.parse(cleanJson);\n\n// 2. Przygotowanie daty i godziny\nconst date = eventDetails.date; // \"2025-04-25\"\nconst time = eventDetails.time; // \"12:00\"\nconst title = eventDetails.title;\n\n// 3. Tworzenie obiektu Date start\nconst startDate = new Date(`${date}T${time}:00+02:00`);\n\n// 4. Tworzenie obiektu Date end (+1 godzina)\nconst endDate = new Date(startDate.getTime() + 60 * 60 * 1000);\n\n// 5. Zwr\u00f3cenie w formacie ISO\nreturn {\n  startDateTime: startDate.toISOString(),\n  endDateTime: endDate.toISOString(),\n  title: title\n};"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1532,
        -1480
      ],
      "id": "5ce24ce5-16b2-4e8b-8682-348bed965dd0",
      "name": "Code"
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "blazej@kapala.com.pl",
          "mode": "list",
          "cachedResultName": "blazej@kapala.com.pl"
        },
        "start": "={{ $json.startDateTime }}",
        "end": "={{ $json.endDateTime }}",
        "additionalFields": {
          "summary": "={{ $json.title }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        1752,
        -1480
      ],
      "id": "db01e1e3-0c29-43e6-96e4-e28d955626a5",
      "name": "Google Calendar",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -980,
        -1280
      ],
      "id": "f89775de-5190-4095-889b-178a0790f850",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "Napisz to inaczej",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1234,
        -780
      ],
      "id": "4e9d9be0-909c-4337-8af5-05b10ca5d90a",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $json.text }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2426,
        -1480
      ],
      "id": "10b27d4d-e037-4672-9853-6a06ee5e46b8",
      "name": "Telegram1",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## \ud83e\udde0 Porozmawiaj z kalendarzem przez Telegrama\n\n**Ten workflow integruje Telegram, OpenAI i Google Calendar w celu reagowania na wiadomo\u015bci i wykonywania okre\u015blonych dzia\u0142a\u0144:**\n\n1. **Telegram Trigger** \u2013 reaguje na wiadomo\u015b\u0107 otrzyman\u0105 na czacie Telegrama.\n\n2. **Basic LLM Chain + OpenAI Chat Model** \u2013 wiadomo\u015b\u0107 jest przetwarzana przez model j\u0119zykowy OpenAI (np. GPT), aby rozpozna\u0107 intencj\u0119 u\u017cytkownika.\n\n3. **Switch (mode: Rules)** \u2013 rozga\u0142\u0119zia przep\u0142yw na podstawie rozpoznanej intencji:\n\n   - **\u201eUtw\u00f3rz wydarzenie\u201d** \u2013 przekierowuje dane do kolejnego modelu LLM oraz:\n     - przekszta\u0142ca dane w formacie wymaganym przez Google Calendar (`Code` node),\n     - tworzy wydarzenie (`Google Calendar`),\n     - wysy\u0142a potwierdzenie przez Telegram (`Telegram1`).\n\n   - **\u201eSprawd\u017a kalendarz\u201d lub inne znane komendy** \u2013 *(miejsce na rozwini\u0119cie)*\n\n   - **\u201eNieznana akcja\u201d** \u2013 wysy\u0142a wiadomo\u015b\u0107 z informacj\u0105 o nieznanym poleceniu (`Telegram`).\n",
        "height": 460,
        "width": 680
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -2000
      ],
      "typeVersion": 1,
      "id": "3ef615d9-f5e5-45ce-bd75-6997fef4a339",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "eead082d-e2b4-404f-a563-d78fd822c009",
              "leftValue": "={{ $json.message.text }}",
              "rightValue": "/start",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        340,
        -1280
      ],
      "id": "daf8b097-026f-43b2-ba40-df15645ec5c6",
      "name": "If"
    },
    {
      "parameters": {
        "chatId": "={{ $json.message.chat.id }}",
        "text": "Dzie\u0144 dobry - co mog\u0119 dla Ciebie zrobi\u0107",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        638,
        -1430
      ],
      "id": "64677cbe-4149-4f8a-98a2-c5b7c9277e8a",
      "name": "Telegram2",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Na podstawie poni\u017cszego tekstu ustal, o jaki dzie\u0144 lub zakres dni chodzi.  \nWydob\u0105d\u017a informacj\u0119 o dacie lub zakresie dat z tre\u015bci wiadomo\u015bci u\u017cytkownika.\n\nTekst u\u017cytkownika:\n{{ $('Telegram Trigger').first().json.message.text || $('Code3').first().json.message.text }}\n\nDzisiejsza data: {{ $now.format('yyyy-LL-dd') }}\n\nTwoje zadanie:\n- Je\u015bli u\u017cytkownik poda pojedynczy dzie\u0144 (np. \"poniedzia\u0142ek\", \"jutro\"), ustal konkretn\u0105 dat\u0119.\n- Je\u015bli u\u017cytkownik poda zakres dni (np. \"przysz\u0142y tydzie\u0144\", \"od \u015brody do pi\u0105tku\", \"ca\u0142y weekend\"), ustal pe\u0142ny zakres:\n  - \"dayStart\" powinien wskazywa\u0107 pocz\u0105tek pierwszego dnia o godzinie 00:00:00.000\n  - \"dayEnd\" powinien wskazywa\u0107 koniec ostatniego dnia o godzinie 23:59:59.999\n- Je\u015bli u\u017cytkownik nie poda \u017cadnych informacji o dacie, przyjmij dzisiejszy dzie\u0144 jako dzie\u0144 wyszukiwania.\n\nWszystkie daty i czasy musz\u0105 uwzgl\u0119dnia\u0107 odpowiedni\u0105 stref\u0119 czasow\u0105 i by\u0107 zapisane w pe\u0142nym formacie, jak w przyk\u0142adzie:\n`2025-04-26T05:57:40.654-04:00`\n\nFormat odpowiedzi:\n```json\n{\n  \"dayStart\": \"<data rozpocz\u0119cia zakresu w pe\u0142nym formacie>\",\n  \"dayEnd\": \"<data zako\u0144czenia zakresu w pe\u0142nym formacie>\"\n}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1156,
        -1180
      ],
      "id": "a930e444-516a-493c-acdc-3a78613ebd2d",
      "name": "Basic LLM Chain2"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1244,
        -960
      ],
      "id": "2a0ed9e9-157b-4e38-ae45-660504470142",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "getAll",
        "calendar": {
          "__rl": true,
          "value": "blazej@kapala.com.pl",
          "mode": "list",
          "cachedResultName": "blazej@kapala.com.pl"
        },
        "timeMin": "={{ $json.dayStart }}",
        "timeMax": "={{ $json.dayEnd }}",
        "options": {}
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        1752,
        -1080
      ],
      "id": "418dc1e1-c1a9-4b1b-b882-960ba6807a1f",
      "name": "Google Calendar1",
      "alwaysOutputData": true,
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Na podstawie dostarczonych danych wypisz wszystkie zaplanowane spotkania w spos\u00f3b czytelny.\n\nDane wej\u015bciowe:\n{{ $json.text }}\n\nTwoje zadanie:\n- Najpierw zawsze podaj, jakiego dnia lub jakiego zakresu dni dotycz\u0105 dane spotkania (np. \"Spotkania na 2025-04-28\" albo \"Spotkania od 2025-04-28 do 2025-04-30\").\n- Nast\u0119pnie:\n  - Je\u015bli s\u0105 spotkania, wypisz ka\u017cde spotkanie w nast\u0119puj\u0105cym formacie:\n    - Nazwa spotkania\n    - Data rozpocz\u0119cia\n    - Godzina rozpocz\u0119cia\n    - Data zako\u0144czenia\n    - Godzina zako\u0144czenia\n  - Je\u015bli brak spotka\u0144, napisz tylko: \"Brak zaplanowanych spotka\u0144.\"\n- Nie dodawaj \u017cadnych dodatkowych wyja\u015bnie\u0144 ani komentarzy poza tym co wymagane.\n\nPrzyk\u0142ad odpowiedzi, gdy s\u0105 spotkania:\n\nSpotkania na 2025-04-28:\n\n- Spotkanie: \"Obiad\"\n- Data rozpocz\u0119cia: 2025-04-28\n- Godzina rozpocz\u0119cia: 11:00\n- Data zako\u0144czenia: 2025-04-28\n- Godzina zako\u0144czenia: 12:00\n\nPrzyk\u0142ad odpowiedzi, gdy brak spotka\u0144:\n\nSpotkania na 2025-04-28:\n\nBrak zaplanowanych spotka\u0144.\n"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        2348,
        -1080
      ],
      "id": "7bccaf38-bc41-4be1-896b-42595addc10c",
      "name": "Basic LLM Chain3"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        2436,
        -860
      ],
      "id": "5d2c5a3c-c608-4281-833e-0fbfbdfeebc7",
      "name": "OpenAI Chat Model3",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// INPUT: list of Google Calendar events\n// OUTPUT: single text summary for LLM\n\n// Je\u015bli brak danych, informuj o tym\nif (!items.length) {\n  return [\n    {\n      json: {\n        text: 'Brak danych do analizy.'\n      }\n    }\n  ];\n}\n\n// Je\u015bli s\u0105 dane, przetwarzaj normalnie\nconst events = items.map(item => {\n  const data = item.json;\n  return `\ud83d\uddd3\ufe0f Spotkanie: ${data.summary || 'Brak nazwy'}\nStart: ${data.start?.dateTime || 'Brak daty startu'}\nKoniec: ${data.end?.dateTime || 'Brak daty ko\u0144ca'}\nOrganizator: ${data.organizer?.email || 'Brak organizatora'}\nLink: ${data.htmlLink || 'Brak linku'}\n`;\n});\n\n// Po\u0142\u0105cz wszystko w jeden wielki tekst\nconst output = events.join('\\n---\\n');\n\nreturn [\n  {\n    json: {\n      text: output\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2050,
        -1080
      ],
      "id": "34e7f593-a788-457e-a001-bead509cd232",
      "name": "Code1"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').first().json.message.chat.id }}",
        "text": "={{ $json.text }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2724,
        -1080
      ],
      "id": "88d2a7d7-e170-47a7-b099-75c984be754e",
      "name": "Telegram3",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// We assume there is only one item\nconst text = items[0].json.text;\n\n// Wyci\u0105gamy fragment pomi\u0119dzy ```json ... ```\nconst jsonMatch = text.match(/```json\\s*([\\s\\S]*?)\\s*```/);\n\nif (!jsonMatch || !jsonMatch[1]) {\n  throw new Error('Nie znaleziono poprawnego JSON w tek\u015bcie.');\n}\n\n// Parsujemy tekst do JSON\nconst parsedJson = JSON.parse(jsonMatch[1]);\n\nreturn [\n  {\n    json: parsedJson\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1532,
        -1080
      ],
      "id": "60ff5659-0ffa-40a2-91aa-bc09425acf03",
      "name": "Code2"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Utworzono spotkanie: {{ $json.summary }}\n\ud83d\udd52 Od: {{ $json.start.dateTime }}\n\ud83d\udd53 Do: {{ $json.end.dateTime }}\n\ud83d\udd17 {{ $json.htmlLink }}\n"
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1972,
        -1580
      ],
      "id": "3d334813-c402-4080-af84-fb5171821ab4",
      "name": "Basic LLM Chain4"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        2060,
        -1360
      ],
      "id": "dbc23982-6cb8-4a3e-b9bd-d29c7138fbfd",
      "name": "OpenAI Chat Model4",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c97ab4cc-a06a-4006-878a-a93852b51252",
              "leftValue": "={{ $json.message.voice.mime_type }}",
              "rightValue": "audio/ogg",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -760,
        -1280
      ],
      "id": "1d4eb1b0-a844-4c02-8992-ec6a19cbe0fe",
      "name": "If1"
    },
    {
      "parameters": {
        "url": "=https://api.telegram.org/bot<API:token>/getFile?file_id={{ $('Telegram Trigger').first().json.message.voice.file_id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -540,
        -1355
      ],
      "id": "de23e0f1-6e75-4e54-9bae-0d5ea846f5ab",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "url": "=https://api.telegram.org/file/bot<API:token>/{{ $json.result.file_path }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -320,
        -1355
      ],
      "id": "a72cfd63-b10b-4e4b-907e-69eafef45725",
      "name": "HTTP Request1"
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {
          "language": "pl"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -100,
        -1355
      ],
      "id": "bc54ec8f-69f2-4161-a327-d81d20411556",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const transcription = items[0].json.text || 'Brak tekstu';\n\nreturn [\n  {\n    json: {\n      message: {\n        text: transcription\n      }\n    }\n  }\n];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        120,
        -1355
      ],
      "id": "ff13530c-e911-4d09-9639-b54213a9ae31",
      "name": "Code3"
    }
  ],
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Basic LLM Chain2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain1": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Google Calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "main": [
        [
          {
            "node": "Basic LLM Chain4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain2": {
      "main": [
        [
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain3",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Basic LLM Chain3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain3": {
      "main": [
        [
          {
            "node": "Telegram3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "Google Calendar1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain4": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "aa107657-5131-4656-9c54-8bfb9182e2d3",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "vkesXggsCulSPkQS",
  "tags": []
}