Integrations / Gmail
Gmail
Read, search and draft email in a connected Gmail account.
6 actions
OAuth 2
3 read2 write1 destructive
Calls gmail.googleapis.com
Connect
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "gmail" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();Permissions requested
| Scope | Why it is requested |
|---|---|
https://www.googleapis.com/auth/userinfo.email | See which Google account you connected |
https://www.googleapis.com/auth/gmail.readonly | Read your email messages and settings |
https://www.googleapis.com/auth/gmail.compose | Create drafts and send email for you |
Actions
Create draftwritegmail.create_draftSave an email as a draft in Gmail without sending it. Safe way to let an AI prepare a reply.
Needs scope: https://www.googleapis.com/auth/gmail.compose
| Input | Type | Description | |
|---|---|---|---|
to | string | Required | Recipient address, or several separated by commas |
cc | string | Optional | Optional cc address |
subject | string | Required | Subject line |
text | string | Required | Plain text body |
thread_id | string | Optional | Optional thread ID to reply into |
await setu.execute({
userId: "user_1",
action: "gmail.create_draft",
input: {
"to": "<to>",
"subject": "<subject>",
"text": "<text>"
},
});Delete draftdestructivegmail.delete_draftDelete a draft from Gmail.
Needs scope: https://www.googleapis.com/auth/gmail.compose
| Input | Type | Description | |
|---|---|---|---|
draft_id | string | Required | Draft ID |
await setu.execute({
userId: "user_1",
action: "gmail.delete_draft",
input: {
"draft_id": "<draft_id>"
},
confirm: true,
});Get messagereadgmail.get_messageRead one message: its headers, a short snippet and the encoded body.
Needs scope: https://www.googleapis.com/auth/gmail.readonly
| Input | Type | Description | |
|---|---|---|---|
message_id | string | Required | Message ID from list_messages |
format | string | Optional | metadata is smallest, full includes the body |
await setu.execute({
userId: "user_1",
action: "gmail.get_message",
input: {
"message_id": "<message_id>"
},
});List labelsreadgmail.list_labelsList the labels in the mailbox, such as Inbox, Sent and custom labels.
Needs scope: https://www.googleapis.com/auth/gmail.readonly
No input.
await setu.execute({
userId: "user_1",
action: "gmail.list_labels",
input: {},
});List messagesreadgmail.list_messagesSearch or list recent messages. Use Gmail search syntax in q, for example from:alice newer_than:7d.
Needs scope: https://www.googleapis.com/auth/gmail.readonly
| Input | Type | Description | |
|---|---|---|---|
q | string | Optional | Gmail search query |
max_results | integer | Optional | Up to 100 |
page_token | string | Optional | From a previous call |
await setu.execute({
userId: "user_1",
action: "gmail.list_messages",
input: {},
});Send emailwritegmail.send_emailSend an email from the connected Gmail account. This cannot be unsent, so it should be approved first.
Needs scope: https://www.googleapis.com/auth/gmail.compose
| Input | Type | Description | |
|---|---|---|---|
to | string | Required | Recipient address, or several separated by commas |
cc | string | Optional | Optional cc address |
subject | string | Required | Subject line |
text | string | Required | Plain text body |
thread_id | string | Optional | Optional thread ID to reply into |
await setu.execute({
userId: "user_1",
action: "gmail.send_email",
input: {
"to": "<to>",
"subject": "<subject>",
"text": "<text>"
},
});