AutomationFlowsEmail & Gmail › Job.1_email_ingestion_pipeline

Job.1_email_ingestion_pipeline

job.1_email_ingestion_pipeline. Uses postgres, emailReadImap, httpRequest. Manual trigger; 7 nodes.

Manual trigger★★★★☆ complexity7 nodesPostgresEmail Read ImapHTTP Request
Email & Gmail Trigger: Manual Nodes: 7 Complexity: ★★★★☆ Added:

This workflow follows the Emailreadimap → HTTP Request recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "job.1_email_ingestion_pipeline",
  "nodes": [
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  const email = item.json;\n\n  // Prefer structured messageId, fallback to header\n  let rawMessageId =\n    email.messageId ||\n    email.headers?.[\"message-id\"] ||\n    email.headers?.[\"Message-ID\"] ||\n    \"\";\n\n  // Normalize Message-ID:\n  // 1. Remove \"Message-ID:\" prefix if present\n  // 2. Trim whitespace\n  // 3. Ensure angle brackets remain\n  let messageId = rawMessageId\n    .replace(/^message-id:\\s*/i, \"\")\n    .trim();\n\n  // Body preference: text > textAsHtml > html\n  const body =\n    email.text ||\n    email.textAsHtml ||\n    email.html ||\n    \"\";\n\n  return {\n    json: {\n      message_id: messageId,\n      sender: email.from?.value?.[0]?.address || \"\",\n      subject: email.subject || \"\",\n      body: body,\n      received_at: email.date || \"\"\n    }\n  };\n});\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        384,
        0
      ],
      "id": "118e0eb1-df80-4c3d-9cf6-0914fd5ff6d6",
      "name": "Normalize email"
    },
    {
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "emails",
          "mode": "list",
          "cachedResultName": "emails"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "message_id": "={{ $json.message_id }}",
            "sender": "={{ $json.sender }}",
            "subject": "={{ $json.subject }}",
            "body": "={{ $json.body }}",
            "received_at": "={{ $json.received_at }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "message_id",
              "displayName": "message_id",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "sender",
              "displayName": "sender",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "subject",
              "displayName": "subject",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "body",
              "displayName": "body",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "received_at",
              "displayName": "received_at",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "skipOnConflict": false
        }
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        576,
        0
      ],
      "id": "1d787d82-c52c-4162-a0d9-2657e9e49b74",
      "name": "Email Insert",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "events",
          "mode": "list",
          "cachedResultName": "events"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "event_type": "EMAIL_RECEIVED",
            "payload": "={{{\n  email_id: $json.email_id,\n  message_id: $json.message_id\n}\n}}",
            "triggered_by": "system",
            "application_id": "={{ null }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "event_id",
              "displayName": "event_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "event_type",
              "displayName": "event_type",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "application_id",
              "displayName": "application_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "payload",
              "displayName": "payload",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "object",
              "canBeUsedToMatch": true
            },
            {
              "id": "triggered_by",
              "displayName": "triggered_by",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        768,
        0
      ],
      "id": "3cefbe11-64de-4d8f-a3fb-c8beba611f44",
      "name": "Event insert",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "email_classification_status",
          "mode": "list",
          "cachedResultName": "email_classification_status"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "email_id": "={{ $json.payload.email_id }}"
          },
          "matchingColumns": [
            "email_id"
          ],
          "schema": [
            {
              "id": "email_id",
              "displayName": "email_id",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.6,
      "position": [
        1008,
        0
      ],
      "id": "39e5f534-f23b-4f4a-8aef-6cb68ce61533",
      "name": "Insert into ECS",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "format": "resolved",
        "options": {}
      },
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 2.1,
      "position": [
        160,
        -128
      ],
      "id": "6477c992-af4e-413c-a779-414865010a32",
      "name": "Email: adi.shailesh",
      "credentials": {
        "imap": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "format": "resolved",
        "options": {}
      },
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 2.1,
      "position": [
        160,
        112
      ],
      "id": "98996168-6559-447a-8343-a236b7f787bb",
      "name": "Email: adityakapare.03",
      "credentials": {
        "imap": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "url": "http://localhost:5678/webhook-test/21681f63-9a20-492f-bde9-3a6cde82585a",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.3,
      "position": [
        1264,
        0
      ],
      "id": "9f9a356a-b545-4db3-9179-9c9df74d35c3",
      "name": "HTTP Request"
    }
  ],
  "connections": {
    "Normalize email": {
      "main": [
        [
          {
            "node": "Email Insert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Insert": {
      "main": [
        [
          {
            "node": "Event insert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Event insert": {
      "main": [
        [
          {
            "node": "Insert into ECS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email: adi.shailesh": {
      "main": [
        [
          {
            "node": "Normalize email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email: adityakapare.03": {
      "main": [
        [
          {
            "node": "Normalize email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert into ECS": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "0b361669-c828-4d85-94da-9855f4e92fab",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "8G4YATB2eRxSIkzd",
  "tags": []
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

job.1_email_ingestion_pipeline. Uses postgres, emailReadImap, httpRequest. Manual trigger; 7 nodes.

Source: https://github.com/daemon-Ad/Job-Aggregation-and-Email-Intelligence-System/blob/main/workflows/job.1_email_ingestion_pipeline.json — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

05a Inbox: Monitor + Classify Replies. Uses emailReadImap, httpRequest, postgres, emailSend. Manual trigger; 5 nodes.

Email Read Imap, HTTP Request, Postgres +1
Email & Gmail

This workflow automates URL reporting to Spamhaus based on incoming spam/phishing sample emails. It watches one or more IMAP folders, extracts URLs from each email body, removes duplicates and common

Email Read Imap, HTTP Request
Email & Gmail

This n8n workflow helps users easily discover nearby residential construction projects by automatically scraping and analyzing property listings from 99acres and other real estate platforms. Users can

Email Read Imap, HTTP Request, Email Send
Email & Gmail

Email Order ID Extractor (Body + Attachments + OCR). Uses httpRequest, emailReadImap. Manual trigger; 11 nodes.

HTTP Request, Email Read Imap
Email & Gmail

AI HRD Screening Automation. Uses emailReadImap, httpRequest, emailSend, googleSheets. Manual trigger; 9 nodes.

Email Read Imap, HTTP Request, Email Send +1