Jump to a Section

Overview

When you add a Gmail card to a Flow for the first time, you’ll be prompted to create a connection. Connecting your account will enable you to save your account information and reuse that connection the next time you build a Flow with the connector. If you are using a non-enterprise gmail.com or googlemail.com account, then you will not be able to establish a connection for the Gmail connector or execute any Flow that contains a Gmail card.

Note: You can create multiple connections and manage them from your Settings page.

To create a new connection from an Event or Action card:

  1. Click New Connection.
  2. Enter a Connection Nickname for your G Suite account. The nickname can be the actual name of the account or a generic nickname. Note: gmail.com and googlemail.com accounts are not supported.
  3. In the OAuth window, enter your Google account and password information.
  4. On the card, authorize access to your Google account by clicking Allow.

Supported Scopes

https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email
openid
https://www.googleapis.com/auth/gmail.settings.basic
https://www.googleapis.com/auth/gmail.settings.sharing
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.readonly

Disclaimer Statement

The app’s use of information received from Gmail APIs will adhere to Google’s Limited Use Requirements.

  • Gmail Errors

    General

    For information on specific errors returned from the Gmail API, see the Gmail API reference.

    For possible service outages, check the status of the Gmail API.

    Authentication

    For issues connecting to your Gmail account, go to Settings > Accounts. Locate the account and then click Reauthorize. Or, delete the account and then add it again.

    We are constantly aggregating more data about errors, so if this article doesn’t help solve your problem, check back soon.

To use Gmail transfer of ownership features, you need to set up a Google Cloud project and service account. The API endpoints that are needed to add a delegate or forward emails are only available to service accounts that have been given domain-wide authority.

In order to perform the steps in this topic, you must have admin access to a G Suite domain and Google Cloud Platform.

Create a Google Cloud Project

Note: It is not necessary to create a new project to complete this procedure. If you already have a Google Cloud project, then go to step 5.

To create a Google Cloud Project: 1. Go to Google Cloud Platform: https://console.cloud.google.com. 1. Click the Quickstart drop-down in the top navigation bar. The project dialog appears. 1. From the drop-down, select an organization, then click NEW PROJECT. 1. Add a project name to the Project name field, and click Create.

Enable the Gmail API for Google Cloud Project

To enable the Gmail API: 1. In the left navigation pane, select APIs & Services > Library. 1. In the search field, type Gmail. The search results will show Gmail API. 1. Click Gmail API then Enable on the Gmail API page.

You have created a Google Cloud project and enabled the Gmail API for it.

Create a Service Account for the Google Cloud Project

To create a service account: 1. In the left navigation pane, select IAM & Admin > Service Accounts. 1. At the top of the Service accounts page, click CREATE SERVICE ACCOUNT. 1. Add a service account name and description (optional) in the Service account details section, then click CREATE. 1. On the Service account permissions (optional) page, click Continue. This step will be completed later. 1. On the Grant users access to this service page, click DONE. This step will also be completed later.

You have created a service account.

Set Up G Suite Domain-Wide Delegation of Authority

To use the endpoints to add a delegate or forward a user’s emails, you need a Google Cloud service account with domain-wide authority. By enabling domain-wide authority for a service account, you allow the service account to programatically access a user’s data without any manual authorization on their part.

To set up domain-wide delegation of authority: 1. Find the service account that you created in the previous task. 1. Click on the name of the service account or Actions menu for that account name and select Edit. 1. Click the SHOW DOMAIN-WIDE DELEGATION drop-down. 1. In the header bar, click Edit. 1. Select the Enable G Suite Domain-wide Delegation box. 1. Add a name in the Product name for the consent screen field, and click Save.

You have set up G Suite domain-wide delegation for your project. The Client ID field is now populated with a value for the service account that will be associated with the G Suite account. Take note of that Client ID value.

Register and Add Scopes to the Service Account in G Suite Domain

To register your service account and add scopes:

  1. Go to https://admin.google.com
  2. If necessary, authenticate with your login credentials.
  3. Select Security.
  4. Select Advanced Settings.
  5. Click Manage API client access.
  6. In the Authorized API clients list, add the Client ID that was generated in the previous task in the Client Name field.
  7. In the One or More API Scopes field, add the required scopes. For adding a delegate or forwarding emails, the required scopes are:
  8. https://www.googleapis.com/auth/gmail.settings.basic
  9. https://www.googleapis.com/auth/gmail.settings.sharing
  10. Click Authorize, then click Save.

You have regisered your service account with the G Suite domain and added the appropriate permissions (scopes) to the account. The service account can now access users’ data in the G Suite domain.

Add users and assign roles in the Google Cloud project

Each user in your Google Cloud project needs permissions to use the Add Delegate, Forward Emails, or Set Auto Reply action card in the Workflows Gmail connector. Each user will need the role of Service Account User on the project level. This role will allow a user to load dynamic dropdown parameters in the action cards.

Each user will also need the role of Service Account Token Creator on the service account level. This role assigns the user permissions to generae short-lived credentials for the service account so that it can access user data in the G Suite domain.

To add user and assign the Service Account User role: 1. Go to https://console.cloud.google.com 1. Find your Google Cloud project and service account. 1. From the left navigation pane, click IAM & Admin. 1. Select IAM. 1. Click ADD. 1. In the New members field, add the user’s email address. 1. In the Select a role dropdown, select Service Accounts > Service Account User. 1. Click Save.

To add user and assign the Service Account Token Creator role: 1. From the left navigation pane, click IAM & Admin. 1. Click Service Accounts. 1. Click the checkbox for your service account, then click SHOW INFO PANEL. 1. In the Permissions section, click ADD MEMBER. 1. In the New members field, add the user’s email address. 1. In the Select a role dropdown, select Service Accounts > Service Account Token Creator. 1. Click Save.

You have added a user to your Google Project who can authenticate to the Workflows Gmail connector and use the Add Delegate, Forward Emails, and Set Auto Reply action cards.

  • Gmail Errors

    General

    For information on specific errors returned from the Gmail API, see the Gmail API reference.

    For possible service outages, check the status of the Gmail API.

    Authentication

    For issues connecting to your Gmail account, go to Settings > Accounts. Locate the account and then click Reauthorize. Or, delete the account and then add it again.

    We are constantly aggregating more data about errors, so if this article doesn’t help solve your problem, check back soon.

Events

  • Label Added or Removed

    Trigger a flow when a label is applied to or removed from a message in your inbox. For more information, refer to Gmail’s documentation.

    Unless otherwise indicated, field types are text. Note that senders and recipients are formatted as - Name <email@email.com>.

    Output

    • Labels
      • Label Added: title of the new label
      • Label Removed: title of the removed label
    • Email
      • Message ID: unique ID of the message
      • Thread ID: unique ID of the message thread (new, non-threaded messages have the same message and thread IDs)
      • Subject: subject line of the email
      • To: recipient of the email
      • Text Body: text in the body of the message
      • HTML Body: HTML formatted body of the message
      • From: sender of the email
      • CC (list of text): list of carbon copied recipients
      • BCC (list of text): list of blind carbon copied recipients
      • Attachment IDs (list of text): list of unique IDs of the email attachments
      • Labels (list of text): list of categories attributed to the message (for example, Unread, Important, or Category_Personal)
    • Context
      • Execution ID: unique ID of the flow instance
  • New Email

    Trigger a flow when you recieve a new email. For more information, refer to Gmail’s documentation.

    Unless otherwise indicated, field types are text. Note that senders and recipients are formatted as - Name <email@email.com>.

    Output

    • Email
      • Message ID: unique ID of the message
      • Thread ID: unique ID of the message thread (new, non-threaded messages have the same message and thread IDs)
      • To: recipient of the email
      • From: sender of the email
      • Text Body: text in the body of the message
      • HTML Body: HTML formatted body of the message
      • CC (list of text): list of carbon copied recipients
      • BCC (list of text): list of blind carbon copied recipients
      • Labels (list of text): list of categories attributed to the message (for example, Unread, Important, or Category_Personal)
      • Attachment IDs (list of text): list of unique IDs of the email attachments
        • filename: name of the attachment
        • attachmentID: unique ID of the attachment
        • messageID: Message ID of the email (see above)
        • type: file type (for example, .png or .jpeg)

Actions

  • Add Delegate

    Add a delegate to a user account in the same G Suite organization.

    The user granting access is referred to as the delegator and the user receiving the access is the delegate.

    To use this action card, you must first set up a Google Cloud project and service account. See Set up a Google Cloud Project and Service Account.

    Unless otherwise indicated, field types are text.

    Required fields are indicated by a red asterisk on the Action card.

    Options

    • Google Cloud Platform Project (drop-down): project to which the user belongs
    • Service Account (drop-down): service account to which the user belongs

    Input

    • Delegator
      • Email: delegator’s email address
    • Delegate
      • Email: delegate’s email address

    Output

    • Result
      • Delegate Email: delegate’s email address
      • Verification Status: indicates whether this email address has been verified and can act as a delegate for the account; values are accepted, expired, pending, rejected, or verificationStatusUnspecified.
  • Forward Emails

    Create a forwarding address.

    To use this action card, you must first set up a Google Cloud project and service account. See Set up a Google Cloud Project and Service Account.

    Unless otherwise indicated, field types are text.

    Required fields are indicated by a red asterisk on the Action card.

    Options

    • Google Cloud Platform Project (drop-down): project to which the user belongs
    • Service Account (drop-down): service account to which the user belongs

    Input

    • Forward From
      • Email: email address from which messages can be forwarded
    • Forward To
      • Email: email address to which messages can be forwarded

    Output

    • Result
      • Forwarding Email: email address to which messages can be forwarded
      • Enabled: indicates whether forwarded is enabled or not. Values are true or false.
      • Disposition: indicates the state that a message should be left in after it has been forwarded; values are: archive: archive the message
        dispositionUnspecified: unspecified disposition
        leaveInInbox: leave the message in the inbox
        markRead: leave the message in the inbox and mark it as read
        trash: move the message to the trash
  • Read Email

    Read a message received in Gmail. Pair this action card with an earlier event or action, such as New Email.

    Unless otherwise indicated, field types are text. Note that senders and recipients are formatted as - Name <email@email.com>.

    Input

    • Read
      • Message ID: unique ID of the message

    Output

    • Email
      • Thread ID: unique ID of the message thread (new, non-threaded messages have the same message and thread IDs)
      • Subject: subject heading of the message
      • Text Body: text in the body of the message
      • HTML Body: HTML formatted body of the message
      • From: sender of the email
      • CC (list of text): list of carbon copied recipients
      • Attachment IDs (list of text): list of unique IDs of the email attachments
        • filename: name of the attachment
        • attachmentID: unique ID of the attachment
        • messageID: Message ID of the email (see above)
        • type: file type (for example, .png or .jpeg)
      • Labels (list of text): list of categories attributed to the message (for example, Unread, Important, or Category_Personal)
  • Search Emails

    Search for an email or multiple emails. For more information, refer to Gmail’s Documentation.

    Unless otherwise indicated, field types are text.

    Options

    • Result Set (drop-down)
      • First matching email: return the first email message that meets the search criteria
      • All matching emails: return all email messages that match the search criteria

    Input

    • Search
      • Query: return only the messages that match the specified query (supports the same query format as the Gmail search box, such as “from:someuser@example.com rfc822msgid:somemsgid@example.com is:unread”. More Info
      • With Label IDs: labels to include in message filtering (such as Important, Starred, or Spam)
      • Max Result Size (number): specify the maximum number of emails to retrieve when All Matching Emails is selected
      • Page Token (string): retrieve a specific page of results in the list

    Output

    • Result for First Matching Email

      • Message ID: unique ID of the message
      • Subject: subject of the message
      • Text Body: text in the body of the message
    • Result for All Matching Emails

      • Emails (list): list of email objects returned from the search
  • Send Email

    Send email from a Gmail account. You can choose HTML, which enables you to format the email message, or plain text.

    If the recipient is always the same, type the email address directly into the To input field. If the recipient changes each time the flow runs, map an input from a previous action or function card.

    Unless otherwise indicated, field types are text.

    Options

    • Body is HTML? (drop-down): indicate whether the body of the email is HTML or plain text

    Input

    • Email
      • To (list of text): email addresses of the message recipients (format multiple addresses in a list of individual emails or as a single text string separated by commas or semicolons)
      • CC (list of text): list of carbon copied recipients
      • Subject: subject of the message
      • Body: content of the message (plain text or HTML depending on the the Options setting)

    Output

    • Email
      • MessageID: unique ID of the email generated by Gmail
  • Set Auto Reply

    Set auto reply for an email address.

    To use this action card, you must first set up a Google Cloud project and service account. See Set up a Google Cloud Project and Service Account.

    Unless otherwise indicated, field types are text.

    Required fields are indicated by a red asterisk on the Action card.

    Options

    • Google Cloud Platform Project (drop-down): project to which the user belongs
    • Service Account (drop-down): service account to which the user belongs

    Input

    • Auto Reply
      • Email address: email for which an auto-reply will be set
      • Restrict to Domain: indicates whether an auto-reply should be sent to recipients who are outside the account’s domain; values are true or false.
      • Restrict to Contacts: indicates whether an auto-reply should be sent to recipients who are not in the user’s list of contacts; values are true or false.
      • Start Time: optional start time for sending an auto-reply
      • End Time: optional end time for sending an auto-reply
      • Response Subject: optional text to prepend to the subject line in an auto-reply
      • Response Body Plain Text: response body of an auto-reply in plain text format
      • Response Body HTML: response body of an auto-reply in HTMl format

    Output

    • Result
      • Enable Auto Reply: indicates whether auto reply is enabled; values are true or false.
      • Email: email address for which auto reply is set
      • Restrict to Domain: indicates whether an auto-reply should be sent to recipients who are outside the account’s domain; values are true or false.
      • Restrict to Contacts: indicates whether an auto-reply should be sent to recipients who are not in the user’s list of contacts; values are true or false.
      • Start Time: optional start time for sending an auto-reply
      • End Time: optional end time for sending an auto-reply
      • Response Subject: optional text to prepend to the subject line in an auto-reply
      • Response Body Plain Text: response body of an auto-reply in plain text format
      • Response Body HTML: response body of an auto-reply in HTMl format