Every function so far has been a read — ask Gmail a question, get a dict back. Today you write for the first time. What do you think changes in the shape of the code?
Probably the action name, and the params would need more fields — a subject, a body, maybe a recipient?
Exactly right. Action.GMAIL_CREATE_EMAIL_DRAFT takes subject and body in its params, and the response includes the draft's new id. Same calling shape, different action enum and different params:
result = toolset.execute_action(Action.GMAIL_CREATE_EMAIL_DRAFT, {
"subject": "Weekly review",
"body": "Let's sync on Friday."
})The draft just appears in my Drafts folder? Gmail handles the formatting, the timestamp, all of that?
Yes. You give Gmail the text, Gmail writes the message. The response dict carries the new draft's id back so your function can prove the write worked and the caller knows which draft to open:
def create_draft(subject: str, body: str) -> dict:
result = toolset.execute_action(Action.GMAIL_CREATE_EMAIL_DRAFT, {
"subject": subject,
"body": body,
})
return resultSo the function just returns the whole result dict? No .get(), no unpacking?
Right — for write actions you usually hand the full response up to the caller. They can pull id or threadId or labelIds from it as needed. The create action's job is to report what happened; interpreting the response is the caller's choice.
So my code now changes Gmail — a new draft shows up in my browser the moment the test passes?
Refresh your Drafts folder after the test runs. The message with the subject you passed will be sitting there. That is the moment automation stops being theory.
TL;DR: Write actions use the same toolset.execute_action shape, just a different enum and params.
Action.GMAIL_CREATE_EMAIL_DRAFT{"subject": ..., "body": ...}id, threadId, labelIds| Read | Write |
|---|---|
FETCH/SEARCH/LIST | CREATE/SEND/UPDATE |
| no side effect | changes your Gmail |
| returns data | returns what was created |
Returning the whole dict lets the caller pick the field they need.
Every function so far has been a read — ask Gmail a question, get a dict back. Today you write for the first time. What do you think changes in the shape of the code?
Probably the action name, and the params would need more fields — a subject, a body, maybe a recipient?
Exactly right. Action.GMAIL_CREATE_EMAIL_DRAFT takes subject and body in its params, and the response includes the draft's new id. Same calling shape, different action enum and different params:
result = toolset.execute_action(Action.GMAIL_CREATE_EMAIL_DRAFT, {
"subject": "Weekly review",
"body": "Let's sync on Friday."
})The draft just appears in my Drafts folder? Gmail handles the formatting, the timestamp, all of that?
Yes. You give Gmail the text, Gmail writes the message. The response dict carries the new draft's id back so your function can prove the write worked and the caller knows which draft to open:
def create_draft(subject: str, body: str) -> dict:
result = toolset.execute_action(Action.GMAIL_CREATE_EMAIL_DRAFT, {
"subject": subject,
"body": body,
})
return resultSo the function just returns the whole result dict? No .get(), no unpacking?
Right — for write actions you usually hand the full response up to the caller. They can pull id or threadId or labelIds from it as needed. The create action's job is to report what happened; interpreting the response is the caller's choice.
So my code now changes Gmail — a new draft shows up in my browser the moment the test passes?
Refresh your Drafts folder after the test runs. The message with the subject you passed will be sitting there. That is the moment automation stops being theory.
TL;DR: Write actions use the same toolset.execute_action shape, just a different enum and params.
Action.GMAIL_CREATE_EMAIL_DRAFT{"subject": ..., "body": ...}id, threadId, labelIds| Read | Write |
|---|---|
FETCH/SEARCH/LIST | CREATE/SEND/UPDATE |
| no side effect | changes your Gmail |
| returns data | returns what was created |
Returning the whole dict lets the caller pick the field they need.
Create a free account to get started. Paid plans unlock all tracks.