{
  "name": "Bewerbungsanschreiben",
  "nodes": [
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.document.file_id }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        288,
        -1184
      ],
      "id": "704ff808-2b3e-4b7e-99b4-693fa23e23db",
      "name": "Get a file",
      "webhookId": "52bc0a67-5dcb-4ee6-8d28-2e1c3469400c",
      "credentials": {
        "telegramApi": {
          "id": "XMcPP8pC9yUYzB22",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "6b265c2d-8c9a-4614-9a75-6e8b1f0bd414",
                    "leftValue": "={{ $json.message.document }}",
                    "rightValue": "",
                    "operator": {
                      "type": "object",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "upload"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 3
                },
                "conditions": [
                  {
                    "id": "74727702-73a5-4d95-96e5-9c4e092326ce",
                    "leftValue": "={{ $json.message.text?.extractUrl() }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "url"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.4,
      "position": [
        64,
        -912
      ],
      "id": "e96af613-994d-4915-aaff-38821bee0ec0",
      "name": "Switch"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "hJ6HNrGUHaxOzNmf",
          "mode": "list",
          "cachedResultUrl": "/workflow/hJ6HNrGUHaxOzNmf",
          "cachedResultName": "Sub: Convert Binary To Text"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {
            "file": "={{ $binary.data }}"
          },
          "matchingColumns": [
            "file"
          ],
          "schema": [
            {
              "id": "file",
              "displayName": "file",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.3,
      "position": [
        512,
        -1184
      ],
      "id": "5156b9cd-47f0-46cb-81cb-e874ee6c8bc5",
      "name": "Convert binary to text"
    },
    {
      "parameters": {
        "url": "={{ $json.message.text.extractUrl() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        512,
        -992
      ],
      "id": "bc8d2ae1-a231-40a2-be65-15f754341209",
      "name": "HTTP Request",
      "retryOnFail": true
    },
    {
      "parameters": {
        "modelName": "={{ $('get further inspirations').params.modelId.value }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        3112,
        -664
      ],
      "id": "ecbd3d02-5728-4ce2-9a92-9adcb3b06998",
      "name": "Gemini",
      "credentials": {
        "googlePalmApi": {
          "id": "Luo2uqLoGEzjvd2z",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``, 'string') }}",
        "actionsUi": {
          "actionFields": [
            {
              "action": "insert",
              "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('actionFields0_Text', ``, 'string') }}"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.googleDocsTool",
      "typeVersion": 2,
      "position": [
        3368,
        -664
      ],
      "id": "a9195762-4678-4efa-b80a-bfa10f2070b8",
      "name": "Update a document",
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "jfbndd5p2LtMLFQn",
          "name": "Google Docs account"
        }
      }
    },
    {
      "parameters": {
        "folderId": "={{ \"1V9IyRHf-lNc0CiYfHkLdPbSz2ksGevOX\" }}",
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', `Speichere hier das Anschreiben. `, 'string') }}"
      },
      "type": "n8n-nodes-base.googleDocsTool",
      "typeVersion": 2,
      "position": [
        3496,
        -664
      ],
      "id": "929e29e8-20c4-4e50-900b-fb976e6a4a0d",
      "name": "Create a document",
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "jfbndd5p2LtMLFQn",
          "name": "Google Docs account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "b390b080-87ca-463e-aeab-16e1de0f0ae1",
              "name": "stellenanzeige",
              "value": "={{ $json.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        736,
        -1184
      ],
      "id": "d6b27fbf-f36c-4a43-8fab-9bee31bf6942",
      "name": "stellenanzeige aus binary"
    },
    {
      "parameters": {
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "stellenanzeige",
              "cssSelector": "body",
              "skipSelectors": "a, img, figure"
            }
          ]
        },
        "options": {
          "trimValues": true,
          "cleanUpText": true
        }
      },
      "type": "n8n-nodes-base.html",
      "typeVersion": 1.2,
      "position": [
        736,
        -992
      ],
      "id": "76bf6af2-5f09-4ade-b778-0937a86e02e2",
      "name": "stellenanzeige aus html"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d7b57b18-8cdf-44a5-a53a-e9cf3025a14d",
              "name": "lebenslauf",
              "value": "[ HIER DEN LEBENSLAUF ALS TEXT EINFÜGEN ]",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        -816
      ],
      "id": "4288d7c8-db8d-4c85-a2a7-acee8eccad85",
      "name": "lebenslauf"
    },
    {
      "parameters": {
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        960,
        -1088
      ],
      "id": "f48e009e-40eb-48ec-81b2-09816b460b53",
      "name": "stellenanzeige"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1184,
        -992
      ],
      "id": "d98443b3-be3a-4b9c-a2f2-4decd600ae74",
      "name": "Merge"
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('session_id').item.json.session_id }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        3240,
        -664
      ],
      "id": "00356659-2ae8-4f3e-8f75-08b5801d887d",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "id": "UH5mUiFcnyrI0YM5",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e6d66379-d70a-4d51-a8fd-a97290cc260c",
              "name": "session_id",
              "value": "={{ $json.message.chat.id }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -160,
        -896
      ],
      "id": "55bc94b6-439e-41eb-b8fa-568a7980bbdb",
      "name": "session_id"
    },
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": false,
          "chatIds": "-5184927598",
          "userIds": "7932349853"
        }
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -384,
        -896
      ],
      "id": "dc16e6eb-7fb7-4cbd-ba1a-e7457e69bcca",
      "name": "Telegram",
      "webhookId": "f722b89a-6fdf-4038-add9-b14f00c4126c",
      "credentials": {
        "telegramApi": {
          "id": "XMcPP8pC9yUYzB22",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "operation": "deleteTable",
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "n8n_chat_histories",
          "mode": "list",
          "cachedResultName": "n8n_chat_histories"
        },
        "deleteCommand": "delete",
        "where": {
          "values": [
            {
              "column": "session_id",
              "value": "={{ $('session_id').item.json.session_id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        1408,
        -992
      ],
      "id": "0e83fc76-5561-4b46-afab-5acaeac0bfd4",
      "name": "Clear history",
      "credentials": {
        "postgres": {
          "id": "UH5mUiFcnyrI0YM5",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.user_prompt }}",
        "options": {
          "systemMessage": "Rolle: Erfahrener HR-Experte und professioneller Copywriter.\n\nKontext: Wir haben im vorherigen Schritt die Lücken und Diskrepanzen zwischen meinem Lebenslauf und der Stellenanzeige analysiert und strategische Antworten festgelegt.\n\nDeine Aufgabe:\n1. Anschreiben verfassen: Formuliere nun das finale Bewerbungsanschreiben. Es soll modern, selbstbewusst und flüssig geschrieben sein. Integriere meine unten stehenden Antworten und Argumentationslinien so natürlich wie möglich, sodass sie wie Stärken wirken und nicht wie Rechtfertigungen.\n2. Dokument erstellen: Nutze dein Tool zur Dokumentenerstellung (Google Docs/Drive), um dieses fertige Anschreiben als neues Dokument in meinem Google Drive zu speichern. Formatiere den Text dabei sauber als professionellen Geschäftsbrief (mit Platzhaltern für Adresse, Datum, Betreff etc.). Meine Kontaktdaten findest du im Lebenslauf.\n\nSTRIKTE AUSGABEREGEL:\nDeine Antwort darf AUSSCHLIESSLICH aus der URL des erstellten Google Docs bestehen. Schreibe absolut keinen Begleittext, keine Bestätigung, keine Formatierungen (wie Markdown-Links) und keine Grußformeln. Liefere nur den reinen, klickbaren Link zurück."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        3232,
        -896
      ],
      "id": "575d6160-1803-4dc5-99d5-1befa66cb958",
      "name": "write application"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "models/gemini-pro-latest",
          "mode": "list",
          "cachedResultName": "models/gemini-pro-latest"
        },
        "messages": {
          "values": [
            {
              "content": "Rolle: Erfahrener HR-Experte und Recruiter.\nAusgabeformat: Optimiere deine Antwort für Telegram! Halte dich extrem kurz, nutze kurze Absätze. Keine Formatierungen nur Plaintext. Bleibe deutlich unter dem Telegram-Zeichenlimit.\n\nKontext: Ich plane eine Bewerbung. Bevor wir das Anschreiben verfassen, müssen wir Lücken und Diskrepanzen zwischen meinem Lebenslauf und der Stellenanzeige identifizieren.\n\nDeine Aufgabe (Schritt-für-Schritt):\n\n1. HR-Analyse: Vergleiche meinen CV mit der Anzeige. Wo fehlen Skills? Welche Lücken oder Brüche fallen sofort negativ auf?\n2. Kritische Fragen: Liste die 3 bis 5 wichtigsten Fragen auf, die ein kritischer Recruiter dazu stellen würde.\n3. Antwortvorschläge: Gib mir zu jeder Frage direkt 2-3 stichpunktartige, strategisch kluge Argumentationslinien, wie wir das im Anschreiben entkräften oder als Stärke verkaufen können.\n4. STOPP: Schreibe noch kein Anschreiben. Warte auf mein Feedback zu deinen Vorschlägen.",
              "role": "model"
            },
            {
              "content": "={{ $json.user_prompt }}"
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.2,
      "position": [
        1856,
        -992
      ],
      "id": "3de02669-683b-4c3d-bdbf-4a5b073a9340",
      "name": "get further inspirations",
      "credentials": {
        "googlePalmApi": {
          "id": "Luo2uqLoGEzjvd2z",
          "name": "Google Gemini(PaLM) Api account"
        }
      }
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "chatId": "={{ $('Telegram').item.json.message.chat.id }}",
        "message": "={{ $json.inspiration }}",
        "responseType": "freeText",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        2432,
        -992
      ],
      "id": "70a4c15c-b7a5-49e8-8ce0-7a69c8f4005f",
      "name": "Ask approval",
      "webhookId": "abaed4e3-371c-46ae-8c3e-e59e6bdd784a",
      "credentials": {
        "telegramApi": {
          "id": "XMcPP8pC9yUYzB22",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cc1f6264-c909-435e-ba36-24c333232b40",
              "name": "inspiration",
              "value": "={{ $json.content.parts[0].text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        2208,
        -992
      ],
      "id": "fd0e692c-3bbe-46e1-9ab8-25e045e31703",
      "name": "inspiration"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram').item.json.message.chat.id }}",
        "text": "={{ $json.output }}",
        "additionalFields": {
          "appendAttribution": false,
          "parse_mode": "HTML",
          "reply_to_message_id": "={{ $('Telegram').item.json.message.message_id }}"
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        3696,
        -896
      ],
      "id": "9d1d67f7-d13e-471e-8621-7814ce05ff44",
      "name": "Send document URL",
      "webhookId": "bde75c62-ce94-4f10-bb5b-84ea229fe4be",
      "credentials": {
        "telegramApi": {
          "id": "XMcPP8pC9yUYzB22",
          "name": "Telegram account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "c5a19e5e-31f0-47fd-8c32-8194ca56cc87",
              "name": "user_prompt",
              "value": "=LEBENSLAUF:  \n{{ $('Merge').item.json.lebenslauf }}  \nENDE LEBENSLAUF\n\nSTELLENANZEIGE:  \n{{ $('Merge').item.json.stellenanzeige }}  \nENDE STELLENANZEIGE  \n",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1632,
        -992
      ],
      "id": "f6874cbc-790f-4cdc-af2f-1ce5d4131340",
      "name": "cv and job advert as user_prompt"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "fdafd03f-40b3-4aca-a259-7dc3e703cdea",
              "name": "user_prompt",
              "value": "={{ $('cv and job advert as user_prompt').item.json.user_prompt }}\n\n---\n\nDEINE ANREGUNG:  \n{{ $('inspiration').item.json.inspiration }}  \nENDE ANREGUNG:\n\nMEIN FEEDBACK:\n{{ $json.data.text }}  \nENDE FEEDBACK",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        2656,
        -992
      ],
      "id": "b69881eb-7cd4-4412-9778-50572ee6cedd",
      "name": "add inspiration and feed back to user_prompt"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "56aa6064-c190-4b5d-8609-f90065ecc579",
              "name": "user_prompt",
              "value": "={{ $json.message.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2656,
        -656
      ],
      "id": "7c6b05fa-23bd-425f-b823-f2079554c2dc",
      "name": "message text as user_prompt"
    },
    {
      "parameters": {
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        2880,
        -896
      ],
      "id": "fc89669d-630e-4752-a7f2-b0874f91c35a",
      "name": "Join branches"
    }
  ],
  "pinData": {},
  "connections": {
    "Get a file": {
      "main": [
        [
          {
            "node": "Convert binary to text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get a file",
            "type": "main",
            "index": 0
          },
          {
            "node": "lebenslauf",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          },
          {
            "node": "lebenslauf",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "message text as user_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert binary to text": {
      "main": [
        [
          {
            "node": "stellenanzeige aus binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "stellenanzeige aus html",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini": {
      "ai_languageModel": [
        [
          {
            "node": "write application",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Update a document": {
      "ai_tool": [
        [
          {
            "node": "write application",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Create a document": {
      "ai_tool": [
        [
          {
            "node": "write application",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "stellenanzeige aus binary": {
      "main": [
        [
          {
            "node": "stellenanzeige",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "stellenanzeige aus html": {
      "main": [
        [
          {
            "node": "stellenanzeige",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "stellenanzeige": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "lebenslauf": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Clear history",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "write application",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "session_id": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram": {
      "main": [
        [
          {
            "node": "session_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clear history": {
      "main": [
        [
          {
            "node": "cv and job advert as user_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "write application": {
      "main": [
        [
          {
            "node": "Send document URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get further inspirations": {
      "main": [
        [
          {
            "node": "inspiration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask approval": {
      "main": [
        [
          {
            "node": "add inspiration and feed back to user_prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "inspiration": {
      "main": [
        [
          {
            "node": "Ask approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send document URL": {
      "main": [
        []
      ]
    },
    "cv and job advert as user_prompt": {
      "main": [
        [
          {
            "node": "get further inspirations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add inspiration and feed back to user_prompt": {
      "main": [
        [
          {
            "node": "Join branches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "message text as user_prompt": {
      "main": [
        [
          {
            "node": "Join branches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Join branches": {
      "main": [
        [
          {
            "node": "write application",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false,
    "timeSavedMode": "fixed",
    "timezone": "Europe/Berlin",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedPerExecution": 60,
    "errorWorkflow": "ZgRERlb7YOFD2Fgh"
  },
  "versionId": "b24448da-d110-4ec4-bb86-a7626f4357eb",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "dd55c636a6af52dda22aa424fe424e1cb9469e4dc4ef9144fc48554c03d56158"
  },
  "nodeGroups": [],
  "id": "ZjVLEJvWOePgATzF",
  "tags": []
}