Files
crewAI/docs/edge/pt-BR/enterprise/integrations/gmail.mdx
Lucas Gomide a237ebabba feat: adopt directory-based docs versioning with Edge channel (#6202)
* feat: adopt directory-based docs versioning with Edge channel

Switch docs.crewai.com from navigation-only versioning (every version
selector entry rendered the same docs/<lang>/* source files) to
Mintlify's directory-based versioning so each version selector entry
renders its own snapshot. Add an "Edge" channel under docs/edge/<lang>/*
that always reflects main HEAD for unreleased work, eliminating
pre-release leakage onto frozen release labels. External links to
canonical /<lang>/* URLs are preserved via wildcard redirects that
always land on the current default version.

Layout:
- docs/edge/<lang>/*         rolling source (you edit here)
- docs/edge/enterprise-api.*.yaml
- docs/v<X.Y.Z>/<lang>/*     frozen, immutable snapshots
- docs/v<X.Y.Z>/enterprise-api.*.yaml
- docs/images/               shared, append-only
- docs/docs.json             nav + redirects

URLs follow the Mintlify-idiomatic shape: /edge/<lang>/<page> for
Edge, /v<X.Y.Z>/<lang>/<page> for every frozen snapshot. The wildcard
redirects /<lang>/:slug* -> /<default>/<lang>/:slug* keep stale links
working, and every freeze rewrites them (plus all per-section/per-page
redirects) so destinations always resolve to the current default
without depending on a second redirect hop.

Release flow integration (devtools release):
- New module crewai_devtools.docs_versioning.freeze() materialises
  docs/v<X.Y.Z>/ from docs/edge/, rewrites openapi: refs inside the
  snapshot, inserts the version into every language block in
  docs.json, and refreshes all redirect destinations.
- _update_docs_and_create_pr() in cli.py now calls that freeze during
  Phase 2 of devtools release. Edge changelogs are updated first (so
  the snapshot freeze picks them up), then the snapshot is staged
  alongside docs.json, branched as docs/freeze-v<X.Y.Z>, and the PR
  is titled [docs-freeze] docs: snapshot and changelog for v<X.Y.Z>
  — the title prefix the new CI guard reads.
- The PR still gates tag, GitHub release, PyPI publish, and the
  enterprise release as before; no new PRs are added.
- Pre-releases (1.X.YaN, 1.X.YbN, ...) skip the snapshot — they ride
  Edge — and the docs PR title omits the [docs-freeze] prefix.
- docs_check (AI-generated docs scaffolding) writes to
  docs/edge/<lang>/* so newly-generated unreleased docs land in Edge
  and never accidentally touch a frozen snapshot.

Migration scripts (one-shot):
- scripts/docs/freeze_historical_versions.py reconstructs all 16
  historical snapshots (v1.10.0 .. v1.14.7) from git tags via
  git archive | tar, rewriting openapi: MDX refs so each snapshot
  reads its own enterprise-api YAML rather than the live one.
- scripts/docs/prefix_version_paths.py one-shot-migrates docs.json:
  rewrites every page path in 16 versioned blocks to point under
  docs/v<X.Y.Z>/, inserts a new Edge entry per language, tags
  v1.14.7 as Latest (default), prunes pages whose target file
  doesn't exist in the snapshot (e.g. docs/ar/ didn't exist before
  v1.12.0), and writes the wildcard + per-section redirects.
- scripts/docs/freeze_current_edge.py is now a thin CLI wrapper
  around docs_versioning.freeze for manual one-off freezes (e.g.
  retroactively snapshotting a forgotten release).

CI guards (.github/workflows/docs-snapshots.yml):
- Frozen snapshots under docs/v[0-9]*/ are immutable; only PRs whose
  title contains [docs-freeze] (i.e. release-cut PRs generated by
  devtools release or the manual wrapper) may modify them.
- Images under docs/images/ are append-only since snapshots share a
  single image directory. Deleting or renaming an image breaks every
  historical snapshot that still references it.

Restored docs/images/crewai-otel-export.png from PR #3673; it was
deleted in PR #4908 but v1.10.0 / v1.10.1 snapshots still reference
it. Restoring instead of editing the snapshots preserves historical
rendering fidelity and validates the new append-only rule
retroactively.

Tests:
- lib/devtools/tests/test_docs_versioning.py covers the freeze: file
  copy, openapi rewrite, version insertion, default demotion, redirect
  upserts, per-section redirect rewriting, idempotency, and invalid
  inputs.

Verified locally with mintlify broken-links: 0 broken links across
the full site (Edge + 16 frozen versions, 4 locales).

AGENTS.md (repo root) is the contributor guide for the new model;
RELEASING.md is the release-cut runbook; README's Contribution
section links to both.

Co-authored-by: Cursor <cursoragent@cursor.com>

* style: resolve linter issues

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-17 11:56:59 -04:00

357 lines
11 KiB
Plaintext

---
title: Integração com Gmail
description: "Gerenciamento de e-mails e contatos com a integração do Gmail para o CrewAI."
icon: "envelope"
mode: "wide"
---
## Visão Geral
Permita que seus agentes gerenciem e-mails, contatos e rascunhos através do Gmail. Envie e-mails, pesquise mensagens, gerencie contatos, crie rascunhos e otimize suas comunicações por e-mail com automação impulsionada por IA.
## Pré-requisitos
Antes de usar a integração com o Gmail, certifique-se de que você possui:
- Uma conta [CrewAI AMP](https://app.crewai.com) com assinatura ativa
- Uma conta do Gmail com as permissões adequadas
- Conectou sua conta do Gmail através da [página de Integrações](https://app.crewai.com/crewai_plus/connectors)
## Configurando a Integração com o Gmail
### 1. Conecte sua Conta do Gmail
1. Navegue até [Integrações CrewAI AMP](https://app.crewai.com/crewai_plus/connectors)
2. Encontre **Gmail** na seção de Integrações de Autenticação
3. Clique em **Conectar** e conclua o fluxo OAuth
4. Conceda as permissões necessárias para o gerenciamento de e-mail e contato
5. Copie seu Token Empresarial em [Configurações de Integração](https://app.crewai.com/crewai_plus/settings/integrations)
### 2. Instale o Pacote Necessário
```bash
uv add crewai-tools
```
### 3. Configuração de variável de ambiente
<Note>
Para usar integrações com `Agent(apps=[])`, você deve definir a variável de
ambiente `CREWAI_PLATFORM_INTEGRATION_TOKEN` com seu Enterprise Token.
</Note>
```bash
export CREWAI_PLATFORM_INTEGRATION_TOKEN="seu_enterprise_token"
```
Ou adicione ao seu arquivo `.env`:
```
CREWAI_PLATFORM_INTEGRATION_TOKEN=seu_enterprise_token
```
## Ações Disponíveis
<AccordionGroup>
<Accordion title="gmail/send_email">
**Descrição:** Envia um e-mail pelo Gmail.
**Parâmetros:**
- `toRecipients` (array, obrigatório): Para - Especifique os destinatários como uma única string ou um array JSON.
```json
[
"recipient1@domain.com",
"recipient2@domain.com"
]
```
- `from` (string, obrigatório): De - Especifique o e-mail do remetente.
- `subject` (string, obrigatório): Assunto - Especifique o assunto da mensagem.
- `messageContent` (string, obrigatório): Conteúdo da Mensagem - Especifique o conteúdo do e-mail em texto simples ou HTML.
- `attachments` (string, opcional): Anexos - Aceita um único objeto de arquivo ou um array JSON de objetos de arquivo.
- `additionalHeaders` (object, opcional): Cabeçalhos Adicionais - Especifique quaisquer campos de cabeçalho adicionais aqui.
```json
{
"reply-to": "Nome do Remetente <sender@domain.com>"
}
```
</Accordion>
<Accordion title="gmail/get_email_by_id">
**Descrição:** Obtém um e-mail pelo ID no Gmail.
**Parâmetros:**
- `userId` (string, obrigatório): ID do Usuário - Especifique o endereço de e-mail do usuário. (exemplo: "user@domain.com").
- `messageId` (string, obrigatório): ID da Mensagem - Especifique o ID da mensagem a ser recuperada.
</Accordion>
<Accordion title="gmail/fetch_emails">
**Descrição:** Pesquisa e-mails no Gmail usando filtros avançados.
**Parâmetros:**
- `emailFilterFormula` (object, opcional): Um filtro na forma normal disjuntiva - OU de grupos E de condições únicas.
```json
{
"operator": "OR",
"conditions": [
{
"operator": "AND",
"conditions": [
{
"field": "from",
"operator": "$stringContains",
"value": "example@domain.com"
}
]
}
]
}
```
Campos disponíveis: `from`, `to`, `date`, `label`, `subject`, `cc`, `bcc`, `category`, `deliveredto:`, `size`, `filename`, `older_than`, `newer_than`, `list`, `is:important`, `is:unread`, `is:snoozed`, `is:starred`, `is:read`, `has:drive`, `has:document`, `has:spreadsheet`, `has:presentation`, `has:attachment`, `has:youtube`, `has:userlabels`
- `paginationParameters` (object, opcional): Parâmetros de Paginação.
```json
{
"pageCursor": "page_cursor_string"
}
```
</Accordion>
<Accordion title="gmail/delete_email">
**Descrição:** Exclui um e-mail no Gmail.
**Parâmetros:**
- `userId` (string, obrigatório): ID do Usuário - Especifique o endereço de e-mail do usuário. (exemplo: "user@domain.com").
- `messageId` (string, obrigatório): ID da Mensagem - Especifique o ID da mensagem para enviar para a lixeira.
</Accordion>
<Accordion title="gmail/create_a_contact">
**Descrição:** Cria um contato no Gmail.
**Parâmetros:**
- `givenName` (string, obrigatório): Primeiro Nome - Especifique o Primeiro Nome do contato a ser criado. (exemplo: "João").
- `familyName` (string, obrigatório): Sobrenome - Especifique o Sobrenome do contato a ser criado. (exemplo: "Silva").
- `email` (string, obrigatório): E-mail - Especifique o endereço de e-mail do contato a ser criado.
- `additionalFields` (object, opcional): Campos Adicionais - Informações adicionais de contato.
```json
{
"addresses": [
{
"streetAddress": "1000 North St.",
"city": "Los Angeles"
}
]
}
```
</Accordion>
<Accordion title="gmail/get_contact_by_resource_name">
**Descrição:** Obtém um contato pelo nome do recurso no Gmail.
**Parâmetros:**
- `resourceName` (string, obrigatório): Nome do Recurso - Especifique o nome do recurso do contato a ser buscado.
</Accordion>
<Accordion title="gmail/search_for_contact">
**Descrição:** Pesquisa um contato no Gmail.
**Parâmetros:**
- `searchTerm` (string, obrigatório): Termo - Especifique um termo para buscar correspondências aproximadas ou exatas nos campos nome, apelido, endereços de e-mail, números de telefone ou organizações do contato.
</Accordion>
<Accordion title="gmail/delete_contact">
**Descrição:** Exclui um contato no Gmail.
**Parâmetros:**
- `resourceName` (string, obrigatório): Nome do Recurso - Especifique o nome do recurso do contato a ser excluído.
</Accordion>
<Accordion title="gmail/create_draft">
**Descrição:** Cria um rascunho no Gmail.
**Parâmetros:**
- `toRecipients` (array, opcional): Para - Especifique os destinatários como uma única string ou um array JSON.
```json
[
"recipient1@domain.com",
"recipient2@domain.com"
]
```
- `from` (string, opcional): De - Especifique o e-mail do remetente.
- `subject` (string, opcional): Assunto - Especifique o assunto da mensagem.
- `messageContent` (string, opcional): Conteúdo da Mensagem - Especifique o conteúdo do e-mail em texto simples ou HTML.
- `attachments` (string, opcional): Anexos - Aceita um único objeto de arquivo ou um array JSON de objetos de arquivo.
- `additionalHeaders` (object, opcional): Cabeçalhos Adicionais - Especifique quaisquer campos de cabeçalho adicionais aqui.
```json
{
"reply-to": "Nome do Remetente <sender@domain.com>"
}
```
</Accordion>
</AccordionGroup>
## Exemplos de Uso
### Configuração Básica de Agente Gmail
```python
from crewai import Agent, Task, Crew
# Create an agent with Gmail capabilities
gmail_agent = Agent(
role="Email Manager",
goal="Manage email communications and contacts efficiently",
backstory="An AI assistant specialized in email management and communication.",
apps=['gmail']
)
# Task to send a follow-up email
send_email_task = Task(
description="Send a follow-up email to john@example.com about the project update meeting",
agent=gmail_agent,
expected_output="Email sent successfully with confirmation"
)
# Run the task
crew = Crew(
agents=[gmail_agent],
tasks=[send_email_task]
)
crew.kickoff()
```
### Filtrando Ferramentas Específicas do Gmail
```python
email_coordinator = Agent(
role="Email Coordinator",
goal="Coordinate email communications and manage drafts",
backstory="An AI assistant that focuses on email coordination and draft management.",
apps=['gmail']
)
# Task to prepare and send emails
email_coordination = Task(
description="Search for emails from the marketing team, create a summary draft, and send it to stakeholders",
agent=email_coordinator,
expected_output="Summary email sent to stakeholders"
)
crew = Crew(
agents=[email_coordinator],
tasks=[email_coordination]
)
crew.kickoff()
```
### Gerenciamento de Contatos
```python
from crewai import Agent, Task, Crew
contact_manager = Agent(
role="Contact Manager",
goal="Manage and organize email contacts efficiently",
backstory="An experienced contact manager who maintains organized contact databases.",
apps=['gmail']
)
# Task to manage contacts
contact_task = Task(
description="""
1. Search for contacts from the 'example.com' domain
2. Create new contacts for recent email senders not in the contact list
3. Update contact information with recent interaction data
""",
agent=contact_manager,
expected_output="Contact database updated with new contacts and recent interactions"
)
crew = Crew(
agents=[contact_manager],
tasks=[contact_task]
)
crew.kickoff()
```
### Pesquisa e Análise de E-mails
```python
from crewai import Agent, Task, Crew
email_analyst = Agent(
role="Email Analyst",
goal="Analyze email patterns and provide insights",
backstory="An AI assistant that analyzes email data to provide actionable insights.",
apps=['gmail']
)
# Task to analyze email patterns
analysis_task = Task(
description="""
Search for all unread emails from the last 7 days,
categorize them by sender domain,
and create a summary report of communication patterns
""",
agent=email_analyst,
expected_output="Email analysis report with communication patterns and recommendations"
)
crew = Crew(
agents=[email_analyst],
tasks=[analysis_task]
)
crew.kickoff()
```
### Fluxos de Trabalho Automatizados de E-mail
```python
from crewai import Agent, Task, Crew
workflow_manager = Agent(
role="Email Workflow Manager",
goal="Automate email workflows and responses",
backstory="An AI assistant that manages automated email workflows and responses.",
apps=['gmail']
)
# Complex task involving multiple Gmail operations
workflow_task = Task(
description="""
1. Search for emails with 'urgent' in the subject from the last 24 hours
2. Create draft responses for each urgent email
3. Send automated acknowledgment emails to senders
4. Create a summary report of urgent items requiring attention
""",
agent=workflow_manager,
expected_output="Urgent emails processed with automated responses and summary report"
)
crew = Crew(
agents=[workflow_manager],
tasks=[workflow_task]
)
crew.kickoff()
```
### Precisa de Ajuda?
<Card title="Precisa de Ajuda?" icon="headset" href="mailto:support@crewai.com">
Entre em contato com nosso time de suporte para obter assistência na
configuração ou solução de problemas da integração Gmail.
</Card>