Every Monday morning you open Gmail and scan for anything urgent from your advisor. How many minutes does that take before you actually start working?
Open browser, navigate to Gmail, scan 30–40 subjects, flag the advisor thread. Five minutes minimum, before I've done anything productive.
One Python function replaces all of that. toolset.execute_action is the single call that connects your Python code to any connected app. Pass it the action name and a params dict — it returns a dict with the data you asked for:
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? Real emails, right now?
Real inbox. Real emails. Right now. Welcome to the moment automation gets personal — your data, not toy data.
Why .get("messages", []) instead of result["messages"]? I thought bracket access was normal for dicts.
On an empty inbox, Gmail drops 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 dict:
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 thesis committee thread shows up the moment I run this.
Every Composio action follows the same pattern — one call, one dict response, one safe parse. The count is a starting point; the message IDs inside each dict unlock the full message details you can fetch with GMAIL_GET_MESSAGE.
Every Composio action has the same shape: call toolset.execute_action with an Action enum and a params dict, parse the response safely.
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 you'll parse.
Every Monday morning you open Gmail and scan for anything urgent from your advisor. How many minutes does that take before you actually start working?
Open browser, navigate to Gmail, scan 30–40 subjects, flag the advisor thread. Five minutes minimum, before I've done anything productive.
One Python function replaces all of that. toolset.execute_action is the single call that connects your Python code to any connected app. Pass it the action name and a params dict — it returns a dict with the data you asked for:
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? Real emails, right now?
Real inbox. Real emails. Right now. Welcome to the moment automation gets personal — your data, not toy data.
Why .get("messages", []) instead of result["messages"]? I thought bracket access was normal for dicts.
On an empty inbox, Gmail drops 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 dict:
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 thesis committee thread shows up the moment I run this.
Every Composio action follows the same pattern — one call, one dict response, one safe parse. The count is a starting point; the message IDs inside each dict unlock the full message details you can fetch with GMAIL_GET_MESSAGE.
Every Composio action has the same shape: call toolset.execute_action with an Action enum and a params dict, parse the response safely.
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 you'll parse.
Create a free account to get started. Paid plans unlock all tracks.