{
  "name": "Route and categorize Gmail emails to Slack with Llama 3 via OpenRouter",
  "nodes": [
    {
      "id": "8eec9a72-61ed-4e5d-bb82-0573e3bde047",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -208,
        128
      ]
    },
    {
      "id": "d3e96249-4dbe-4f64-abe6-7ce73ef63bf9",
      "name": "Merge Category",
      "type": "n8n-nodes-base.set",
      "position": [
        368,
        -128
      ]
    },
    {
      "id": "60fc0df9-fe4b-4586-9f7c-d35b33b3b1b2",
      "name": "Invite a user to a channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        2352,
        192
      ]
    },
    {
      "id": "47e3d00b-ea89-4c0e-816d-90e897259d23",
      "name": "Find Category",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -272,
        -128
      ]
    },
    {
      "id": "9b66ffcf-edd5-41d2-a282-b8eedb525982",
      "name": "Format Channel Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        -128
      ]
    },
    {
      "id": "cb1fcb2b-ef59-45fd-a50e-c1732f9e752e",
      "name": "Check Channel Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        1696,
        -128
      ]
    },
    {
      "id": "130ed387-40e3-4d52-814b-2e48d2eae03d",
      "name": "Arrange Email Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -704,
        -128
      ]
    },
    {
      "id": "8028e034-b129-4f54-8623-c6045d44c1e8",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -336,
        128
      ]
    },
    {
      "id": "7b669536-e9e0-46bb-ab8b-e3112e9f347f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        -432
      ],
      "parameters": {
        "width": 928,
        "height": 496,
        "content": "##  Gmail Intake & Data Preparation\n\n* The Gmail node runs every minute to check for newly received emails that are still in an unread state. It is configured to ignore spam and draft emails.\n\n* The C"
      }
    },
    {
      "id": "abebe0b8-cfe6-4501-9dbf-8e22d7e844fd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -432
      ],
      "parameters": {
        "width": 496,
        "height": 896,
        "content": "## AI Email Categorization\n\n* The AI Agent node reads the email content and determines its category (for example, Sales, Accounts, etc.).\n\n* A predefined list of categories is included in the prompt. "
      }
    },
    {
      "id": "46e12fcc-e93c-43fe-89c4-7b0c659316f2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -336
      ],
      "parameters": {
        "width": 432,
        "height": 368,
        "content": "## Merge Node ( Merge Category)\n\n* This node merges the category identified by the AI agent into the main data returned by the “Arrange Email Data” node."
      }
    },
    {
      "id": "22dbf00c-c35a-44fc-86b1-16c13e6f5111",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -384
      ],
      "parameters": {
        "width": 688,
        "height": 416,
        "content": "## Slack Channels\n\n* The Slack node is used to retrieve the list of Slack channels.\n* The first Code node formats the channel list data returned by the Slack node.\n* The second Code node filters the f"
      }
    },
    {
      "id": "672c42f0-98a3-4cb5-a2ae-af01d808d487",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        -352
      ],
      "parameters": {
        "width": 432,
        "height": 368,
        "content": "## Channel Existence Check\n\n* This If node checks whether a matching category was found in the previous node.\n* If found is true, it proceeds with the Existing Channel Flow.\n* Otherwise, it triggers t"
      }
    },
    {
      "id": "6ac9e3ac-4caf-4f1d-8954-a6cc6c6d7079",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        -704
      ],
      "parameters": {
        "width": 688,
        "height": 400,
        "content": "## Existing Channel Flow\n\n* The Join Slack Channel node is used to join the app to the matched channel if it has not already joined.\n* The next Slack node posts the email details to the matched channe"
      }
    },
    {
      "id": "ac1786b7-03b2-4ec3-9d66-0042aa4a46f3",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        -80
      ],
      "parameters": {
        "width": 688,
        "height": 464,
        "content": "## New Channel Creation Flow\n\n* It first creates a Slack channel using the category name identified by the AI agent. If the category exists in the predefined category list, that name is used; otherwis"
      }
    },
    {
      "id": "7eacc984-5ff7-4566-a37d-6343635afcf8",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -208,
        288
      ]
    },
    {
      "id": "cc8882b2-b5fd-423a-88d7-477a439e6e7b",
      "name": "Capture Gmail Event",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1408,
        -112
      ]
    },
    {
      "id": "76ddf070-1317-4ecd-92f3-626843ef6846",
      "name": "Filter + Deduplicate Validation",
      "type": "n8n-nodes-base.code",
      "position": [
        -1168,
        -112
      ]
    },
    {
      "id": "dcc0cc20-174f-4fdb-8484-78f08ef49a37",
      "name": "Check Data Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        -944,
        -112
      ]
    },
    {
      "id": "a8f5a2fb-9ce8-4f45-8ac0-2129fc912288",
      "name": "Get Channels List",
      "type": "n8n-nodes-base.slack",
      "position": [
        832,
        -128
      ]
    },
    {
      "id": "7666c7b1-2882-43cf-9416-377bb7c476f7",
      "name": "Join Slack Channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        2112,
        -464
      ]
    },
    {
      "id": "87e72e20-b706-4846-8989-3fec085dfeb2",
      "name": "Post Message in Channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        2576,
        -464
      ]
    },
    {
      "id": "3d934bb1-af42-4451-8cc1-49dd47e89d07",
      "name": "Create Slack Channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        2128,
        192
      ]
    },
    {
      "id": "7ef887f5-abdd-4d67-a7a1-e62d01eca0c3",
      "name": "Post Message in Created Channel",
      "type": "n8n-nodes-base.slack",
      "position": [
        2592,
        192
      ]
    },
    {
      "id": "6862cc08-b3fb-41b4-9a7f-f12f7dc234b7",
      "name": "Remove Duplicate Channel + Find Matched Channel",
      "type": "n8n-nodes-base.code",
      "position": [
        1264,
        -128
      ]
    },
    {
      "id": "0e290919-c0ea-4cbd-a09d-033ac18fcfe4",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2480,
        -1104
      ],
      "parameters": {
        "width": 832,
        "height": 608,
        "content": "## Prerequisite and Setup Guide\n\n### How it works\n* This workflow automatically monitors new unread emails in Gmail and routes them to the correct Slack channel using AI-based categorization. It start"
      }
    }
  ],
  "connections": {
    "Find Category": {
      "main": [
        [
          {
            "node": "Merge Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Category": {
      "main": [
        [
          {
            "node": "Get Channels List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Data Exist": {
      "main": [
        [
          {
            "node": "Arrange Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Channels List": {
      "main": [
        [
          {
            "node": "Format Channel Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Arrange Email Data": {
      "main": [
        [
          {
            "node": "Find Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Join Slack Channel": {
      "main": [
        [
          {
            "node": "Post Message in Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Capture Gmail Event": {
      "main": [
        [
          {
            "node": "Filter + Deduplicate Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Channel Exist": {
      "main": [
        [
          {
            "node": "Join Slack Channel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Slack Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Channel Data": {
      "main": [
        [
          {
            "node": "Remove Duplicate Channel + Find Matched Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Slack Channel": {
      "main": [
        [
          {
            "node": "Invite a user to a channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Find Category",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Post Message in Channel": {
      "main": [
        []
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Find Category",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Invite a user to a channel": {
      "main": [
        [
          {
            "node": "Post Message in Created Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter + Deduplicate Validation": {
      "main": [
        [
          {
            "node": "Check Data Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicate Channel + Find Matched Channel": {
      "main": [
        [
          {
            "node": "Check Channel Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}