Gmail Tool – Operations and Scopes


Introduction

This guide explains all Gmail Tool operations available in AgenThink. It includes the required scopes, use cases, and step-by-step instructions. Scopes define the level of access the Gmail Tool has to your Gmail account. Each operation requires specific scopes to run.

Warning

Best practice: Re-authenticate after you change a scope to make sure the Thinkflow runs correctly.


Operations

1. Get Profile

Required Scope: Read-only Access

Description: Retrieves your Gmail account profile information, such as email address, total messages, total threads, and history ID.

Use case: Confirm that your Gmail account is connected and accessible within Thinkflow.

Steps:

  1. From the Scopes dropdown, select Read-only access.
  2. From the Operation dropdown, select Get Profile.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:
    • “Get my profile”.
Description
  1. The system displays your Gmail profile information.

2. Get Labels

Required Scope: Manage labels

Description: Fetches all existing labels from your Gmail account.

Use case: View available labels before applying them to messages or threads.

Steps:

  1. From the Scopes dropdown, select Manage labels.
  2. From the Operation dropdown, select Get Labels.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Give me all the labels in my account.”
Description
  1. The system displays a list of all labels present in your Gmail account.

3. Create Label

Required Scope: Manage labels

Description: Creates a new label in your Gmail account.

Use case: Organize emails with custom labels such as Invoices or High Priority.

Steps:

  1. From the Scopes dropdown, select Manage labels.
  2. From the Operation dropdown, select Create Label.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • Create a label named 'Agents'.
Description
  1. The system confirms label creation.

4. Get Messages

Required Scope: Read-only or Read-write access.

Description: Retrieves a list of messages from your Gmail inbox.

Use case: Fetch multiple messages that match conditions such as unread, from a specific sender, or the most recent.

Steps:

  1. From the Scopes dropdown, select Read-only or Read-write.
  2. From the Operation dropdown, select Get Messages.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Get my unread messages”

    • “Fetch the last 5 messages from example123@gmail.com”

Description
  1. The system returns a list of messages with details such as message IDs, subjects, senders, and timestamps.

5. Send Email

Required Scope: Compose and send an email.

Description: Sends a new email from your Gmail account.

Use case: Send notifications, alerts, or customer communication by providing the required details in the My chat window.

Steps:

  1. From the Scopes dropdown, select Compose and send emails.
  2. From the Operation dropdown, select Send Email.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:
  • To (recipient address)

  • CC (optional)

  • Subject

  • Email Body

Example: “Write an email to [email address], Subject: [subject text], email Body: [message content].”

Info

Note: All required fields (To, Subject, and email Body) must be entered manually in the My Chats window for the email to send successfully.

Description
  1. The system confirms the email has been sent.

6. Reply to Mail

Required Scope: Send emails, Read-write access, Compose and send emails, Read-only access.

Description: Replies to an existing Gmail message by referencing its message ID.

Use case: Replies such as acknowledgments or thank-you responses, or confirmations.

Steps:

  1. From the Scopes dropdown, select Read-only access, Read-write access, Send emails, and Compose and send emails.
  2. From the Operation dropdown, select Reply to Mail, Send E-mail, and Get messages.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Get the last sent messages in my send box”.

    • “I want to send a reply email to option 2 from the above email list, email Body: [message content].”

Description
  1. The system confirms that the reply has been sent.

7. Modify Message Label

Required Scope: Manage labels, read-write access, read-only access, and full access.

Description: Updates labels on an existing Gmail message by adding or removing them.

Use case: Change how emails are categorized. For example, move a message from Travel to Personal or add a label such as To Review.

Steps:

  1. From the Scopes dropdown, select Manage labels, Read-write access, Read-only access, and Full access.
  2. From the Operation dropdown, select Modify Message Label, Get labels, and Get messages.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Give me the top 5 messages that I received from example123@gmail.com.”

    • “I want to change the label Travel to Personal for the messages I received from example123@gmail.com.”The chat output confirms the update.

Description
  1. The system confirms that the label has been updated.

8. Delete Message

Required Scope: Read-write access and read-only access.

Description: Deletes a Gmail message by ID.

Use case: Remove emails that are no longer needed.

Steps:

  1. From the Scopes dropdown, select Read-write access and Read-only access.
  2. From the Operation dropdown, select Delete Message and Get messages.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Give me my last email.”

    • “I want to delete this email.”

Description
  1. The system confirms deletion.

9. Apply Label to Message

Required Scope: Manage labels, read-write access, read-only access, and full access.

Description: Applies a specific Gmail label to an email.

Use case: Categorize incoming messages with labels such as Work, Personal, or High Priority.

Steps:

  1. From the Scopes dropdown, select Manage labels, Read-write access, Read-only access, and Full access.
  2. From the Operation dropdown, select Apply label to messages, Get labels, Get messages, and Full access.
  3. If you changed the scope, click Re-authenticate with Google.
  4. Click SaveAuto SaveDeploy.
  5. After deployment, click Run to execute the flow.
Description
  1. In the My Chats window, type:

    • “Give me the top 5 emails I received from example@123.com with message IDs.”

    • “Add the label ‘Personal’ to this email ID eample@123.com.”

Description
  1. The system confirms the label is applied.

Gmail Scopes Overview

ScopeDescription
Read-only accessView messages and labels
Read-write accessView and update messages
Send emailsCompose and send emails
Manage labelsCreate, update, or delete labels
Full access to GmailComplete access: read, send, delete, and settings
Warning

Best practice: Always grant only the minimum scopes required for your Thinkflow.