---
title: "Mail Received"
description: "Run when Gmail delivers mail for a connected mailbox and labels."
canonical_url: "https://docs.vettero.com/build/event-handlers/mail-received"
---
# Mail Received

> Run when Gmail delivers mail for a connected mailbox and labels.

<trigger-meta capability="Gmail" group="Messaging" icon="i-lucide-mail" service="Google" serviceTo="/integrations/third-party-services/google" type="google.gmail.on-mail">



</trigger-meta>

**Mail Received** runs when Gmail push notifications arrive for the configured mailbox.

## Payload

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        serviceId
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Connected Google service with Gmail enabled
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        labelIds
      </code>
    </td>
    
    <td>
      string<span>
        
      </span>
    </td>
    
    <td>
      Labels to watch. Default: <code>
        ["INBOX"]
      </code>
    </td>
  </tr>
</tbody>
</table>

## Trigger data

Available as `args.*`.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        message.id
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Gmail message id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.threadId
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Thread id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.labelIds
      </code>
    </td>
    
    <td>
      string<span>
        
      </span>
    </td>
    
    <td>
      Message labels
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.snippet
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Snippet
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.internalDate
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Internal date
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.subject
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Subject
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.from.name
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      From name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.from.email
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      From email
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.to[].name
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      To name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.to[].email
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      To email
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.cc[].name
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Cc name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.cc[].email
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Cc email
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.bcc[].name
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Bcc name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.bcc[].email
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Bcc email
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.replyTo.name
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Reply-to name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.replyTo.email
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Reply-to email
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.messageId
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Message-ID header
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.inReplyTo
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      In-Reply-To header
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.references
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      References header
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.isReply
      </code>
    </td>
    
    <td>
      boolean
    </td>
    
    <td>
      Whether the message is a reply
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.dateHeader
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Date header
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.textPlain
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Plain-text body
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.textHtml
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      HTML body
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.textParsed
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Parsed body
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.attachments[].filename
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Attachment filename
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.attachments[].mimeType
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Attachment MIME type
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.attachments[].size
      </code>
    </td>
    
    <td>
      number
    </td>
    
    <td>
      Attachment size
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        message.attachments[].attachmentId
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      Attachment id
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        raw
      </code>
    </td>
    
    <td>
      object
    </td>
    
    <td>
      Original Gmail push payload
    </td>
  </tr>
</tbody>
</table>

## Use case

- Inbound support or sales mail should create or update a [table](https://docs.vettero.com/data/tables) row, classify with an [AI Field](https://docs.vettero.com/data/tables/ai-field) or [agent](https://docs.vettero.com/build/agents), then notify — without opening a live chat.
- Watch **INBOX** or other labels (for example only `support@`) so personal mail does not fire the handler.
- Store `threadId` on a [Gmail Thread](https://docs.vettero.com/data/tables/gmail-thread) column so later replies stay on the same conversation in Gmail.
- Use [Get Attachment](https://docs.vettero.com/build/workflows/blocks/gmail/get-attachment) when inbound mail includes files you need in workspace storage.
- Use [Mail Chat](https://docs.vettero.com/build/channels/mail-chat) instead when a person should talk to a default agent over email.

## Channels vs handlers

Mail handlers share identifiers with [Mail Chat](https://docs.vettero.com/build/channels/mail-chat).

<warning>

If an **active channel** uses the same mailbox, inbound mail goes to the channel. The event handler does not run for that mailbox until you disable or change the channel, or change the handler identifier.

</warning>

<trigger-page-nav>



</trigger-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
