docs/en/enterprise/guides/gmail-trigger.mdx
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>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.
@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.
Test your Gmail trigger integration locally using the CrewAI CLI:
# View all available triggers
crewai triggers list
# Simulate a Gmail trigger with realistic payload
crewai triggers run gmail/new_email_received
The crewai triggers run command will execute your crew with a complete Gmail payload, allowing you to test your parsing logic before deployment.
Track history and performance of triggered runs:
<Frame> </Frame>crewai triggers run gmail/new_email_received to see the exact payload structurecrewai_trigger_payloadcrewai triggers run (not crewai run) to simulate trigger execution