count_emails from Day 3 gives you a list of message dicts — each one has an id field. Your co-author sent a reply with the subject "Manuscript revision — round 3". How do you read the full message?
count_emails returns the count from the messages list — each message has an id. I'd take one of those IDs and pass it to a fetch action to get the full content.
Exactly the list-then-fetch pattern. GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID takes one message ID and returns the full email — subject, sender, body snippet. The response is a dict you parse the same way:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
subject = result.get("subject", "")
sender = result.get("from", "")Why two actions? Why doesn't GMAIL_FETCH_EMAILS just return the full body directly?
API efficiency. Fetching full bodies for 40 messages at once transfers a lot of data. GMAIL_FETCH_EMAILS returns lightweight summaries — IDs and snippets — so you scan quickly. You only fetch full content for the messages that matter. Same pattern as filter_eligible in the Python track: filter first, fetch detail for what passes.
So the workflow is: count_emails to get IDs, then get_email on the ones with "revision" in the subject. That's the inbox triage I described on Day 3.
Triage without opening a browser. That's what automation feels like:
def get_email(msg_id: str) -> dict:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
print(f"Fetched: {result.get('subject', 'no subject')}")
return resultI'm reading my actual co-author emails from a Python function. That's a genuinely new research tool.
One thing to note: GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID fetches a single message at a time. For bulk operations — like archiving all "sounds good" replies — loop over the IDs from count_emails and call get_email for each. Tests use a real message ID from your inbox, so the first test run is worth doing interactively.
This pattern appears in every REST API in this track:
GMAIL_FETCH_EMAILS)GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID)# Step 1: get IDs
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10})
messages = result.get("messages", [])
# Step 2: fetch full details for the first message
if messages:
full = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": messages[0]["id"]}
)The full message dict typically includes subject, from, to, snippet, body. Use .get(key, "") for all of them — the shape can vary.
count_emails from Day 3 gives you a list of message dicts — each one has an id field. Your co-author sent a reply with the subject "Manuscript revision — round 3". How do you read the full message?
count_emails returns the count from the messages list — each message has an id. I'd take one of those IDs and pass it to a fetch action to get the full content.
Exactly the list-then-fetch pattern. GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID takes one message ID and returns the full email — subject, sender, body snippet. The response is a dict you parse the same way:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
subject = result.get("subject", "")
sender = result.get("from", "")Why two actions? Why doesn't GMAIL_FETCH_EMAILS just return the full body directly?
API efficiency. Fetching full bodies for 40 messages at once transfers a lot of data. GMAIL_FETCH_EMAILS returns lightweight summaries — IDs and snippets — so you scan quickly. You only fetch full content for the messages that matter. Same pattern as filter_eligible in the Python track: filter first, fetch detail for what passes.
So the workflow is: count_emails to get IDs, then get_email on the ones with "revision" in the subject. That's the inbox triage I described on Day 3.
Triage without opening a browser. That's what automation feels like:
def get_email(msg_id: str) -> dict:
result = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": msg_id}
)
print(f"Fetched: {result.get('subject', 'no subject')}")
return resultI'm reading my actual co-author emails from a Python function. That's a genuinely new research tool.
One thing to note: GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID fetches a single message at a time. For bulk operations — like archiving all "sounds good" replies — loop over the IDs from count_emails and call get_email for each. Tests use a real message ID from your inbox, so the first test run is worth doing interactively.
This pattern appears in every REST API in this track:
GMAIL_FETCH_EMAILS)GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID)# Step 1: get IDs
result = toolset.execute_action(Action.GMAIL_FETCH_EMAILS, {"max_results": 10})
messages = result.get("messages", [])
# Step 2: fetch full details for the first message
if messages:
full = toolset.execute_action(
Action.GMAIL_FETCH_MESSAGE_BY_MESSAGE_ID,
{"message_id": messages[0]["id"]}
)The full message dict typically includes subject, from, to, snippet, body. Use .get(key, "") for all of them — the shape can vary.
Create a free account to get started. Paid plans unlock all tracks.