{
  "id": "Tq4PScVRA4toMCD4",
  "name": "Inbound email to n8n (via EmailConnect) \u2014 receive & route by alias",
  "tags": [],
  "nodes": [
    {
      "id": "3406c050-8d8c-4cba-8bc3-13a88c89e314",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        16
      ],
      "parameters": {
        "width": 640,
        "height": 448,
        "content": "## Inbound email to n8n (via EmailConnect) \u2014 receive & route by alias\n\n### How it works\n\nThis workflow receives inbound email events from EmailConnect through a webhook, extracts key email fields, filters spam (Maker+), and routes valid messages based on the recipient alias. It sends messages into separate downstream paths for support, invoices/accounting, or a default catch-all branch.\n\n### Setup steps\n\n- Configure the EmailConnect webhook URL to point to the n8n webhook trigger and verify.\n- Customize the field mappings in the extract step to match the payload keys sent by EmailConnect, including sender, sender name, recipient, and subject.\n- Define the spam condition in the filter node and configure the alias matching rules in the switch node.\n- Replace the placeholder no-op branch nodes with real actions, such as creating tickets, filing invoices, or notifying a team.\n\n### Customization\n\nAdjust the alias rules to match your organization\u2019s mailbox aliases, and add more switch outputs for additional departments or workflows."
      },
      "typeVersion": 1
    },
    {
      "id": "58d2b017-ed00-4a31-864f-b7b7bae5f8ad",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 320,
        "content": "## Receive email payload\n\nStarts the workflow with the EmailConnect webhook and normalizes the incoming email payload into core fields used by the rest of the flow."
      },
      "typeVersion": 1
    },
    {
      "id": "2cfd6d28-612d-4282-8da0-eb50601ead17",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 352,
        "content": "## Filter and route email\n\nChecks whether the extracted email should be dropped as spam, then routes accepted messages by recipient alias using a switch branch."
      },
      "typeVersion": 1
    },
    {
      "id": "77674d99-c058-4ac5-aa11-46b11b774df0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1776,
        -224
      ],
      "parameters": {
        "color": 7,
        "height": 704,
        "content": "## Handle routed aliases\n\nContains the three spatially grouped destination branches for support emails, invoice/accounting emails, and the default catch-all path. These are currently no-op placeholders for downstream processing."
      },
      "typeVersion": 1
    },
    {
      "id": "dcb3305a-f772-481c-95d5-a614fd30b563",
      "name": "When Email Received",
      "type": "n8n-nodes-base.webhook",
      "position": [
        832,
        176
      ],
      "parameters": {
        "path": "emailconnect-inbound",
        "options": {
          "rawBody": true
        },
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "4472e67e-ee13-4487-a810-9048a6b5f71b",
      "name": "Set Email Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1072,
        176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "from",
              "type": "string",
              "value": "={{ $json.body.message.sender.email }}"
            },
            {
              "id": "a2",
              "name": "fromName",
              "type": "string",
              "value": "={{ $json.body.message.sender.name }}"
            },
            {
              "id": "a3",
              "name": "recipient",
              "type": "string",
              "value": "={{ $json.body.message.recipient.email }}"
            },
            {
              "id": "a4",
              "name": "subject",
              "type": "string",
              "value": "={{ $json.body.message.subject }}"
            },
            {
              "id": "a5",
              "name": "text",
              "type": "string",
              "value": "={{ $json.body.message.content.text }}"
            },
            {
              "id": "a6",
              "name": "attachments",
              "type": "array",
              "value": "={{ $json.body.message.attachments }}"
            },
            {
              "id": "a7",
              "name": "isSpam",
              "type": "boolean",
              "value": "={{ $json.body.spam.isSpam ?? false }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "12300665-403d-43c6-b986-067264797ecc",
      "name": "If Not Spam",
      "type": "n8n-nodes-base.if",
      "position": [
        1312,
        176
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.isSpam }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "fcad992e-6796-4f61-8db8-243d6bef7c84",
      "name": "Route by Email Alias",
      "type": "n8n-nodes-base.switch",
      "position": [
        1552,
        160
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "support@",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "s1",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.recipient }}",
                    "rightValue": "support@"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "invoices@",
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "s2",
                    "operator": {
                      "type": "string",
                      "operation": "contains"
                    },
                    "leftValue": "={{ $json.recipient }}",
                    "rightValue": "invoices@"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "c651a315-d004-4adb-9f01-cb83b10fc83a",
      "name": "Support Ticket Handler",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1824,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "cac0220a-df56-4099-b1fd-a80f42a30fc8",
      "name": "Invoice Filing Handler",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1824,
        176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9d24a904-b26b-463b-95dc-f4c0bb5ef4b2",
      "name": "Default Handler",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1824,
        320
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "03b9b096-dd8e-42cc-9b7a-b041307e197f",
  "connections": {
    "If Not Spam": {
      "main": [
        [
          {
            "node": "Route by Email Alias",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Email Fields": {
      "main": [
        [
          {
            "node": "If Not Spam",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Email Received": {
      "main": [
        [
          {
            "node": "Set Email Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Email Alias": {
      "main": [
        [
          {
            "node": "Support Ticket Handler",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invoice Filing Handler",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Default Handler",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}