Gmail Automation: From Filters to an Inbox-Triage Agent

Filters and templates sort your mail, but they can't read it. Here's the next step: an inbox-triage agent that classifies email, drafts replies for one-click approval, and captures leads to your CRM, with guardrails.

Jose Giron
Major and Gmail lockup: an inbox-triage agent built on the Gmail API.

Gmail automation is the set of built-in rules that sort and send mail for you: filters, labels, templates, and schedule-send. Those rules are deterministic and fast, but they cannot read a message and decide what it means. The next step is an inbox-triage agent built on the Gmail API that classifies each incoming email, drafts a reply for you to approve, captures leads to a CRM, and escalates what matters, all behind policy guardrails so it never sends or deletes on its own.

Key takeaways

  • Native Gmail automation (filters, labels, templates, schedule-send) is deterministic sorting and sending, and it is the right tool for that job.
  • A filter cannot read a message or make a judgment call. That is where an inbox agent picks up.
  • An inbox-triage agent classifies each email, drafts replies for one-click approval, captures leads to a CRM, and escalates the urgent ones.
  • Build it on the Gmail API using watch (via Pub/Sub), the messages and labels resources, and drafts, scoped to gmail.modify so it reads, labels, and drafts but does not send.
  • Keep a human in the loop: the agent drafts and labels, a person clicks send, and every action lands in an audit log.

What Gmail automation is (filters, templates, and where they stop)

Gmail automation is the set of built-in rules that sort and send mail without you touching it. Filters match on sender, subject, or keywords, then label, archive, forward, or star. Templates (Gmail calls them canned responses) drop a saved reply into a new message. Schedule-send holds a message until a set time. Tools like Mailmeteor add mail merge on top for bulk sends.

These are deterministic rules, and for what they do they are the right tool. A filter that labels every receipt from stripe.com as Finance and skips the inbox runs correctly forever, costs nothing, and never surprises you. Do not replace that with an agent.

The ceiling is judgment. A filter matches patterns. It cannot read a message and decide what it means. It cannot tell an angry customer from a routine question that happens to share keywords, weigh whether a reply is warranted, or notice that "quick question about pricing" from a domain you have never seen is a lead worth logging. That gap is why a Reddit thread titled "what Gmail automation is still impossible with current tools" reads like a wishlist for reading and deciding, and why people have started hand-building small labeling apps with an LLM to catch the client mail their filters miss.

So here is the definition worth keeping: Gmail's native automation is rule-based sorting and sending; an inbox agent adds the reading and the judgment that rules cannot encode. The two are not competitors. The agent picks up where the filter stops.

How the three approaches compare across the capabilities that matter:

  • Reads the message body. Gmail filters and templates: No, matches patterns only. Zapier or Make: Partly, via fields or an optional AI step. Inbox-triage agent: Yes, the full message.
  • Makes a judgment call. Gmail filters and templates: No. Zapier or Make: Limited, one prompt per step. Inbox-triage agent: Yes, classifies and decides.
  • Drafts vs. auto-sends. Gmail filters and templates: Sends or forwards on a rule. Zapier or Make: Usually auto-sends or posts. Inbox-triage agent: Drafts by default.
  • Human in the loop. Gmail filters and templates: No, fires automatically. Zapier or Make: Optional, not the default. Inbox-triage agent: Yes, by design.

When an AI agent over Gmail actually helps

An agent earns its place on three jobs filters cannot do. This is the same classify-draft-route shape behind most useful agentic workflow patterns.

Classify incoming mail

The agent reads each new message and assigns a category: lead, client, invoice, or junk. It works from the body and headers, not a keyword list, so "loved the demo, what does the team plan cost?" lands as a lead even though no rule anticipated that phrasing. Each classification carries a confidence score, and anything below your threshold routes to a person instead of guessing.

Draft replies for one-click approval

For messages that warrant a response, the agent writes a reply and saves it as a Gmail draft. It does not send. You open the thread, read the draft, edit if needed, and hit send yourself. The drafting is the work. The sending stays with you. This is the same reply-drafting pattern behind AI customer service agents, applied to a shared or personal inbox.

Lead capture to CRM and escalation

When a message is a lead, the agent creates or updates a record in your CRM so it does not live and die in an inbox. When something is urgent (a churn signal, a contract question, an outage report from a key account), it posts to a Slack channel so the right owner sees it in minutes. The CRM write here maps directly to what AI agents for HubSpot do on the deal side.

What you need to build one

The Gmail API in about 200 words

The Gmail API exposes your mailbox as a set of resources. Messages are the individual emails, and they are immutable: once created, a message cannot be edited, so the agent changes state by adding or removing labels, not by rewriting mail. Labels are the tags you already see in Gmail, and the API lets an app create and apply them, which is how the agent marks something "Triage: Lead" or "Escalated." Drafts are unsent messages, and this is where a reply lives until a human sends it. Sending a draft deletes it and produces a message with the SENT label.

To react in near real time, the agent uses watch, Gmail's push mechanism built on Google Cloud Pub/Sub. Your app calls watch on the mailbox, and Gmail publishes a notification to your Pub/Sub topic whenever the inbox changes.

POST https://gmail.googleapis.com/gmail/v1/users/me/watch
{
"labelIds": ["INBOX"],
"topicName": "projects/your-project/topics/gmail-triage"
}

Access is governed by OAuth scopes. The three that matter here are gmail.readonly (read messages), gmail.modify (read plus label and draft), and gmail.send (send on your behalf). Request the narrowest one the job needs.

Pros and cons of the Gmail API

The strengths are real. Push via watch means you react to mail as it arrives rather than polling every few minutes. Drafts are a first-class resource, so "write but do not send" is a native operation, not a workaround. Labels give you an auditable trail of what the agent touched.

The gotchas are specific, and worth knowing before you build. First, watch subscriptions expire and must be renewed at least every seven days, so the agent needs a scheduled job to re-arm the watch or it goes silent. Second, gmail.readonly, gmail.modify, and the full mail.google.com scope are restricted scopes: an app that requests them and stores that data goes through Google's restricted-scope verification and, in many cases, an annual third-party security assessment. Budget for that review rather than discovering it at launch. Third, because messages are immutable, there is no "edit the email" operation. Plan around labels and drafts.

A worked example: the inbox-triage agent

What it does

A new email arrives. The agent reads it, classifies it as lead, client, invoice, or junk, and then acts on the category. Leads get a CRM record and a drafted reply. Client issues get a label, a drafted reply, and a Slack ping to the owner. Invoices get labeled for finance. Junk gets labeled and archived. Every reply it writes is saved as a Gmail draft for you to send.

How the steps wire together

The trigger is Gmail watch via Pub/Sub. From there the steps run in order:

  1. A new message in the inbox fires a Pub/Sub notification and wakes the agent.
  2. The agent fetches the message and classifies it as lead, client, invoice, or junk with a confidence score.
  3. For a lead, it writes to HubSpot or Salesforce and composes a draft reply in Gmail.
  4. For a client issue, it applies a label, drafts a reply, and posts to Slack with a link to the thread.
  5. For an invoice, it labels the message for finance. For junk, it labels and archives.
  6. A person reads each draft and clicks send. Nothing leaves your domain on the agent's own authority.

Gmail, the CRM, and Slack are named connectors doing one clear job each, not a vague "your stack."

Human stays in the loop: the agent drafts and labels, but a person reads every draft and clicks send. Nothing leaves your domain on the agent's own authority.

What governance the agent needs

This is the part that answers the fear of letting AI act in your inbox. Scope the OAuth grant to gmail.modify so the agent can read, label, and draft but cannot send unless you explicitly turn that on later. Keep a log of every classification, label, draft, and CRM write, so any action can be traced back to the message that caused it. Set the scope boundary in plain terms and hold it: the agent drafts and labels. It does not auto-send or delete mail unattended. Those are the same scoped-credential and audit-log habits behind enterprise-grade governance for any agent that touches a system of record.

What this doesn't cover

This walkthrough is about triaging and drafting on an inbox you own, not fully autonomous sending. It does not cover cold outreach or bulk mail merge (Mailmeteor and similar tools already do that well), spam filtering (Gmail's own filters handle it), or replacing deterministic rules you already trust. If a filter sorts your receipts correctly, keep it. The agent is for the reading-and-deciding work rules cannot encode.

Build this in Major

On Major, the triage agent is a predictable agent that builds a governable app for the repeatable work. The classification logic, the routing rules, and the category thresholds are reasoned once and then run as a deterministic app with its own database and audit log. The model reads each new email and decides where it goes. It does not re-derive the rules on every message. That is the difference between an assistant that re-thinks the job each run and an app that just runs it. Reason once. Run forever. Gmail, your CRM, and Slack connect through scoped credentials, and every label, draft, and CRM write lands in the app's log where you can inspect it. If you are new to the idea, start with what an AI agent is and come back.

You already have the filters for the deterministic sorting. The reading-and-deciding layer is what is missing, and it is a weekend's work to stand up rather than a research project. Build your inbox-triage agent on Major and keep every reply behind a human send.

Related articles

Frequently asked questions

What is Gmail automation?
Gmail automation is the built-in rules that sort and send mail for you: filters that label, archive, or forward on a match, templates for canned replies, and schedule-send. Those are deterministic and rule-based. An inbox agent goes further, reading each message and deciding what it means, which filters cannot do.
Can you automate Gmail replies without sending them automatically?
Yes, and it is the safe default. An agent built on the Gmail API reads the message, writes a reply, and saves it as a Gmail draft instead of sending. You open the draft, edit if needed, and click send yourself. The drafting is automated. The send stays a human decision.
What Gmail automation is still hard with filters alone?
Anything that needs reading and judgment. Filters match sender, subject, and keywords, so they cannot tell an urgent client issue from a lookalike, gauge whether a reply is warranted, or spot a new lead phrased in an unexpected way. Classifying tricky mail and deciding what matters is where an agent helps.
How do you build a custom Gmail automation?
Build on the Gmail API. Use watch (via Google Cloud Pub/Sub) to react to new mail, read the messages resource, apply labels, and save replies as drafts. Request the narrowest OAuth scope the job needs, usually gmail.modify. From there an inbox-triage agent can classify each email, draft replies, capture leads to a CRM, and escalate the urgent ones.
Is it safe to let AI act on my inbox?
With the right guardrails, yes. Scope the OAuth grant to read, label, and draft (gmail.modify) rather than send, so the agent never sends or deletes on its own. Keep the default at drafts for one-click human approval, and log every classification, label, and draft so any action is traceable.