Skip to main content

Classify Gmail support emails with AI and store tickets in PostgreSQL

Workflow preview

Workflow preview
100%
Classify Gmail support emails with AI and store tickets in PostgreSQL preview
Open on n8n.io

1. Workflow Overview

This workflow automatically converts incoming Gmail messages into structured support tickets using AI classification. It assigns categories, generates a unique ticket ID, stores data in PostgreSQL,...

Best for

  • Ticket Management automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.textclassifier, @n8n/n8n-nodes-langchain.lmollama, n8n-nodes-base.postgres, n8n-nodes-base.code, n8n-nodes-base.noop, n8n-nodes-base.stickynote, n8n-nodes-base.gmailtrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Jyothish S L.

Original n8n.io source

1.1 Workflow description

Title
Classify Gmail support emails with AI and store tickets in PostgreSQL
Workflow name
Classify Gmail support emails with AI and store tickets in PostgreSQL

This workflow automatically converts incoming Gmail messages into structured support tickets using AI classification. It assigns categories, generates a unique ticket ID, stores data in PostgreSQL, assigns a support agent based on workload, and sends an automated email reply to the customer.

⚙️ How it works Fetch email from Gmail AI classifies ticket (Payment, Login, Fraud, etc.) Generates unique ticket ID Stores ticket in PostgreSQL Assigns available support agent Logs assignment Sends email confirmation to customer

📦 Requirements

  1. n8n (latest version)
  2. Gmail OAuth2 credentials
  3. PostgreSQL database
  4. AI model (Ollama or compatible LLM)
  5. Support tables:
  6. tickets
  7. support_persons
  8. ticket_assignment_logs

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Get many messages

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 2 - Text Classifier

Type / Role
@n8n/n8n-nodes-langchain.textClassifier - textClassifier
Config choices
Version 1.1

Block 3 - Ollama Model

Type / Role
@n8n/n8n-nodes-langchain.lmOllama - lmOllama
Config choices
Version 1

Block 4 - Insert rows in a table

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 5 - Code in JavaScript

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 6 - Select rows from a table

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 7 - Update rows in a table

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 8 - Insert rows in a table1

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 9 - Reply to a message

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 10 - Code in JavaScript1

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 11 - Code in JavaScript2

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Code in JavaScript3

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 13 - Code in JavaScript4

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 14 - Code in JavaScript5

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - No Operation, do nothing

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 16 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.4

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Classify Gmail support emails with AI and store tickets in PostgreSQL
Complexity advanced
Nodes 22
Categories Ticket Management, AI Summarization
Author Jyothish S L
Published 07 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15522/15522.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Classify Gmail support emails with AI and store tickets in PostgreSQL do?

This workflow automatically converts incoming Gmail messages into structured support tickets using AI classification. It assigns categories, generates a unique ticket ID, stores data in PostgreSQL,...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Ticket Management, AI Summarization use case.