> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# On message added

> Run an automation when Gmail adds any message.

`gmail.onMessageAdded` handles every message Gmail adds to the mailbox, including received, sent, inserted, imported, and draft messages.

## Example

```ts automations/inspect-added-message.automation.ts theme={null}
import { automation } from "automate.ax"
import { gmail } from "automate.ax/gmail"

export default automation("Inspect added Gmail messages", () => {
  const message = gmail.onMessageAdded()

  // Route the Gmail message by its labels.
})
```

## Options

`account` is a static Google Account binding and defaults to the project binding. It can't change at runtime.

## Trigger data

Returns the complete parsed `Message` documented by [Get message](/reference/integrations/gmail/actions/get-message). Use [On new email](/reference/integrations/gmail/triggers/on-new-email) for the `INBOX` subset or [On email sent](/reference/integrations/gmail/triggers/on-email-sent) for messages sent by the watched mailbox.

Existing messages establish the watch cursor and aren't replayed when you deploy the trigger. Automate.ax deduplicates repeated Gmail notifications and suppresses recursive delivery to the automation that originated an authenticated message.
