Block 1 - Gmail Trigger
- Type / Role
- n8n-nodes-base.gmailTrigger - gmailTrigger
- Config choices
- Version 1.3
This workflow is provided as-is. Please review and test before using in production.
This workflow automates analyzing Gmail threads and drafting AI powered replies with the new model Anthropic Sonnet 4.5 . This workflow automates the process of analyzing incoming emails and genera...
n8n-nodes-base.gmailtrigger, n8n-nodes-base.gmail, n8n-nodes-base.merge, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.textclassifier, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.lmchatanthropic
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Davide.
Original n8n.io sourceThis workflow automates analyzing Gmail threads and drafting AI-powered replies with the new model Anthropic Sonnet 4.5.
This workflow automates the process of analyzing incoming emails and generating context-aware draft replies by examining the entire email thread.
This workflow automates the process of analyzing incoming emails and generating context-aware draft replies by examining the entire email thread.
Trigger & Initial Filtering: The workflow is automatically triggered every minute by the Gmail Trigger node, which detects new emails. For each new email, it immediately performs a crucial first step: it uses an AI Email Classifier to analyze the email snippet. The AI determines if the email is a legitimate message that warrants a reply (categorized as "ok") or if it's spam, a newsletter, or an advertisement. This prevents the system from generating replies for unwanted emails.
Context Aggregation: If an email is classified as "ok," the workflow fetches the entire conversation thread from Gmail using the threadId. A Code Node then processes all the messages in the thread, structuring them into a consistent format that the AI can easily understand.
AI-Powered Draft Generation: The structured conversation history is passed to the Replying email Agent with Sonnet 4.5. This agent, powered by a language model, analyzes the entire thread to understand the context and the latest inquiry. It then drafts a relevant and coherent HTML email reply. The system prompt instructs the AI not to invent information and to use placeholders for any missing details.
Draft Creation: The final step takes the AI-generated reply and the original email's metadata (subject, recipient, threadId) and uses them to create a new draft email in Gmail. This draft is automatically placed in the correct email thread, ready for the user to review and send.
To implement this automated email reply system, you need to configure the following:
Configure Gmail & OpenAI Credentials: Ensure the following credentials are set up in your n8n instance:
Gmail OAuth2 Credentials: The workflow uses the same Gmail account for the trigger, fetching threads, and creating drafts. Configure this in the "Gmail Trigger," "Get a thread," and "Create a draft" nodes.
OpenAI API Credentials: Required for both the "Email Classifier". Provide your API key in the respective OpenAI Chat Model nodes.
Anthropic API Credentials: Required for the main "Replying email Agent." Provide your API key in the respective Antrhopic Chat Model nodes.
Review AI Classification & Prompting:
Contact me for consulting and support or add me on Linkedin.
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.
| Workflow | AI-powered Gmail assistant: send replies by analyzing thread ID with Sonnet 4.5 |
|---|---|
| Complexity | intermediate |
| Nodes | 11 |
| Categories | AI Chatbot |
| Author | Davide |
| Published | 02 Oct 2025 |
Use the JSON export at /data/workflows/9193/9193.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
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.
This workflow automates analyzing Gmail threads and drafting AI powered replies with the new model Anthropic Sonnet 4.5 . This workflow automates the process of analyzing incoming emails and genera...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
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 AI Chatbot use case.