AutomationFlowsEmail & Gmail › W1: Email Ingestion & Classification

W1: Email Ingestion & Classification

W1: Email Ingestion & Classification. Uses gmailTrigger, postgres. Event-driven trigger; 4 nodes.

Event trigger★★☆☆☆ complexity4 nodesGmail TriggerPostgres
Email & Gmail Trigger: Event Nodes: 4 Complexity: ★★☆☆☆ Added:

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": "W1: Email Ingestion & Classification",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "q": "is:unread"
        }
      },
      "id": "1f8e6c7e-8d5a-4b6e-9f3a-7c9b2d1e0f0a",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [
        100,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "INSERT INTO emails (mailbox, provider_message_id, thread_id, from_address, subject, sent_at, body_text, snippet, attachment_count, has_attachments, labels_json, raw_metadata_json) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) ON CONFLICT (provider_message_id) DO NOTHING RETURNING id;",
        "queryParams": "={{ $json.from.value[0].address }}, {{ $json.id }}, {{ $json.threadId }}, {{ $json.from.value[0].address }}, {{ $json.subject }}, {{ $json.date }}, {{ $json.textAsHtml }}, {{ $json.snippet }}, {{ $json.attachments ? $json.attachments.length : 0 }}, {{ !!$json.attachments }}, {{ JSON.stringify($json.labelIds) }}, {{ JSON.stringify($json) }}"
      },
      "id": "2f8e6c7e-8d5a-4b6e-9f3a-7c9b2d1e0f0b",
      "name": "Save to DB",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        300,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.subject.toLowerCase().includes('kuitti') || $json.subject.toLowerCase().includes('receipt') || $json.subject.toLowerCase().includes('puuttuu') }}",
              "value2": true
            }
          ]
        }
      },
      "id": "3f8e6c7e-8d5a-4b6e-9f3a-7c9b2d1e0f0c",
      "name": "Is Bookkeeping?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "workflowId": "W2: Build Bookkeeping Case"
      },
      "id": "4f8e6c7e-8d5a-4b6e-9f3a-7c9b2d1e0f0d",
      "name": "Execute W2",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        700,
        200
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Save to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to DB": {
      "main": [
        [
          {
            "node": "Is Bookkeeping?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Bookkeeping?": {
      "main": [
        [
          {
            "node": "Execute W2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

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

About this workflow

W1: Email Ingestion & Classification. Uses gmailTrigger, postgres. Event-driven trigger; 4 nodes.

Source: https://github.com/perttu/workforce/blob/63589768519d1828d7fae6a1d31563f24eeb4afb/workflows/w1_ingestion.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

BPC GetData. Uses gmailTrigger, gmail, postgres. Event-driven trigger; 4 nodes.

Gmail Trigger, Gmail, Postgres
Email & Gmail

Email Automation Suite. Uses gmailTrigger, supabase, gmail. Event-driven trigger; 12 nodes.

Gmail Trigger, Supabase, Gmail
Email & Gmail

[](https://www.youtube.com/watch?v=jxT6XO4eUwI)

Google Sheets, Gmail, Gmail Trigger
Email & Gmail

Automatically transform audio files into professional transcription reports with AI-powered speech recognition, timestamp generation, and formatted Google Docs output. Monitors Gmail for incoming audi

Gmail Trigger, @Vlm Run/N8N Nodes Vlmrun, Google Docs
Email & Gmail

Lector de facturas. Uses gmailTrigger, rabbitmq. Event-driven trigger; 9 nodes.

Gmail Trigger, Rabbitmq