Your get_email reads one message by ID. But your investor threads aren't tagged with IDs you know — they're in your inbox mixed with everything else. How do you find just the investor emails?
After get_email I can read messages. But finding them still requires knowing their IDs first. In Gmail I'd use the search bar — from:investor@example.com is:unread.
That's exactly the query you pass to GMAIL_FETCH_EMAILS. The same Gmail search syntax — from:, is:unread, subject:, label: — works as the query parameter:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "from:investor@example.com is:unread", "max_results": 10}
)
messages = result.get("messages", [])So GMAIL_FETCH_EMAILS is both the 'count my inbox' action AND the 'search' action? The same action handles both?
Same action — different params. Without query, it returns the recent inbox. With query, it filters. The response shape is identical. Here's the full function:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query, "max_results": 20}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} messages matching '{query}'")
return messagesSo search_emails('from:investor is:unread') returns my unread investor threads as a list. I can loop over them and call get_email on each one to build a full audit.
Your investor email audit is now a two-line loop. The Gmail search bar just became a Python argument.
I went from 'count emails' to 'search emails by sender' in one lesson. The compose chain — search, then read each result — is already obvious.
Gmail query syntax is documented at developers.google.com/gmail/api/guides/filtering. Useful operators: from:, to:, subject:, is:unread, is:starred, after:2024/01/01, label:inbox. Master these and your inbox becomes a queryable database.
Pass any Gmail search string as the query param to GMAIL_FETCH_EMAILS. Mastering query syntax turns your inbox into a queryable database — essential for automating investor thread monitoring and customer follow-up workflows.
| Query | Finds |
|---|---|
from:person@co.com | Emails from that sender |
is:unread | Unread messages |
subject:Update | Subject contains 'Update' |
label:inbox | Only inbox messages |
Combined: from:x is:unread | Unread from sender |
The query param is optional. Omitting it returns recent inbox messages unfiltered — same action, different behaviour.
Your get_email reads one message by ID. But your investor threads aren't tagged with IDs you know — they're in your inbox mixed with everything else. How do you find just the investor emails?
After get_email I can read messages. But finding them still requires knowing their IDs first. In Gmail I'd use the search bar — from:investor@example.com is:unread.
That's exactly the query you pass to GMAIL_FETCH_EMAILS. The same Gmail search syntax — from:, is:unread, subject:, label: — works as the query parameter:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": "from:investor@example.com is:unread", "max_results": 10}
)
messages = result.get("messages", [])So GMAIL_FETCH_EMAILS is both the 'count my inbox' action AND the 'search' action? The same action handles both?
Same action — different params. Without query, it returns the recent inbox. With query, it filters. The response shape is identical. Here's the full function:
def search_emails(query: str) -> list:
result = toolset.execute_action(
Action.GMAIL_FETCH_EMAILS,
{"query": query, "max_results": 20}
)
messages = result.get("messages", [])
print(f"Found {len(messages)} messages matching '{query}'")
return messagesSo search_emails('from:investor is:unread') returns my unread investor threads as a list. I can loop over them and call get_email on each one to build a full audit.
Your investor email audit is now a two-line loop. The Gmail search bar just became a Python argument.
I went from 'count emails' to 'search emails by sender' in one lesson. The compose chain — search, then read each result — is already obvious.
Gmail query syntax is documented at developers.google.com/gmail/api/guides/filtering. Useful operators: from:, to:, subject:, is:unread, is:starred, after:2024/01/01, label:inbox. Master these and your inbox becomes a queryable database.
Pass any Gmail search string as the query param to GMAIL_FETCH_EMAILS. Mastering query syntax turns your inbox into a queryable database — essential for automating investor thread monitoring and customer follow-up workflows.
| Query | Finds |
|---|---|
from:person@co.com | Emails from that sender |
is:unread | Unread messages |
subject:Update | Subject contains 'Update' |
label:inbox | Only inbox messages |
Combined: from:x is:unread | Unread from sender |
The query param is optional. Omitting it returns recent inbox messages unfiltered — same action, different behaviour.
Create a free account to get started. Paid plans unlock all tracks.