Gmail
Send, reply, search, and read emails in Gmail. Create drafts, request approvals, and manage your inbox.
On this page
Connect
Auth type: OAuth (oauth2). The connection holds the provider's OAuth tokens. They are sealed on the server and only opened when an action runs.
Scopes requested: https://www.googleapis.com/auth/gmail.sendhttps://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.compose
- From your agent: integrations {action: "connect", piece, credentials, env} stores the credentials for dev, prod or all. Answers name the fields, never the values.
- Or set the integration's project secrets with the secrets tool (SLACK_BOT_TOKEN, DISCORD_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN …): a call uses the connection, else those secrets. integrations {action: "catalog", piece} lists which ones work.
- Try one action now with integrations {action: "call", piece, piece_action, input}. It really sends.
Call it from a workflow
step.ctx.integrations.invoke("gmail", action, input) resolves with the provider's answer and rejects when Gmail isn't connected or refuses. Wrap it in step.run so a retry sends once. See step.ctx. Its actions run through the integration runner, which the server's operator turns on: integrations {action: "catalog", piece: "gmail"} says whether yours can call it.
// workflows/notify.ts: call Gmail when a booking is confirmed
import { on } from "@appbricx/workflows";
export const tellGmail = on.transition("booking", "status", "confirmed", async (_event, step) => {
// Recorded once: a retry doesn't send it twice. Rejects when Gmail isn't connected.
const output = await step.run("Gmail", () =>
step.ctx.integrations.invoke("gmail", "create_draft_reply", {
"message_id": "<message_id>",
"reply_type": "reply",
"body_type": "plain_text",
"include_original_message": true
}),
);
step.ctx.log("Gmail answered", output);
});{
"name": "integrations",
"arguments": {
"project_id": "<project-id>",
"action": "call",
"piece": "gmail",
"piece_action": "create_draft_reply",
"input": {
"message_id": "<message_id>",
"reply_type": "reply",
"body_type": "plain_text",
"include_original_message": true
},
"env": "dev"
}
}curl -X POST "$APP_ORIGIN/__appbricx/connector-proxy/gmail/create_draft_reply" \
-H "Authorization: Bearer $APP_KEY" \
-H "content-type: application/json" \
-d '{"props":{"message_id":"<message_id>","reply_type":"reply","body_type":"plain_text","include_original_message":true}}'Actions
create_draft_reply
Create Draft Reply. Creates a draft reply to an existing email.
| Input | Type | Description |
|---|---|---|
message_idrequired | id (picked from your account) | Select a message from the list or enter a message ID manually. |
reply_typerequired | one of "reply" | "reply_all" | Choose whether to reply to sender only or to all recipients |
body_typerequired | one of "plain_text" | "html" | Body Type |
bodyoptional | long text | Your draft reply message content |
include_original_messagerequired | boolean | Include the original message content in the draft reply |
sender_nameoptional | text | Optional sender name to display |
attachmentoptional | file | Optional file to attach to your draft reply |
attachment_nameoptional | text | Custom name for the attachment |
custom_api_call
Custom API Call. Make a custom API call to a specific endpoint
| Input | Type | Description |
|---|---|---|
urlrequired | object (depends on other props) | url |
methodrequired | one of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD" | Method |
headersrequired | object | Authorization headers are injected automatically from your connection. |
queryParamsrequired | object | Query Parameters |
body_typeoptional | one of "none" | "json" | "form_data" | "raw" | Body Type |
bodyoptional | object (depends on other props) | Body |
response_is_binaryoptional | boolean | Enable for files like PDFs, images, etc. |
failsafeoptional | boolean | No Error on Failure |
timeoutoptional | number | Timeout (in seconds) |
followRedirectsoptional | boolean | Follow redirects |
gmail_get_mail
Get Email. Get an email via Id.
| Input | Type | Description |
|---|---|---|
message_idrequired | text | The messageId of the mail to read. |
gmail_search_mail
Find Email. Find emails using advanced search criteria. At least one search filter (from, to, subject, label, category, date, content, or attachment) is required.
| Input | Type | Description |
|---|---|---|
fromoptional | text | Optional filteration, leave empty to filter based on the email sender |
tooptional | text | Optional filteration, leave empty to filter based on the email recipient |
subjectoptional | text | The email subject |
contentoptional | text | Search for specific text within email body |
has_attachmentoptional | boolean | Only find emails with attachments |
attachment_nameoptional | text | Search for emails with specific attachment filename |
labeloptional | id (picked from your account) | Optional filteration, leave unselected to filter based on the email label |
categoryoptional | one of "primary" | "social" | "promotions" | "updates" | "forums" | "reservations" | "purchases" | Optional filteration, leave unselected to filter based on the email category |
after_dateoptional | date-time (ISO) | Find emails sent after this date |
before_dateoptional | date-time (ISO) | Find emails sent before this date |
include_spam_trashoptional | boolean | Include emails from Spam and Trash folders in search results |
max_resultsoptional | number | Maximum number of emails to return (1-500) |
reply_to_email
Reply to Email. Reply to an existing email.
| Input | Type | Description |
|---|---|---|
message_idrequired | id (picked from your account) | Select a message from the list or enter a message ID manually. |
reply_typerequired | one of "reply" | "reply_all" | Choose whether to reply to sender only or to all recipients |
body_typerequired | one of "plain_text" | "html" | Body Type |
bodyrequired | long text | Your reply message content |
sender_nameoptional | text | Optional sender name to display |
attachmentoptional | file | Optional file to attach to your reply |
attachment_nameoptional | text | Custom name for the attachment |
request_approval_in_mail
Request Approval in Email. Send approval request email and then wait until the email is approved or disapproved
| Input | Type | Description |
|---|---|---|
receiverrequired | text | The email address of the recipient who will receive the approval request. |
ccoptional | array | The email addresses of the recipients who will receive a carbon copy of the approval request. |
bccoptional | array | The email addresses of the recipients who will receive a blind carbon copy of the approval request. |
subjectrequired | text | The subject of the approval request email. |
bodyrequired | text | Body for the email you want to send |
reply_tooptional | array | Email address to set as the "Reply-To" header |
sender_nameoptional | text | Sender Name |
fromoptional | text | The address must be listed in your GMail account's settings |
in_reply_tooptional | text | Reply to this Message-ID |
send_email
Send Email. Send an email through a Gmail account
| Input | Type | Description |
|---|---|---|
receiverrequired | array | Receiver Email (To) |
ccoptional | array | CC Email |
bccoptional | array | BCC Email |
subjectrequired | text | Subject |
body_typerequired | one of "plain_text" | "html" | Body Type |
bodyrequired | text | Body for the email you want to send |
reply_tooptional | array | Email address to set as the "Reply-To" header |
sender_nameoptional | text | Sender Name |
fromoptional | text | The address must be listed in your GMail account's settings |
attachmentsoptional | array | Attachments |
in_reply_tooptional | text | Reply to this Message-ID |
draftrequired | boolean | Create draft without sending the actual email |
Details
- Id
gmail- Category
- Communication
- Tags
- email, google, inbox, mail, send, read
- Package
@activepieces/piece-gmail@0.11.6- Runs
- Through the integration runner