Automate Gmail Tasks with a Gemini AI Agent and Contact Lookup
Build an n8n Chat Trigger workflow that lets a Gemini-powered agent send, reply, label, delete, and fetch emails via natural-language commands, with contact emails resolved from Google Sheets.
- Who
- YouTubers, sales teams, freelancers, or professionals who want to manage Gmail through chat commands
- You get
- Send a one-sentence command in chat and the AI agent performs the email action while keeping conversation context
- You need
- n8n · Gmail · Google Sheets
Constraints
Prerequisites: a Gmail account with pre-created labels (youtube-viewers, sales-inquiry, meeting-request, potential-clients, collaboration-requests), a Google Gemini API key, a Google Sheets contact list (name + email columns), and an n8n instance. Cost: Gemini is billed per token; see Google’s pricing page for current rates.
What they did
Author rakinjakaria built a Gmail Agent workflow in n8n. A Chat Trigger receives natural-language commands via webhook; an AI Agent node powered by Gemini parses intent and drives Gmail tool nodes (Send, Reply, Label, Delete, Get Many). If only a contact name is given, the agent calls a Google Sheets tool node to look up the email, prompting the user to add it if not found. A Memory node retains conversation context across turns.
How it went
The author reports that the agent handles requests instantly and keeps everything logged (author_report). The template is published on n8n.io with 544 views.
Worth knowing
Gemini is billed per token; see Google’s pricing page for current rates. The workflow requires pre-existing Gmail labels; without them, labeling actions may fail. Test each Gmail node individually before running the full workflow. The author provides a YouTube tutorial for additional reference, but its content has not been verified by this site. The Sheet node in workflow.json contains the author’s example spreadsheet ID and must be replaced with your own. This site has not tested the template; reproduction.status=not_tested.
Steps
Configure Gmail OAuth2 credentials
In n8n Credentials, create a new Gmail OAuth2 credential and complete the auth flow to let n8n access your Gmail. Apply this credential to all Gmail nodes (Send, Reply, Label, Delete, Get Many).
Configure Google Gemini API key
Visit Google AI Studio to generate a Gemini API key. Create a new Google Gemini (PaLM) API credential in n8n and paste the key into the Gemini language-model node.
Configure Google Sheets contact list
Set up Google Sheets OAuth2 credentials in n8n. Create or connect your existing contact sheet with name and email columns. Update the Sheet node with your own spreadsheet ID and sheet name.
Configure Chat Trigger and copy the webhook URL
The Chat Trigger node generates a webhook URL. Copy it and use that URL to interact with your Gmail agent via a chat interface.
Customize the AI Agent system prompt
Paste the author’s system message into the AI Agent node’s systemMessage field, then adjust labels and the assistant name to match your context.
Configure the Memory node
The Memory node stores conversation context. Adjust the buffer window size based on your expected chat length.
Safety tip: human confirmation before action
Safety tip (editorial safety note, not the template author's practice): before the agent actually replies to, deletes or relabels emails, have a human confirm each action.
Test and operate
Test each Gmail operation individually before running the full workflow. Send commands like: - “Reply to John’s email with a follow-up about the project.” - “Label Sarah’s email as potential-client.” - “Delete the latest spam email.” The agent handles the request instantly and keeps logs. Create Gmail labels beforehand and monitor Google API usage to avoid rate limits.
Prompt you can copy
Execution prompt · Source text。Send it in the n8n chat window (Chat Trigger)
This block is the prompt. Ads are never placed here.
Reply to John’s email with a follow-up about the project.
Paste this prompt into Kimi/ChatGPT before importing the n8n template to run a configuration check and step-by-step walkthrough.
Source
Automate Gmail tasks with Gemini AI assistant and contact management · rakinjakaria · n8n.io · 2025-08-26T11:37:02.664Z
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.