Gmail

Send, reply, search, and read emails in Gmail. Create drafts, request approvals, and manage your inbox.

CommunicationOAuth7 actionsAll integrations

On this page
  1. Connect
  2. Call it from a workflow
  3. Actions (7)
  4. create_draft_reply
  5. custom_api_call
  6. gmail_get_mail
  7. gmail_search_mail
  8. reply_to_email
  9. request_approval_in_mail
  10. send_email
  11. Details

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.

Workflow
// 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);
});
Try it from your agent
{
  "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"
  }
}
From another backend (connector proxy)
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.

InputTypeDescription
message_idrequiredid (picked from your account)Select a message from the list or enter a message ID manually.
reply_typerequiredone of "reply" | "reply_all"Choose whether to reply to sender only or to all recipients
body_typerequiredone of "plain_text" | "html"Body Type
bodyoptionallong textYour draft reply message content
include_original_messagerequiredbooleanInclude the original message content in the draft reply
sender_nameoptionaltextOptional sender name to display
attachmentoptionalfileOptional file to attach to your draft reply
attachment_nameoptionaltextCustom name for the attachment

custom_api_call

Custom API Call. Make a custom API call to a specific endpoint

InputTypeDescription
urlrequiredobject (depends on other props)url
methodrequiredone of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD"Method
headersrequiredobjectAuthorization headers are injected automatically from your connection.
queryParamsrequiredobjectQuery Parameters
body_typeoptionalone of "none" | "json" | "form_data" | "raw"Body Type
bodyoptionalobject (depends on other props)Body
response_is_binaryoptionalbooleanEnable for files like PDFs, images, etc.
failsafeoptionalbooleanNo Error on Failure
timeoutoptionalnumberTimeout (in seconds)
followRedirectsoptionalbooleanFollow redirects

gmail_get_mail

Get Email. Get an email via Id.

InputTypeDescription
message_idrequiredtextThe 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.

InputTypeDescription
fromoptionaltextOptional filteration, leave empty to filter based on the email sender
tooptionaltextOptional filteration, leave empty to filter based on the email recipient
subjectoptionaltextThe email subject
contentoptionaltextSearch for specific text within email body
has_attachmentoptionalbooleanOnly find emails with attachments
attachment_nameoptionaltextSearch for emails with specific attachment filename
labeloptionalid (picked from your account)Optional filteration, leave unselected to filter based on the email label
categoryoptionalone of "primary" | "social" | "promotions" | "updates" | "forums" | "reservations" | "purchases"Optional filteration, leave unselected to filter based on the email category
after_dateoptionaldate-time (ISO)Find emails sent after this date
before_dateoptionaldate-time (ISO)Find emails sent before this date
include_spam_trashoptionalbooleanInclude emails from Spam and Trash folders in search results
max_resultsoptionalnumberMaximum number of emails to return (1-500)

reply_to_email

Reply to Email. Reply to an existing email.

InputTypeDescription
message_idrequiredid (picked from your account)Select a message from the list or enter a message ID manually.
reply_typerequiredone of "reply" | "reply_all"Choose whether to reply to sender only or to all recipients
body_typerequiredone of "plain_text" | "html"Body Type
bodyrequiredlong textYour reply message content
sender_nameoptionaltextOptional sender name to display
attachmentoptionalfileOptional file to attach to your reply
attachment_nameoptionaltextCustom 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

InputTypeDescription
receiverrequiredtextThe email address of the recipient who will receive the approval request.
ccoptionalarrayThe email addresses of the recipients who will receive a carbon copy of the approval request.
bccoptionalarrayThe email addresses of the recipients who will receive a blind carbon copy of the approval request.
subjectrequiredtextThe subject of the approval request email.
bodyrequiredtextBody for the email you want to send
reply_tooptionalarrayEmail address to set as the "Reply-To" header
sender_nameoptionaltextSender Name
fromoptionaltextThe address must be listed in your GMail account's settings
in_reply_tooptionaltextReply to this Message-ID

send_email

Send Email. Send an email through a Gmail account

InputTypeDescription
receiverrequiredarrayReceiver Email (To)
ccoptionalarrayCC Email
bccoptionalarrayBCC Email
subjectrequiredtextSubject
body_typerequiredone of "plain_text" | "html"Body Type
bodyrequiredtextBody for the email you want to send
reply_tooptionalarrayEmail address to set as the "Reply-To" header
sender_nameoptionaltextSender Name
fromoptionaltextThe address must be listed in your GMail account's settings
attachmentsoptionalarrayAttachments
in_reply_tooptionaltextReply to this Message-ID
draftrequiredbooleanCreate 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