{
  "name": "Inbox Butler v2 + calendar (Demoyard EP05)",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": true,
        "filters": {
          "readStatus": "unread"
        },
        "options": {}
      },
      "id": "632d400a-4af1-43ac-b5d1-8a3e7c0acc8e",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "inputText": "=From: {{ $('Gmail Trigger').item.json.From }}\nSubject: {{ $('Gmail Trigger').item.json.Subject }}\nPreview: {{ $('Gmail Trigger').item.json.snippet }}",
        "categories": {
          "categories": [
            {
              "category": "Urgent",
              "description": "Something is broken, a deadline is today, or someone needs an answer within hours."
            },
            {
              "category": "Clients",
              "description": "Questions, requests or replies from customers or business contacts that aren't urgent."
            },
            {
              "category": "Receipts",
              "description": "Order confirmations, invoices, payment receipts, shipping updates."
            },
            {
              "category": "Newsletters",
              "description": "Newsletters and content subscriptions I signed up for."
            },
            {
              "category": "Promotions",
              "description": "Sales, discounts, marketing and cold outreach."
            }
          ]
        },
        "options": {
          "fallback": "other"
        }
      },
      "id": "c1bb2406-0916-48aa-975c-9c2f558fbd86",
      "name": "Sort Email",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1.1,
      "position": [
        260,
        300
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "options": {}
      },
      "id": "d9f35879-1bc6-4e08-ab97-46d89631636b",
      "name": "Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        260,
        560
      ],
      "notes": "Add your OpenAI credential. Or delete this node and attach an Anthropic or Gemini chat model instead.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "de456300-184d-4a8d-9471-db5c9af7f340",
      "name": "Label: AI/Urgent",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        40
      ],
      "notes": "Pick the AI/Urgent label from the dropdown",
      "notesInFlow": true
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are my email assistant. Read the email below.\nIf it asks to meet or have a call, FIRST use the calendar tool to see my booked slots for the next 5 days, then pick two free 30-minute slots on business days between 9am and 5pm and offer both in the reply.\nIf it does not ask to meet, do not check the calendar.\nWrite a short, polite reply (under 80 words) and sign it \"— [Your name]\".\nThen use the Gmail tool to save it as a DRAFT reply. Never send email.\n\nFrom: {{ $('Gmail Trigger').item.json.From }}\nSubject: {{ $('Gmail Trigger').item.json.Subject }}\nEmail: {{ $('Gmail Trigger').item.json.snippet }}",
        "options": {}
      },
      "id": "ea42a13f-718a-40b9-898b-1031ff5b3942",
      "name": "Draft Urgent Reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        900,
        40
      ]
    },
    {
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "subject": "=Re: {{ $('Gmail Trigger').item.json.Subject }}",
        "emailType": "text",
        "message": "={{ $fromAI('reply_body', 'The full text of the reply email', 'string') }}",
        "options": {
          "threadId": "={{ $('Gmail Trigger').item.json.threadId }}",
          "sendTo": "={{ $('Gmail Trigger').item.json.From }}"
        }
      },
      "id": "533d5a45-d3d7-43ab-999e-e5cdfa24fd1e",
      "name": "Create Gmail Draft",
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.2,
      "position": [
        1060,
        260
      ],
      "notes": "Drafts only. This workflow never sends email.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "e44703a0-bda3-4734-b8a5-5480360c34ba",
      "name": "Label: AI/Clients",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        180
      ],
      "notes": "Pick the AI/Clients label from the dropdown",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "10f560ac-dc57-4305-af0b-54e660357cab",
      "name": "Label: AI/Receipts",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        320
      ],
      "notes": "Pick the AI/Receipts label from the dropdown",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "a9cf2eb8-7b9f-4dbd-9a1c-cb2ee7b8ef55",
      "name": "Label: AI/Newsletters",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        460
      ],
      "notes": "Pick the AI/Newsletters label from the dropdown",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "5d36030a-abc4-4fbc-9960-67087157fe61",
      "name": "Label: AI/Promotions",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        600
      ],
      "notes": "Pick the AI/Promotions label from the dropdown",
      "notesInFlow": true
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": []
      },
      "id": "ca9f0124-24f6-4592-a460-880a88e4f02f",
      "name": "Label: AI/Other",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        620,
        740
      ],
      "notes": "Optional: pick an AI/Other label, or delete this node",
      "notesInFlow": true
    },
    {
      "parameters": {
        "resource": "calendar",
        "operation": "availability",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "timeMin": "={{ $now }}",
        "timeMax": "={{ $now.plus(5, 'days') }}",
        "options": {
          "outputFormat": "bookedSlots"
        }
      },
      "id": "0469b59f-6884-4f44-b0b2-c4f44c940ebd",
      "name": "Check My Calendar",
      "type": "n8n-nodes-base.googleCalendarTool",
      "typeVersion": 1.3,
      "position": [
        1200,
        260
      ],
      "notes": "Pick your calendar from the dropdown. Read-only: it only sees busy times.",
      "notesInFlow": true
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Sort Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Sort Email",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Draft Urgent Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sort Email": {
      "main": [
        [
          {
            "node": "Label: AI/Urgent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label: AI/Clients",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label: AI/Receipts",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label: AI/Newsletters",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label: AI/Promotions",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label: AI/Other",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label: AI/Urgent": {
      "main": [
        [
          {
            "node": "Draft Urgent Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Gmail Draft": {
      "ai_tool": [
        [
          {
            "node": "Draft Urgent Reply",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Check My Calendar": {
      "ai_tool": [
        [
          {
            "node": "Draft Urgent Reply",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "active": false
}