Agent Mail Drafts | Integrations | AutoGPT

Agent Mail Create Draft

What it is

Create a draft email for review or scheduled sending. Use send_at for automatic future delivery.

How it works

The block calls client.inboxes.drafts.create(inbox_id, **params) to create a new draft in the specified inbox. You must provide at least the recipient list; subject, text body, HTML body, cc, bcc, and in_reply_to are all optional.

If you supply send_at, the draft is scheduled for automatic delivery at that time and the returned send_status will be scheduled. If send_at is omitted, the draft remains unsent until you explicitly send it with the Send Draft block. Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address to create the draft in str Yes
to Recipient email addresses (e.g. ['user@example.com']) List[str] Yes
subject Email subject line str No
text Plain text body of the draft str No
html Rich HTML body of the draft str No
cc CC recipient email addresses List[str] No
bcc BCC recipient email addresses List[str] No
in_reply_to Message ID this draft replies to, for threading follow-up drafts str No
send_at Schedule automatic sending at this ISO 8601 datetime str No

Outputs

Output Description Type
error Error message if the operation failed str
draft_id Unique identifier of the created draft str
send_status 'scheduled' if send_at was set, empty otherwise. Values: scheduled, sending, failed. str
result Complete draft object with all metadata Dict[str, Any]

Possible use case


Agent Mail Delete Draft

What it is

Delete a draft or cancel a scheduled email. Removes the draft permanently.

How it works

The block calls client.inboxes.drafts.delete(inbox_id, draft_id) to permanently remove the specified draft. If the draft was scheduled for future delivery, deleting it also cancels that scheduled send.

On success the block yields success=True. Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address the draft belongs to str Yes
draft_id Draft ID to delete (also cancels scheduled sends) str Yes

Outputs

Output Description Type
error Error message if the operation failed str
success True if the draft was successfully deleted/cancelled bool

Possible use case


Agent Mail Get Draft

What it is

Retrieve a draft email to review its contents, recipients, and scheduled send status.

How it works

The block calls client.inboxes.drafts.get(inbox_id, draft_id) to fetch a single draft by its ID. It returns the draft's subject, send status, scheduled send time, and the complete draft object.

Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address the draft belongs to str Yes
draft_id Draft ID to retrieve str Yes

Outputs

Output Description Type
error Error message if the operation failed str
draft_id Unique identifier of the draft str
subject Draft subject line str
send_status Scheduled send status: 'scheduled', 'sending', 'failed', or empty str
send_at Scheduled send time (ISO 8601) if set str
result Complete draft object with all fields Dict[str, Any]

Possible use case


Agent Mail List Drafts

What it is

List drafts in an AgentMail inbox. Filter by labels=['scheduled'] to find pending sends.

How it works

The block calls client.inboxes.drafts.list(inbox_id, **params) to retrieve drafts from a single inbox. You can control page size with limit, paginate with page_token, and filter by labels (for example, ['scheduled'] to find only pending sends).

The block returns the list of draft objects, a count of drafts in the current page, and a next_page_token for fetching subsequent pages. Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address to list drafts from str Yes
limit Maximum number of drafts to return per page (1-100) int No
page_token Token from a previous response to fetch the next page str No
labels Filter drafts by labels (e.g. ['scheduled'] for pending sends) List[str] No

Outputs

Output Description Type
error Error message if the operation failed str
drafts List of draft objects with subject, recipients, send_status, etc. List[Dict[str, Any]]
count Number of drafts returned int
next_page_token Token for the next page. Empty if no more results. str

Possible use case


Agent Mail List Org Drafts

What it is

List all drafts across every inbox in your organization. Use for central approval dashboards.

How it works

The block calls client.drafts.list(**params) at the organization level, so it returns drafts across every inbox without requiring an inbox ID. You can control page size with limit and paginate with page_token.

Inputs

Input Description Type Required
limit Maximum number of drafts to return per page (1-100) int No
page_token Token from a previous response to fetch the next page str No

Outputs

Output Description Type
error Error message if the operation failed str
drafts List of draft objects from all inboxes in the organization List[Dict[str, Any]]
count Number of drafts returned int
next_page_token Token for the next page. Empty if no more results. str

Possible use case


Agent Mail Send Draft

What it is

Send a draft immediately, converting it into a delivered message. The draft is deleted after sending.

How it works

The block calls client.inboxes.drafts.send(inbox_id, draft_id) to deliver the draft immediately. Once the send completes, the draft is deleted from the inbox and a message object is returned in its place.

The block yields the message_id and thread_id of the newly sent email along with the complete message result. Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address the draft belongs to str Yes
draft_id Draft ID to send now str Yes

Outputs

Output Description Type
error Error message if the operation failed str
message_id Message ID of the now-sent email (draft is deleted) str
thread_id Thread ID the sent message belongs to str
result Complete sent message object Dict[str, Any]

Possible use case


Agent Mail Update Draft

What it is

Update a draft's content, recipients, or scheduled send time. Use to reschedule or edit before sending.

How it works

The block calls client.inboxes.drafts.update(inbox_id, draft_id, **params) to modify an existing draft. Only the fields you provide are changed; omitted fields are left untouched. Internally, None is used to distinguish between "omit this field" and "clear this field to empty," so you can selectively update recipients, subject, body, or scheduled send time without affecting other fields.

The block returns the updated draft_id, send_status, and the complete draft result. Any errors propagate to the block framework's global error handler, which yields them on the error output.

Inputs

Input Description Type Required
inbox_id Inbox ID or email address the draft belongs to str Yes
draft_id Draft ID to update str Yes
to Updated recipient email addresses (replaces existing list). Omit to keep current value. List[str] No
subject Updated subject line. Omit to keep current value. str No
text Updated plain text body. Omit to keep current value. str No
html Updated HTML body. Omit to keep current value. str No
send_at Reschedule: new ISO 8601 send time (e.g. '2025-01-20T14:00:00Z'). Omit to keep current value. str No

Outputs

Output Description Type
error Error message if the operation failed str
draft_id The updated draft ID str
send_status Updated send status str
result Complete updated draft object Dict[str, Any]

Possible use case