# Gmail Integration

Give your AVCodex agent the keys to your Gmail. RFP responses, manufacturer support threads, client commissioning sign-offs. The agent reads, searches, sends, replies, and triages without you ever leaving chat.

---

Connect Gmail to your AVCodex agent so it can search your inbox, read emails, compose new messages, reply to threads, and manage your mailbox through natural conversation.

## What the AI Can Do

Once connected, your agent gains seven tools for full inbox management:

| Tool | Description |
|------|-------------|
| **gmail_list_emails** | Search and list emails with Gmail query syntax |
| **gmail_read_email** | Read the full content of a specific email |
| **gmail_send_email** | Compose and send a new email (with optional attachments) |
| **gmail_reply_to_email** | Reply to an email thread with correct headers |
| **gmail_unsubscribe** | Automatically unsubscribe from mailing lists and newsletters |
| **gmail_trash_email** | Move an email to the trash |
| **gmail_modify_labels** | Mark as read/unread, star, archive, or apply labels |

### Search Capabilities

The list tool supports Gmail's full search syntax:

- `from:dealersupport@crestron.com`: emails from a specific sender
- `is:unread`: unread emails only
- `subject:RFP`: emails with a specific subject
- `newer_than:2d`: emails from the last 2 days
- `has:attachment`: emails with attachments (spec sheets, AS-builts, BOMs)
- `label:INBOX`: emails in a specific label

## Connecting Gmail

  **1.**
    **Open the Integrations tab**

    In your agent's builder, navigate to the **Build** section and select the **Integrations** tab. Find **Gmail** in the list of available integrations.

  **2.**
    **Click Connect**

    Click the **Connect** button next to Gmail. A Google OAuth popup will appear.

  **3.**
    **Authorize access**

    Sign in with the Google account whose inbox you want the agent to manage. Grant the requested permissions for reading and sending emails.

    > **Warning:** Gmail integration requests modify and send permissions. The agent can read, send, reply, trash, and label emails. Only connect accounts you trust the agent to manage. (For an integrator's BD inbox, fine. For the CFO's inbox, think twice.)

  **4.**
    **Test it out**

    Once connected, open the chat preview and try:
    - "Show me my unread emails"
    - "Read the latest manufacturer support thread from Biamp"
    - "Send an email to the client about tomorrow's commissioning window"
    - "Unsubscribe me from that AV newsletter"

## Key Features

### Sending and Replying

The agent can compose new emails and reply to existing threads:

- **New emails** support To, CC, BCC recipients, plain text or HTML body
- **Replies** automatically set the correct `In-Reply-To` and `References` headers to keep the thread intact (vital for ongoing RFP and commissioning threads)
- **Reply All** includes all original recipients
- **Attachments**: files uploaded in the conversation can be attached to outgoing emails (signed-off commissioning checklists, redlined AS-builts)

### Unsubscribe

The unsubscribe tool is a standout feature. When asked to unsubscribe from a newsletter, the agent:

1. Reads the `List-Unsubscribe` header from the email
2. Tries RFC 8058 one-click unsubscribe (POST request) first
3. Falls back to visiting the unsubscribe URL and submitting confirmation forms
4. As a last resort, sends an unsubscribe email via the `mailto:` link
5. Optionally trashes the email afterward

### Label Management

Use labels to organize emails through conversation:

- "Mark that email as read": removes the `UNREAD` label
- "Star the commissioning sign-off from Acme HQ": adds the `STARRED` label
- "Archive all manufacturer marketing emails": removes the `INBOX` label

## Example Use Cases

- **Inbox triage**: "Summarize my unread emails from today"
- **RFP follow-up**: "Show me emails tagged 'RFP' and draft holding replies for the ones older than 24 hours"
- **Inbox cleanup**: "Unsubscribe me from all manufacturer marketing emails and trash them"
- **Client follow-ups**: "Reply to the client's commissioning question saying we'll have the AS-built by Friday"
- **Thread search**: "Find the email with the Crestron quote attachment from last month"

## Billing

Gmail tool calls use your standard LLM token billing. There is no separate per-call fee. Listing and reading emails consume tokens based on the content length returned. A long manufacturer support thread costs more to read than a one-line client confirmation.

*AVCodex · Your AV expertise. Amplified by AI.*
