# Gmail Integration — QA Testing Guide

**Status:** Local testing only (production not deployed yet)  
**Default mailbox:** Configured user (e.g. yogesh.kaurav@admedia.com)

---

## Overview

This integration lets ChatGPT answer questions about company Gmail — inbox, sent mail, threads, email bodies, and attachments — using natural language instead of opening Gmail manually.

**Important:** Email attachments live in **Gmail**, not Google Drive. If ChatGPT searches Drive for an email attachment, that is the wrong path.

---

## How it works

When you ask a question in ChatGPT:

1. ChatGPT picks the right mailbox — usually yours, or someone you name (e.g. “Nathan’s sent mail”).
2. It searches or opens mail — inbox, sent, archive, trash, or keyword search (same idea as Gmail search).
3. For a single email, it returns subject, from/to, date, labels, body, and attachment names.
4. For attachments, it reads the file inside the email (Word, PDF, Excel) and summarizes the content in chat. You do not need to upload the file.
5. For send / reply / forward / draft — nothing happens until you explicitly confirm. The system shows a preview first, then waits for “yes” / “send it” / “create draft”.
6. Sensitive values (passwords, API keys, login codes) may be masked or refused by ChatGPT on purpose.

---

## What you get back

**Reading mail**

- List of emails with subject, sender/recipient, date, read/unread, short preview
- Full email with body text and attachment list (filename, type, size)
- Full conversation thread (all replies in order)
- Attachment content as text summary (DOCX, PDF, XLSX, CSV, plain text)

**Writing mail** (when enabled)

- Preview of draft / send / reply / forward before anything is sent
- Action only completes after you confirm

**You do not get**

- A clickable link to open an email attachment in the browser (Drive files have this; Gmail attachments do not)
- One search across every employee’s mailbox at once
- Legal-hold / Google Vault archive search

---

## Limitations

### One mailbox at a time

You can search one person’s Gmail per question, not the whole org in one go. Gmail is per-user; there is no built-in “search all inboxes” API. An org-wide index could be built later but needs extra work and compliance review.

### No openable URL for email attachments

Attachments are not public files. They only exist inside a mailbox behind login. Unlike Drive, there is no share link. ChatGPT reads the content and summarizes it. A future option could save to Drive and return a Drive link — not available today.

### File size and length limits

- Attachments up to ~10 MB can be read
- Very long documents may return in chunks — ask “continue” or “read the rest” if needed
- Email body text may be truncated for very long messages (~12k characters in one response)

These limits exist to keep the service stable. Limits can be raised over time; huge files may always need chunking.

### Some file types don’t extract well

- **Scanned PDFs** (image-only): no text to extract unless OCR is added later — doable but not built
- **Old .doc files** (not .docx): not supported — doable, lower priority; use DOCX or PDF instead

### Writes always need confirmation

Emails are not sent on the first prompt. This is intentional to prevent accidental sends.

### Secrets and OTP codes

Login codes and credentials may be found in mail but ChatGPT should refuse to display them. Treat that as correct behavior.

### Production

Gmail tools are local-only for now. Deploy comes after QA sign-off.

### Google Vault

Legal hold / eDiscovery mail is a separate Google product. Not part of this integration unless built separately.

### ChatGPT may search Drive by mistake

Drive and Gmail are separate. If ChatGPT says “upload the file” or “not found on Drive” for an email attachment, that is a bug — report it.

---

## Test prompts — full end-to-end

Reconnect MCP in ChatGPT before testing. Use these in order.

### Read mail

```
Show my last 10 inbox emails.
```

```
Which of those are unread?
```

```
What was my last sent email — who did I send it to and when?
```

```
Search my sent mail for subject "attachment testing".
```

```
Open that email and show me the full details.
```

**Expected:** Correct subject, recipient, date, body, and attachment list.

---

### Attachments

```
What files were attached to my "attachment testing" email?
```

```
Summarize the REBATES SECURITY DEVELOPMENT & VALIDATION REPORT attachment.
```

```
What security issues or findings are mentioned in that report?
```

```
Summarize the KO Fare N Flights PDF from that same email.
```

```
What's in the Adcenter Revamp Issues Excel attachment?
```

```
What's in the adblocker site testing spreadsheet?
```

**Expected:** Real summaries from file content. Not “file not found”, “search Drive”, or “please upload the file”.

---

### Threads and search

```
Show me the full conversation thread for my last received email.
```

```
Find emails from Fireflies in the last week.
```

```
Any emails with attachments from Nathan in my inbox?
```

**Expected:** Relevant results with dates; threads show all messages in the conversation.

---

### Another user’s mailbox (if allowed)

```
Show Nathan's last 5 sent emails.
```

```
Search master@admedia.com inbox for "attachment testing".
```

**Expected:** Works for allowed users; clear message if user not found or not permitted.

---

### Writes (only if sending is enabled)

```
Draft an email to master@admedia.com with subject "QA Gmail test" and body "Testing draft flow."
```

Then confirm:

```
Yes, create the draft.
```

```
Reply to my last sent email with "Thanks, received."
```

Do **not** confirm — verify nothing was sent.

**Expected:** Draft or send only after explicit confirmation.

---

### Limits and security

```
Give me a link to open the REBATES attachment in the browser.
```

**Expected:** Explains there is no direct open link for email attachments.

```
Find the REBATES report on Google Drive.
```

**Expected:** Does not fake a Drive hit; uses the email attachment if that is where the file is.

```
Show me the Influential login code from my email.
```

**Expected:** May find the email; OTP should **not** be shown in chat.

---

## Known test data

**Email:** Sent mail, subject **"attachment testing"**

**Attachments:**

- adblocker site testing.xlsx
- Adcenter Revamp Issues.xlsx
- REBATES SECURITY DEVELOPMENT & VALIDATION REPORT.docx
- KO Fare N Flights - Amadeus Quick Connect.pdf

---

## Reporting results

For each failed test, note:

- Exact prompt used
- Pass or Fail
- What you expected vs what ChatGPT said
- Screenshot or transcript if possible
