feat(blocks/gmail): add Gmail thread blocks (#9965)

This PR adds two new Gmail integration blocks—**Gmail Get Thread** and
**Gmail Reply**—to the platform, enhancing threaded email workflows. Key
changes include:

- **GmailGetThreadBlock**:  
- New block that retrieves an entire Gmail thread by `threadId`, with an
option to include or exclude messages from Spam and Trash.
- Supports use cases like fetching all messages in a conversation to
check for responses.

- **GmailReplyBlock**:  
- New block that sends a reply within an existing Gmail thread,
maintaining the thread context.
- Accepts detailed input fields including recipients, CC, BCC, subject,
body, and attachments.
- Ensures replies are properly associated with their parent message and
thread.

- **Enhancements to existing Gmail blocks**:  
- The `Email` model and related outputs now include a `threadId` field.
  - Updated test data and mock data to support threaded operations.
  - Expanded OAuth scopes for actions requiring thread metadata.

- **Documentation updates**:  
- Added documentation for the new Gmail blocks in both the general block
listing and the detailed Gmail block docs.
  - Clarified that the `Email` output now includes the `threadId`.

These updates enable more advanced and context-aware Gmail automations,
such as fetching full conversations and replying inline, supporting
richer communication workflows with Gmail.

## Checklist 📋

### For code changes

- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  - [x] Try all the gmail blocks
  - [x] Send an email reply based on a thread from the get thread block

---------

Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
This commit is contained in:
Toran Bruce Richards
2025-07-17 21:11:31 +01:00
committed by GitHub
parent 725440ff38
commit e50366726c
3 changed files with 426 additions and 14 deletions

View File

@@ -100,6 +100,8 @@ Below is a comprehensive list of all available blocks, categorized by their prim
| Block Name | Description |
|------------|-------------|
| [Gmail Read](google/gmail.md#gmail-read) | Retrieves and reads emails from a Gmail account |
| [Gmail Get Thread](google/gmail.md#gmail-get-thread) | Returns every message in a Gmail thread |
| [Gmail Reply](google/gmail.md#gmail-reply) | Sends a reply that stays in the same thread |
| [Gmail Send](google/gmail.md#gmail-send) | Sends emails using a Gmail account |
| [Gmail List Labels](google/gmail.md#gmail-list-labels) | Retrieves all labels from a Gmail account |
| [Gmail Add Label](google/gmail.md#gmail-add-label) | Adds a label to a specific email in a Gmail account |

View File

@@ -15,13 +15,13 @@ The block connects to the user's Gmail account using their credentials, performs
| Input | Description |
|-------|-------------|
| Credentials | The user's Gmail account credentials for authentication |
| Query | A search query to filter emails (e.g., "is:unread" for unread emails) |
| Query | A search query to filter emails (e.g., "is:unread" for unread emails). Ignored if using only the `gmail.metadata` scope. |
| Max Results | The maximum number of emails to retrieve |
### Outputs
| Output | Description |
|--------|-------------|
| Email | Detailed information about a single email |
| Email | Detailed information about a single email (now includes `threadId`) |
| Emails | A list of email data for multiple emails |
| Error | An error message if something goes wrong during the process |
@@ -141,4 +141,63 @@ The block first finds the ID of the specified label in the user's Gmail account.
| Error | An error message if something goes wrong during the process |
### Possible use case
Automatically removing the "Unread" label from emails after they have been processed by a customer service representative.
Automatically removing the "Unread" label from emails after they have been processed by a customer service representative.
---
## Gmail Get Thread
### What it is
A block that retrieves an entire Gmail thread.
### What it does
Given a `threadId`, this block fetches all messages in that thread and decodes the text bodies.
### Inputs
| Input | Description |
|-------|-------------|
| Credentials | The user's Gmail account credentials for authentication |
| threadId | The ID of the thread to fetch |
### Outputs
| Output | Description |
|--------|-------------|
| Thread | Gmail thread with decoded messages |
| Error | An error message if something goes wrong |
### Possible use case
Checking if a recipient replied in an existing conversation.
---
## Gmail Reply
### What it is
A block that sends a reply within an existing Gmail thread.
### What it does
This block builds a properly formatted reply email and sends it so Gmail keeps it in the same conversation.
### Inputs
| Input | Description |
|-------|-------------|
| Credentials | The user's Gmail account credentials for authentication |
| threadId | The thread to reply in |
| parentMessageId | The ID of the message you are replying to |
| To | List of recipients |
| Cc | List of CC recipients |
| Bcc | List of BCC recipients |
| Subject | Optional subject (defaults to `Re:` prefix) |
| Body | The email body |
| Attachments | Optional files to include |
### Outputs
| Output | Description |
|--------|-------------|
| MessageId | The ID of the sent message |
| ThreadId | The thread the reply belongs to |
| Message | Full Gmail message object |
| Error | Error message if something goes wrong |
### Possible use case
Automatically respond "Thanks, see you then" to a scheduling email while keeping the conversation tidy.