Skip to content

Gmail Webhook

Gmail Webhook starts a flow every time something happens in your Gmail mailbox: a new email arrives, an email is deleted, or a label is added to or removed from an email. You can limit it to the labels you care about, for example just the inbox.

NappAI checks your mailbox about once a minute and, if it finds changes, runs the flow with the details of each email affected. You don’t have to set anything up in Google: the credential and subscribing the flow are enough.

When to use it

  • You want an AI agent to read every email that reaches the inbox and draft a reply.
  • Orders or invoices arrive by email and you want to record them in a spreadsheet as soon as they come in.
  • You want to notify your team when someone marks an email as important or starred.
  • You need to keep a record of the emails deleted from a shared account.

Configuration

You need a Google Gmail credential, which connects by signing in with your Google account. See Credentials.

FieldWhat it does
Credential (required)The Google Gmail credential of the account you want to watch.
EventsThe changes that start the flow: Message Added (an email arrives or is imported), Message Deleted (an email is permanently deleted, for example when the trash is emptied), Label Added (a label is added to an email) and Label Removed (a label is removed from it). Default: Message Added.
Label FiltersThe labels to watch: INBOX, SENT, DRAFT, STARRED, IMPORTANT, UNREAD, CATEGORY_PERSONAL, CATEGORY_SOCIAL, CATEGORY_PROMOTIONS, CATEGORY_UPDATES or CATEGORY_FORUMS. Default: INBOX. If you choose none, INBOX is used.
DataTest field. It lets you try the flow with a sample event without waiting for something to happen in Gmail. Leave it empty in normal use.

Turn on the subscription

The flow only receives changes when it is subscribed:

  1. Save the flow and publish a version. You need a published version of the flow to subscribe. See Versions and publishing.
  2. In the node’s settings panel, click Subscribe.
  3. In the panel that opens, click Subscribe. The status changes to Synced.

Only changes that happen after you subscribe come through. If you later change the events or the labels, the status shows Out of sync: subscribe again to apply the changes. From the same panel you can Unsubscribe when you no longer want to receive changes.

Output

The Data output contains one item per change, with the type of change (messageAdded, messageDeleted, labelAdded or labelRemoved) and the email ID (messageId). For new emails it also includes the sender (from), the recipients (to), the subject (subject), the date, a short summary (snippet), its labels and the conversation ID (threadId). For label changes, the labels that were added or removed. If several changes arrive at once, they all come out together.

The result does not include the full email text. To read it, connect Gmail Message with the Get Message operation and the messageId in Email Id., or pass the details straight to an AI agent.

Example

An online shop receives orders from its distributors by email.

  1. Add Gmail Webhook and choose the shop’s Google Gmail credential.
  2. Leave Events on Message Added and Label Filters on INBOX.
  3. Connect the Data output to Gmail Message with the Get Message operation to read the order text, and then to an agent that extracts the products and quantities.
  4. Publish the flow and click Subscribe.

Good practices

  • Choose only the events and labels you need: the flow runs fewer times and only with what matters to you.
  • If the flow sends emails from the same account and you watch SENT, it will run again with its own emails. Watch INBOX or filter by sender inside the flow.