Picture your inbox right now. How many of those emails would you pay $50 to process automatically instead of manually?
Honestly? Most of my investor update thread. I compile the same data every Monday and reply to the same questions. It's burning at least an hour a week.
That hour is what this week reclaims. toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10}) — your inbox is now a Python variable. One call, one dict back, .get("messages", []) for the list:
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10})
messages = result.get("messages", [])
count = len(messages)
print(f"Found {count} emails in your inbox")Wait — that's actually my inbox coming back? Not a mock?
Real inbox, real data. That's Composio — the OAuth is already handled. Welcome to the part where automation gets personal. Your data, not toy data.
Why .get("messages", []) instead of just result["messages"]? I thought bracket access was standard.
On an empty inbox, Gmail may drop the messages key entirely. result["messages"] raises KeyError and your script crashes. .get("messages", []) falls back to an empty list — len() returns 0 cleanly. Make .get(key, default) your reflex for every API response. Here's the full function:
def count_emails(max_results: int) -> int:
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": max_results})
messages = result.get("messages", [])
count = len(messages)
print(f"Found {count} emails in your inbox")
return countFive lines and I've replaced my entire Monday inbox scan. My ops brain is having a moment.
That moment never gets old. Every app this week follows the same shape — one action, one dict response, one safe parse. The count is a starting point; the message IDs inside each dict unlock the rest.
Every Composio action has the same shape: call toolset.execute_action with an Action enum and a params dict, parse what comes back.
Gmail returns {"messages": [{"id": "abc"}, ...]}. The messages key holds a list; each object has an id you can use to fetch full details.
.get() beats []| Access | Empty inbox |
|---|---|
result["messages"] | KeyError — crashes |
result.get("messages", []) | [] — len() returns 0 |
.get(key, default) is the reflex for every API response dict.
Picture your inbox right now. How many of those emails would you pay $50 to process automatically instead of manually?
Honestly? Most of my investor update thread. I compile the same data every Monday and reply to the same questions. It's burning at least an hour a week.
That hour is what this week reclaims. toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10}) — your inbox is now a Python variable. One call, one dict back, .get("messages", []) for the list:
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10})
messages = result.get("messages", [])
count = len(messages)
print(f"Found {count} emails in your inbox")Wait — that's actually my inbox coming back? Not a mock?
Real inbox, real data. That's Composio — the OAuth is already handled. Welcome to the part where automation gets personal. Your data, not toy data.
Why .get("messages", []) instead of just result["messages"]? I thought bracket access was standard.
On an empty inbox, Gmail may drop the messages key entirely. result["messages"] raises KeyError and your script crashes. .get("messages", []) falls back to an empty list — len() returns 0 cleanly. Make .get(key, default) your reflex for every API response. Here's the full function:
def count_emails(max_results: int) -> int:
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": max_results})
messages = result.get("messages", [])
count = len(messages)
print(f"Found {count} emails in your inbox")
return countFive lines and I've replaced my entire Monday inbox scan. My ops brain is having a moment.
That moment never gets old. Every app this week follows the same shape — one action, one dict response, one safe parse. The count is a starting point; the message IDs inside each dict unlock the rest.
Every Composio action has the same shape: call toolset.execute_action with an Action enum and a params dict, parse what comes back.
Gmail returns {"messages": [{"id": "abc"}, ...]}. The messages key holds a list; each object has an id you can use to fetch full details.
.get() beats []| Access | Empty inbox |
|---|---|
result["messages"] | KeyError — crashes |
result.get("messages", []) | [] — len() returns 0 |
.get(key, default) is the reflex for every API response dict.
Create a free account to get started. Paid plans unlock all tracks.