n8n workflow template · 11 nodes · Gmail
Auto-label incoming Gmail messages with AI nodes is a free n8n workflow template that starts from the Gmail Trigger node and works with Gmail and OpenAI. It has 11 nodes, 3 of them AI nodes (Basic LLM Chain, Structured Output Parser and OpenAI Chat Model). The notes inside the workflow say: “With this workflow you can automatically set labels for your Gmail message according to its content.” To run it, you add your own credentials for Gmail OAuth2 and OpenAI API.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
With this workflow you can automatically set labels for your Gmail message according to its content.
In this workflow available are 3 labels: "Partnership", "Inquiry" and "Notification". Feel free to adjust labels according to your needs.
Please remember to set label names both in your Gmail account and workflow.
Receive data from Gmail about new incoming message.
Set polling interval according to your needs.
Based on Gmail message ID retrieve body content of the email and pass it to AI chain.
Let the AI decide which labels suit the best content of the message.
Remember to edit system prompt - modify label names and instructions according to your needs.
Edit JSON schema and label names according to your needs.
Label names in system prompt and JSON schema should be the same.
Combine labels retrieved from Gmail account and assigned by AI together.
Create array of label IDs and add to the desired email message in Gmail.
The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.
Thank you for your support!
The 11 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:
Configure your own credentials after importing. Create each credential in n8n, then select it in the node.
Do you need somewhere to run it? Read our guide to self-hosted n8n.
We can adapt this workflow to your apps, data and process, then deploy and support it.
Contact Us