mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
Some checks failed
* WIP: v1 docs (#3626) (cherry picked from commit d46e20fa09bcd2f5916282f5553ddeb7183bd92c) * docs: parity for all translations * docs: full name of acronym AMP * docs: fix lingering unused code * docs: expand contextual options in docs.json * docs: add contextual action to request feature on GitHub * chore: tidy docs formatting
86 lines
2.7 KiB
Plaintext
86 lines
2.7 KiB
Plaintext
---
|
|
title: "Gmail Trigger"
|
|
description: "Trigger automations when Gmail events occur (e.g., new emails, labels)."
|
|
icon: "envelope"
|
|
mode: "wide"
|
|
---
|
|
|
|
## Overview
|
|
|
|
Use the Gmail Trigger to kick off your deployed crews when Gmail events happen in connected accounts, such as receiving a new email or messages matching a label/filter.
|
|
|
|
<Tip>
|
|
Make sure Gmail is connected in Tools & Integrations and the trigger is enabled for your deployment.
|
|
</Tip>
|
|
|
|
## Enabling the Gmail Trigger
|
|
|
|
1. Open your deployment in CrewAI AMP
|
|
2. Go to the **Triggers** tab
|
|
3. Locate **Gmail** and switch the toggle to enable
|
|
|
|
<Frame>
|
|
<img src="/images/enterprise/trigger-selected.png" alt="Enable or disable triggers with toggle" />
|
|
</Frame>
|
|
|
|
## Example: Process new emails
|
|
|
|
When a new email arrives, the Gmail Trigger will send the payload to your Crew or Flow. Below is a Crew example that parses and processes the trigger payload.
|
|
|
|
```python
|
|
@CrewBase
|
|
class GmailProcessingCrew:
|
|
@agent
|
|
def parser(self) -> Agent:
|
|
return Agent(
|
|
config=self.agents_config['parser'],
|
|
)
|
|
|
|
@task
|
|
def parse_gmail_payload(self) -> Task:
|
|
return Task(
|
|
config=self.tasks_config['parse_gmail_payload'],
|
|
agent=self.parser(),
|
|
)
|
|
|
|
@task
|
|
def act_on_email(self) -> Task:
|
|
return Task(
|
|
config=self.tasks_config['act_on_email'],
|
|
agent=self.parser(),
|
|
)
|
|
```
|
|
|
|
The Gmail payload will be available via the standard context mechanisms. See the payload samples repository for structure and fields.
|
|
|
|
### Sample payloads & crews
|
|
|
|
The [CrewAI AMP Trigger Examples repository](https://github.com/crewAIInc/crewai-enterprise-trigger-examples/tree/main/gmail) includes:
|
|
|
|
- `new-email-payload-1.json` / `new-email-payload-2.json` — production-style new message alerts with matching crews in `new-email-crew.py`
|
|
- `thread-updated-sample-1.json` — follow-up messages on an existing thread, processed by `gmail-alert-crew.py`
|
|
|
|
Use these samples to validate your parsing logic locally before wiring the trigger to your live Gmail accounts.
|
|
|
|
## Monitoring Executions
|
|
|
|
Track history and performance of triggered runs:
|
|
|
|
<Frame>
|
|
<img src="/images/enterprise/list-executions.png" alt="List of executions triggered by automation" />
|
|
</Frame>
|
|
|
|
## Payload Reference
|
|
|
|
See the sample payloads and field descriptions:
|
|
|
|
<Card title="Gmail samples in Trigger Examples Repo" href="https://github.com/crewAIInc/crewai-enterprise-trigger-examples/tree/main/gmail" icon="envelopes-bulk">
|
|
Gmail samples in Trigger Examples Repo
|
|
</Card>
|
|
|
|
## Troubleshooting
|
|
|
|
- Ensure Gmail is connected in Tools & Integrations
|
|
- Verify the Gmail Trigger is enabled on the Triggers tab
|
|
- Check the execution logs and confirm the payload is passed as `crewai_trigger_payload`
|