count_emails from yesterday gives you how many messages arrived. But your advisor sends three emails a week and you need to know which one is about the committee meeting. The count tells you nothing — the subject does. How do you get from an ID to a full message?
count_emails returns the count but the IDs are inside the response. I'd need to fetch one of those IDs to see the full message content.
Same toolset.execute_action structure, different action. GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID takes the message ID and returns the full dict — subject, from address, body. Every Composio action is just a different namespace of the same call pattern:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": "abc123"}
)
subject = result.get("subject", "")
sender = result.get("from", "")
print(f"From: {sender} | Subject: {subject}")result.get("subject", "") — using .get() again? Does Gmail ever drop the subject key?
Not commonly, but draft messages and system notifications sometimes have empty subjects. .get(key, "") is the safe reflex — you get a usable string either way, no crash:
def get_email(msg_id: str) -> dict:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
subject = result.get("subject", "")
sender = result.get("from", "")
print(f"From: {sender} | Subject: {subject}")
return resultThe whole message dict comes back — I can read the body, check the date, everything. That's my advisor thread, fetched with one function call.
Your inbox-scanning Monday ritual just became a for loop over message IDs.
I built count_emails as the list step and now get_email is the detail step. They chain naturally.
Return the full result dict, not just the subject. Callers decide which fields they need — the function should hand back all available data and let the caller extract what's relevant. Narrow the output only when you control both sides of the interface.
Gmail message IDs come from GMAIL_FETCH_EMAILS — each {"id": "abc"} in the messages list. Pass one to GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID to get the full message.
| Field | Type | Content |
|---|---|---|
subject | str | Email subject line |
from | str | Sender email address |
body | str | Message body text |
date | str | Received timestamp |
Always use .get(key, "") — sparse responses may omit optional fields.
count_emails from yesterday gives you how many messages arrived. But your advisor sends three emails a week and you need to know which one is about the committee meeting. The count tells you nothing — the subject does. How do you get from an ID to a full message?
count_emails returns the count but the IDs are inside the response. I'd need to fetch one of those IDs to see the full message content.
Same toolset.execute_action structure, different action. GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID takes the message ID and returns the full dict — subject, from address, body. Every Composio action is just a different namespace of the same call pattern:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": "abc123"}
)
subject = result.get("subject", "")
sender = result.get("from", "")
print(f"From: {sender} | Subject: {subject}")result.get("subject", "") — using .get() again? Does Gmail ever drop the subject key?
Not commonly, but draft messages and system notifications sometimes have empty subjects. .get(key, "") is the safe reflex — you get a usable string either way, no crash:
def get_email(msg_id: str) -> dict:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
subject = result.get("subject", "")
sender = result.get("from", "")
print(f"From: {sender} | Subject: {subject}")
return resultThe whole message dict comes back — I can read the body, check the date, everything. That's my advisor thread, fetched with one function call.
Your inbox-scanning Monday ritual just became a for loop over message IDs.
I built count_emails as the list step and now get_email is the detail step. They chain naturally.
Return the full result dict, not just the subject. Callers decide which fields they need — the function should hand back all available data and let the caller extract what's relevant. Narrow the output only when you control both sides of the interface.
Gmail message IDs come from GMAIL_FETCH_EMAILS — each {"id": "abc"} in the messages list. Pass one to GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID to get the full message.
| Field | Type | Content |
|---|---|---|
subject | str | Email subject line |
from | str | Sender email address |
body | str | Message body text |
date | str | Received timestamp |
Always use .get(key, "") — sparse responses may omit optional fields.
Create a free account to get started. Paid plans unlock all tracks.