Module 7 Lesson 2: Gmail Automation
·Automation

Module 7 Lesson 2: Gmail Automation

Zero inbox on autopilot. Learn how to search for emails, download attachments, send personalized replies, and manage labels automatically using n8n.

Module 7 Lesson 2: Gmail Automation

Email is where productivity goes to die. n8n allows you to build an "Assistant" that sorts your mail, handles attachments, and replies to common questions while you sleep.

1. Trigger: New Email

You can tell n8n to "Wait" for emails that match a search query.

  • from:boss@office.com
  • subject:URGENT
  • label:To-Process
  • has:attachment

2. Handling Attachments (Binary Data)

Gmail nodes can download attachments.

  • The Binary Key: The file is stored in n8n's memory with a key like attachment_0.
  • You can then pass this to Google Drive (Lesson 3) or a "PDF to Text" AI node (Module 10).

3. Sending Personalized Emails

You can use Expressions (Module 1, Lesson 4) to make every email feel manually written.

  • Hi {{ $json.name }}, thanks for your order #{{ $json.order_id }}!

4. The "Inbox Cleanup" Pattern

  • Move to Trash: For junk data.
  • Add Label: Tagging an email as "Processed" so you don't process it twice.
  • Mark as Read: Cleaning up your UI.

Exercise: The Inbox Ninja

  1. Search for an email in your inbox from a specific sender.
  2. If it has an attachment, add a label "Attached" to that email.
  3. Send a reply: "Received your file!"
  4. Why is it important to use a "Search Query" in the Gmail trigger rather than just "All Emails"? (Hint: Cost and Speed).
  5. Research: What is "Gmail API Scopes" and why does Google warn you when you first connect n8n?
  6. Search: How do you send an HTML email vs a Plain Text email in n8n?

Summary

Gmail automation is about Focus. By delegating the repetitive sorting and file-handling to n8n, you ensure that you only look at your inbox when there's a task that truly requires a human brain.

Next Lesson: Filing cabinet: Google Drive: Managing Files and Folders.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn