Your inbox has 200 emails. You only care about unread messages from your supervisor — from:supervisor@uni.edu is:unread. In your current workflow, how do you find them?
get_email from Day 4 fetches one message at a time. For the supervisor filter, I'd use Gmail's search bar and scroll. But that's still manual.
Gmail's search syntax works directly in the query parameter of GMAIL_FETCH_EMAILS. The same operators you type in the Gmail search bar work here — from:, is:unread, subject:, after:. The filter runs on Gmail's servers, not in your script:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "from:supervisor@uni.edu is:unread", "max_results": 20}
)
messages = result.get("messages", [])What query would I use to find all emails with "revision" in the subject from the last month?
subject:revision matches any email with "revision" in the subject line. Add after:2026/03/01 to limit by date. Combine with spaces: "subject:revision after:2026/03/01". Gmail's query syntax is documented — the same syntax you use in the search bar is what you pass as the query string:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} emails matching '{query}'")
return messagesSo I can build a function that finds all "Manuscript revision" emails and passes each ID to get_email for the full content. That's the triage pipeline.
The Monday morning routine, automated. Filter on the server, fetch what matters, skip the rest.
I used to spend 20 minutes doing this by hand. Now it's a two-line function call.
Server-side filtering matters for research inboxes with years of history. Running GMAIL_FETCH_EMAILS without a query fetches all messages up to max_results. With a query, Gmail pre-filters — only matching messages cross the network. Use queries for any operation on inboxes larger than a few hundred messages.
The query parameter uses Gmail's built-in search operators:
| Operator | Example | Matches |
|---|---|---|
from: | from:coauthor@uni.edu | Sender address |
is:unread | is:unread | Unread messages |
subject: | subject:revision | Subject contains word |
after: | after:2026/01/01 | After a date |
has:attachment | has:attachment | Has attachment |
Combine with spaces: "from:boss@uni.edu is:unread subject:deadline".
Passing a query filters on Gmail's servers. Not passing one returns all messages up to max_results — then you'd filter in Python. For large inboxes, always prefer server-side.
Your inbox has 200 emails. You only care about unread messages from your supervisor — from:supervisor@uni.edu is:unread. In your current workflow, how do you find them?
get_email from Day 4 fetches one message at a time. For the supervisor filter, I'd use Gmail's search bar and scroll. But that's still manual.
Gmail's search syntax works directly in the query parameter of GMAIL_FETCH_EMAILS. The same operators you type in the Gmail search bar work here — from:, is:unread, subject:, after:. The filter runs on Gmail's servers, not in your script:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "from:supervisor@uni.edu is:unread", "max_results": 20}
)
messages = result.get("messages", [])What query would I use to find all emails with "revision" in the subject from the last month?
subject:revision matches any email with "revision" in the subject line. Add after:2026/03/01 to limit by date. Combine with spaces: "subject:revision after:2026/03/01". Gmail's query syntax is documented — the same syntax you use in the search bar is what you pass as the query string:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} emails matching '{query}'")
return messagesSo I can build a function that finds all "Manuscript revision" emails and passes each ID to get_email for the full content. That's the triage pipeline.
The Monday morning routine, automated. Filter on the server, fetch what matters, skip the rest.
I used to spend 20 minutes doing this by hand. Now it's a two-line function call.
Server-side filtering matters for research inboxes with years of history. Running GMAIL_FETCH_EMAILS without a query fetches all messages up to max_results. With a query, Gmail pre-filters — only matching messages cross the network. Use queries for any operation on inboxes larger than a few hundred messages.
The query parameter uses Gmail's built-in search operators:
| Operator | Example | Matches |
|---|---|---|
from: | from:coauthor@uni.edu | Sender address |
is:unread | is:unread | Unread messages |
subject: | subject:revision | Subject contains word |
after: | after:2026/01/01 | After a date |
has:attachment | has:attachment | Has attachment |
Combine with spaces: "from:boss@uni.edu is:unread subject:deadline".
Passing a query filters on Gmail's servers. Not passing one returns all messages up to max_results — then you'd filter in Python. For large inboxes, always prefer server-side.
Create a free account to get started. Paid plans unlock all tracks.