{
  "id": "aoAFjsgfd58M95zK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Gmail sorter Upload",
  "tags": [],
  "nodes": [
    {
      "id": "002c2222-6465-4e02-be6d-f264a8aa6801",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "onError": "continueErrorOutput",
      "position": [
        -128,
        112
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 17
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 1.3,
      "waitBetweenTries": 5000
    },
    {
      "id": "9e8cee00-3936-418b-989b-7bf7bf8a4424",
      "name": "Time Saving Node",
      "type": "n8n-nodes-base.timeSaved",
      "position": [
        320,
        592
      ],
      "parameters": {
        "mode": "perItem",
        "minutesSaved": 0.5
      },
      "typeVersion": 1
    },
    {
      "id": "aedbb427-be70-4340-810a-43f4996dac30",
      "name": "Add important Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1424,
        832
      ],
      "parameters": {
        "labelIds": [
          "IMPORTANT",
          "Label_4"
        ],
        "messageId": "={{ $json.output.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "505c9417-efad-4698-aac0-47c8c254d102",
      "name": "Mark Email as read",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1424,
        1136
      ],
      "parameters": {
        "messageId": "={{ $json.output.id }}",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "169fa30e-f57c-4e44-a947-9a4e351fa7cf",
      "name": "Mark email as read",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1424,
        992
      ],
      "parameters": {
        "messageId": "={{ $json.output.id }}",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f62b8293-325f-491b-bce3-d8b21cc1f1d0",
      "name": "not important Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1616,
        1136
      ],
      "parameters": {
        "labelIds": [
          "Label_8574112114184363405"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "575bd2d0-fe0a-40ff-9110-04d89747dda4",
      "name": "delete from Inbox",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1792,
        1136
      ],
      "parameters": {
        "labelIds": [
          "INBOX"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "removeLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a60cab9f-aadf-46da-a3a2-27fc417a9741",
      "name": "Google Vertex Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        544,
        752
      ],
      "parameters": {
        "options": {},
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "n8nauths-493720",
          "cachedResultName": "n8nauths"
        }
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "93d95992-f716-449c-9ab3-059d80b133a9",
      "name": "Google Vertex Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        2160,
        384
      ],
      "parameters": {
        "options": {},
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "n8nauths-493720",
          "cachedResultName": "n8nauths"
        }
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ee409bf3-f8d6-44e2-9a59-13990bf445fb",
      "name": "Create a task in Google Tasks",
      "type": "n8n-nodes-base.googleTasksTool",
      "position": [
        2128,
        -400
      ],
      "parameters": {
        "task": "MDI3Mjc5NTc3NzI3NTYwMTI1NjM6MDow",
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}",
        "descriptionType": "manual",
        "toolDescription": "Create a task in Google Tasks",
        "additionalFields": {}
      },
      "credentials": {
        "googleTasksOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6fe95ef6-b364-456e-babb-adf87c09b0fb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        48
      ],
      "parameters": {
        "color": "#685A5A",
        "width": 224,
        "height": 224,
        "content": "Specify execution time.\n\n(Verify local timezone in settings)."
      },
      "typeVersion": 1
    },
    {
      "id": "997c843c-c165-49b4-b132-d104a024b667",
      "name": "Fetch daily emails.",
      "type": "n8n-nodes-base.gmail",
      "position": [
        96,
        112
      ],
      "parameters": {
        "filters": {
          "q": "newer_than:1d"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f112d6d5-6775-4e26-968d-ed89f6e7fb92",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        496
      ],
      "parameters": {
        "color": "#685A5A",
        "width": 224,
        "height": 224,
        "content": "Deactivate if not tracking time savings in n8n. \nFeel free to adjust values."
      },
      "typeVersion": 1
    },
    {
      "id": "c1c2b50a-0ae7-4d90-ae13-a3fdf218913b",
      "name": "Analyze importance and reply needs via AI",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        544,
        592
      ],
      "parameters": {
        "text": "={{ $json.snippet }}{{ $json.From }}{{ $json.Subject }}{{ $json.To }}{{ $json.id }}",
        "options": {
          "batching": {
            "batchSize": 1
          },
          "systemPromptTemplate": "=Role: You are a highly efficient e-mail sorter for a private mailbox. Your task is to classify incoming e-mails by priority and type.\n\nClassification Levels:\n\n1 (IMPORTANT): Only personal messages from real people that require a manual response or action from me.\n\n2 (WORTH READING): Automated e-mails from companies regarding important processes (e.g., shipping confirmations, info on package tracking, OR company e-mails to which I MUST respond). Do NOT include login warnings, invoices, or confirmation codes here, as I have already seen these by the time you sort them.\n\n3 (NEUTRAL/IGNORE): Everything else. Pure information without need for action. This includes: Login notices, security alerts (as I have already seen these), newsletters, promotional e-mails, and already completed transaction confirmations/receipts.\n\nType:\n0: No direct reply via e-mail required. This includes everything from large companies, every automated e-mail, and e-mails from private individuals that do not require a response.\n\n1: If the e-mail requires a response from me via e-mail AND comes from a private individual, it must be Type 1.\n\nTask:\nBased on the Recipient, Sender, Subject, and Snippet of an e-mail, assign a number from 1-3 and determine whether it needs a reply (1) or no reply via e-mail (0). Export the result as JSON. The ID must also be included: {{ $json.id }} for later assignment."
        },
        "schemaType": "manual",
        "inputSchema": "={\n  \"type\": \"object\",\n  \"properties\": {\n    \"id\": {\n      \"type\": \"string\",\n      \"description\": \"The original ID of the e-mail. This must be adopted exactly as it appears in the input. ID:{{ $json.id }}\"\n    },\n    \"importance\": {\n      \"type\": \"integer\",\n      \"description\": \"The importance of the mail from 1 (extremely important) to 3 (unimportant/spam).\",\n      \"enum\": [1, 2, 3]\n    },\n    \"reply_required\": {\n      \"type\": \"integer\",\n      \"description\": \"Is a reply to this e-mail mandatory? 0 (no), 1 (yes).\",\n      \"enum\": [0, 1]\n    }\n  },\n  \"required\": [\n    \"id\",\n    \"importance\",\n    \"reply_required\"\n  ]\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "a61d4c23-6f77-4fcf-985c-9e3d83fe54af",
      "name": "removing all  previous n8n tags",
      "type": "n8n-nodes-base.gmail",
      "position": [
        880,
        944
      ],
      "parameters": {
        "labelIds": [
          "Label_2362452134659423732",
          "Label_8574112114184363405",
          "Label_4"
        ],
        "messageId": "={{ $json.output.id }}",
        "operation": "removeLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5bcc0e0a-fe4f-4ef6-9836-478f547e8b23",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        688
      ],
      "parameters": {
        "color": "#685A5A",
        "width": 224,
        "height": 432,
        "content": "Apply 'n8n Sorted' label. Clears existing labels to avoid double-labeling."
      },
      "typeVersion": 1
    },
    {
      "id": "8b91399c-7134-4a34-9300-d66ff2d9cb9d",
      "name": "Filter: Reply required.",
      "type": "n8n-nodes-base.if",
      "position": [
        1248,
        -272
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "38f6b421-cffe-41b5-823c-3e3472839eaf",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.reply_required }}",
              "rightValue": "=1"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3,
      "alwaysOutputData": true
    },
    {
      "id": "1cd5d3b1-72dd-47fd-880e-c43706aa330e",
      "name": "Google Task writer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1984,
        -576
      ],
      "parameters": {
        "text": "=Assess whether a To-Do for me arises from the emails sent to me. Only if I truly need to take action should you create a task; then summarize what I need to do as concisely as possible and name the Google Task accordingly, using your task tool for this. This is the email:\n{{ $json.data.map(m => `VON: ${m.From}\\nBETREFF: ${m.Subject}\\nINHALT: ${m.snippet}`).join('\\n\\n---\\n\\n') }}",
        "options": {
          "batching": {
            "batchSize": 1
          }
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "37e67898-c8bb-4464-9482-70d8beec67cd",
      "name": "Merge ID with email data.",
      "type": "n8n-nodes-base.merge",
      "position": [
        1536,
        -400
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "id",
              "field2": "output.id"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "b1bfdae0-75a9-413e-b716-400c176c8ee7",
      "name": "Combine email data: Subject, Snippet & Sender.",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1728,
        -400
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "={{ [\"From\", \"Subject\", \"snippet\", \"threadId\"] }}"
      },
      "typeVersion": 1
    },
    {
      "id": "6fff891f-c7de-4411-b98d-a31eee1209db",
      "name": "Google Vertex Chat Model3",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        1984,
        -400
      ],
      "parameters": {
        "options": {},
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "n8nauths-493720",
          "cachedResultName": "n8nauths"
        }
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2990f8f3-fd6b-43f3-8619-bb880527823d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -656
      ],
      "parameters": {
        "color": "#7E8462",
        "width": 1440,
        "height": 768,
        "content": "## Optional: AI Drafts & Google Tasks\nThis section generates AI email drafts and syncs detected action items to Google Tasks.\nNote: Deactivate or delete nodes to disable these features."
      },
      "typeVersion": 1
    },
    {
      "id": "dc366eee-90f1-4285-b049-424e4957fcc6",
      "name": "Apply n8n Sorted label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        880,
        768
      ],
      "parameters": {
        "labelIds": [
          "Label_2362452134659423732",
          "INBOX"
        ],
        "messageId": "={{ $json.output.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "94d5db8f-7a14-4f55-9ebc-3c0a734e7108",
      "name": "Rank items by importance",
      "type": "n8n-nodes-base.switch",
      "position": [
        1152,
        576
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "1",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7649271b-5f0f-4381-9e66-1163d99fa8ad",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.importance }}",
                    "rightValue": 1
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "2",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3e807be4-8423-4ca7-8565-ce599a5485ff",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.importance }}",
                    "rightValue": 2
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "3",
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3974d8ae-dd8d-4bb8-9683-15044f70e8df",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.importance }}",
                    "rightValue": 3
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4,
      "alwaysOutputData": true
    },
    {
      "id": "5670f610-6eff-4511-abf1-cb18eb485857",
      "name": "Combine Priority 1 & 2.",
      "type": "n8n-nodes-base.merge",
      "position": [
        1488,
        240
      ],
      "parameters": {},
      "notesInFlow": false,
      "typeVersion": 3.2
    },
    {
      "id": "f547b3b7-06e8-419e-9930-1e28d822f4d0",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        624
      ],
      "parameters": {
        "color": 4,
        "width": 592,
        "height": 688,
        "content": "## Actions by priority\nPriority Actions\nHigh: Label as 'Important'.\nMedium: Mark as read to reduce inbox clutter.\nLow: Label 'Unimportant', mark as read, and archive (removes from Inbox without deleting).\n\nNote: You can customize these actions within the Gmail nodes to suit your needs."
      },
      "typeVersion": 1
    },
    {
      "id": "b8a38a36-3c66-4651-ad30-2a7a72c43fc8",
      "name": "Merge ID with email data",
      "type": "n8n-nodes-base.merge",
      "position": [
        1696,
        224
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "id",
              "field2": "output.id"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "e410c2dc-1d31-4953-b955-6eb50fbf8ee4",
      "name": "Combine email data: Subject, Snippet & Sender",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1936,
        224
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "={{ [\"From\", \"Subject\", \"snippet\"] }}"
      },
      "typeVersion": 1
    },
    {
      "id": "1649df13-2e64-45c5-b342-5e134d64af19",
      "name": "Generate daily summary message",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2160,
        224
      ],
      "parameters": {
        "text": "=Create a message that summarizes my emails for me. You will receive all emails from one day; you should then state in a structured manner who an email came from, summarize in at most one sentence what it was about, and what is expected of me. Here is the list containing Sender, Subject, and Snippet:\n\n{{ $json.data.map(m => `FROM: ${m.From}\\nSUBJECT: ${m.Subject}\\nTEXT: ${m.snippet}`).join('\\n\\n---\\n\\n') }}\n\nYOU write the email as follows: Daily Summary: 1. Mail from (sender) it is about (content) you should do (your action recommendation) 2. next mail 3. ....\n\n\n",
        "batching": {
          "batchSize": 1
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "b34e6a49-a4ea-40aa-b745-f469f5da987e",
      "name": "Send Email to yourself",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2496,
        224
      ],
      "parameters": {
        "sendTo": "info@example.com",
        "message": "={{ $json.text }}",
        "options": {},
        "subject": "Tageszusammenfassung",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "1055153e-0c62-491f-a83f-e2a2ea31eba0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        128
      ],
      "parameters": {
        "color": 5,
        "width": 1440,
        "height": 400,
        "content": "## Daily Inbox Summary\nAI generates a summary of all Priority 1 and 2 emails and sends it to your inbox.\n\nSetup: Enter your email address in the final node for this to function."
      },
      "typeVersion": 1
    },
    {
      "id": "5227da2a-2d2c-42e7-a2c8-a13d7ddfacdb",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -384
      ],
      "parameters": {
        "color": "#5D0404",
        "width": 512,
        "height": 352,
        "content": "## SETUP\n1. Schedule: Set your desired trigger time and ensure the workflow timezone is set to local.\n\n2. AI Setup: Connect Vertex AI or your preferred AI model credentials.\n\n3. Gmail: Connect your Gmail credentials.\n\n4. Labels: Create these labels in Gmail: Important, n8n Sorted, and Unimportant. You may use custom label names.\n\n5. Node Sync: After creating labels, update the corresponding labeling nodes in the workflow.\n\n6. Cleanup: Deactivate any unused optional nodes or features.\n\n7. Language: Adjust LLM Chain prompts if your emails are not in English.\n\n8. Prompt Customization: Feel free to adjust any prompt. The sorting logic, in particular, should be fine-tuned to match your personal preferences.\n\nFeel free to reach out for feedback or help at info@tyzup.com"
      },
      "typeVersion": 1
    },
    {
      "id": "58346081-66fe-49c8-9b55-b38ceb7b3844",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -384
      ],
      "parameters": {
        "color": 3,
        "width": 336,
        "height": 352,
        "content": "## Credential Setup\n**Gmail and Tasks**\n[![Google OAuth Authentication in n8n - From Setup to Connection](https://img.youtube.com/vi/FBGtpWMTppw/maxresdefault.jpg)](https://www.youtube.com/watch?v=FBGtpWMTppw)\n\n**AI Setup**\nDepends on your chosen AI model.\n\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "19ead895-ec22-4f3c-82f3-62869d8a9b96",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2048,
        -80
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n\t\"Text\": \"Hier geh\u00f6hrt dein Draft rein\",\n\t\"ThredID\": \"kopiere hier die exakte Thread ID der Mail die du beantwortest\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "60a88426-2a55-4b90-a45f-423796b3d5e9",
      "name": "Google Vertex Chat Model4",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        1936,
        -80
      ],
      "parameters": {
        "options": {},
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "n8nauths-493720",
          "cachedResultName": "n8nauths"
        }
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e4bb5f74-d0c6-4f65-b948-b7db9fd6f0e3",
      "name": "Google Vertex Chat Model5",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleVertex",
      "position": [
        1936,
        -80
      ],
      "parameters": {
        "options": {},
        "projectId": {
          "__rl": true,
          "mode": "list",
          "value": "n8nauths-493720",
          "cachedResultName": "n8nauths"
        }
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fb573831-b93c-4a95-a962-90cc4d3cb348",
      "name": "Generate AI draft",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1984,
        -240
      ],
      "parameters": {
        "text": "=Du bist mein Pers\u00f6nlicher Mail beantworter. Du sollst f\u00fcr Mails welche ich beantworten muss einen Text als antwort schreiben.\nAchte darauf deinen Ton an den Ton der Mail an mich anzupassen, wenn es sehr informal ist dann sei auch informal und wenn es sehr formal ist auch formal. \nHalte die Antwort m\u00f6glichst kurz.\nFalls du etwas nicht sinnvoll beantworten kannst dann baue f\u00fcr mich [antwort ben\u00f6tigt] ein damit ich dies noch \u00e4ndern kann.\nDas ganze muss dann einfach nur der text ohne eine antwort von dir davor oder \u00e4hnliches als antwort sein damit ich deine gesamte nachricht dann kopieren kann. Es muss ins JSON FORMAT und die Thread ID muss seperat im JSON sein\nDas ist die Mail:\n{{ $json.data.map(m => `VON: ${m.From}\\nBETREFF: ${m.Subject}\\nINHALT: ${m.snippet}`).join('\\n\\n---\\n\\n') }}",
        "batching": {
          "batchSize": 1
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "e5cff58e-be64-46bc-9803-6052b0452857",
      "name": "Import AI draft in Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2400,
        -144
      ],
      "parameters": {
        "message": "={{ $json.text }}",
        "options": {
          "threadId": "="
        },
        "subject": "AI Draft",
        "resource": "draft"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Europe/Berlin",
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedMode": "dynamic",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "32c1a532-d0f2-4a52-9deb-7e0fe0a2e6d5",
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch daily emails.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Time Saving Node": {
      "main": [
        [
          {
            "node": "Analyze importance and reply needs via AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate AI draft": {
      "main": [
        [
          {
            "node": "Import AI draft in Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark Email as read": {
      "main": [
        [
          {
            "node": "not important Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark email as read": {
      "main": [
        []
      ]
    },
    "Add important Label": {
      "main": [
        []
      ]
    },
    "Fetch daily emails.": {
      "main": [
        [
          {
            "node": "Time Saving Node",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge ID with email data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge ID with email data.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "not important Label": {
      "main": [
        [
          {
            "node": "delete from Inbox",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply n8n Sorted label": {
      "main": [
        []
      ]
    },
    "Combine Priority 1 & 2.": {
      "main": [
        [
          {
            "node": "Merge ID with email data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Filter: Reply required.": {
      "main": [
        [
          {
            "node": "Merge ID with email data.",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Google Vertex Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze importance and reply needs via AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge ID with email data": {
      "main": [
        [
          {
            "node": "Combine email data: Subject, Snippet & Sender",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rank items by importance": {
      "main": [
        [
          {
            "node": "Add important Label",
            "type": "main",
            "index": 0
          },
          {
            "node": "Combine Priority 1 & 2.",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark email as read",
            "type": "main",
            "index": 0
          },
          {
            "node": "Combine Priority 1 & 2.",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Mark Email as read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate AI draft",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Google Vertex Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate daily summary message",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Vertex Chat Model3": {
      "ai_languageModel": [
        [
          {
            "node": "Google Task writer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Vertex Chat Model4": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Vertex Chat Model5": {
      "ai_languageModel": [
        [
          {
            "node": "Generate AI draft",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Merge ID with email data.": {
      "main": [
        [
          {
            "node": "Combine email data: Subject, Snippet & Sender.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a task in Google Tasks": {
      "ai_tool": [
        [
          {
            "node": "Google Task writer",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Generate daily summary message": {
      "main": [
        [
          {
            "node": "Send Email to yourself",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "removing all  previous n8n tags": {
      "main": [
        []
      ]
    },
    "Analyze importance and reply needs via AI": {
      "main": [
        [
          {
            "node": "removing all  previous n8n tags",
            "type": "main",
            "index": 0
          },
          {
            "node": "Apply n8n Sorted label",
            "type": "main",
            "index": 0
          },
          {
            "node": "Rank items by importance",
            "type": "main",
            "index": 0
          },
          {
            "node": "Filter: Reply required.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine email data: Subject, Snippet & Sender": {
      "main": [
        [
          {
            "node": "Generate daily summary message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine email data: Subject, Snippet & Sender.": {
      "main": [
        [
          {
            "node": "Google Task writer",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate AI draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}