Requirements & Compatibility

  • AnythingLLM Version: v1.12.1 or later.
  • Security Model: Read-only actions execute without confirmation. Write/modification actions (marked with ✏️) require explicit approval.

Setup & Deployment

1. Retrieve Script

Download the Google Apps Script from: https://github.com/Mintplex-Labs/anythingllm-gapps/blob/main/gmail/index.gs

2. Configure Google Apps Script

  1. Navigate to: Google Apps Script console -> New Project.
  2. Rename project (e.g., AnythingLLM Gmail Bridge).
  3. Replace all contents of Code.gs with the downloaded script.
  4. Edit the security key configuration variable near the top:
    const API_KEY = "YOUR_SECURE_RANDOM_STRING";
  5. Click Deploy > New deployment.
  6. Click the gear icon (Select type) -> Web App.
  7. Set parameters:
    • Execute as: Me
    • Who has access: Anyone
  8. Click Deploy, click Review Permissions, and authorize the script.
  9. Copy the generated Deployment ID.

3. Configure AnythingLLM

  • Input the Deployment ID and the configured API_KEY into the AnythingLLM Gmail Agent settings page.

Capability Reference & Tool Commands

Search & Read

  • Gmail Search
    • Syntax: Standard Gmail operators (is:inbox, is:unread, from:email, newer_than:7d).
    • Command: @agent search for unread emails in my inbox about the project
  • Gmail Read Thread
    • Action: Reads thread by ID; prompts before downloading attachments.
    • Command: @agent read the thread with ID <thread_id>

Draft Management

  • Create Draft ✏️
    • Command: @agent create a draft email to john@example.com about the meeting tomorrow
  • Create Draft Reply ✏️
    • Command: @agent create a draft reply to thread <thread_id> thanking them for the update
  • Update Draft ✏️
    • Command: @agent update draft <draft_id> to change the subject to "Updated: Meeting"
  • Get Draft
    • Command: @agent show me the draft with ID <draft_id>
  • List Drafts
    • Command: @agent list my email drafts
  • Delete Draft ✏️
    • Command: @agent delete the draft with ID <draft_id>
  • Send Draft ✏️
    • Command: @agent send the draft with ID <draft_id>

Send & Reply (Immediate)

  • Send Email ✏️
    • Command: @agent send an email to john@example.com about the project update
  • Reply to Thread ✏️
    • Command: @agent reply to thread <thread_id> saying I agree with the proposal

Thread Management

  • Mark as Read ✏️
    • Command: @agent mark thread <thread_id> as read
  • Mark as Unread ✏️
    • Command: @agent mark thread <thread_id> as unread
  • Move to Trash ✏️
    • Command: @agent move thread <thread_id> to trash
  • Move to Archive ✏️
    • Command: @agent archive thread <thread_id>
  • Move to Inbox ✏️
    • Command: @agent move thread <thread_id> to inbox

Account Administration

  • Get Mailbox Stats
    • Command: @agent how many unread emails do I have?

Maintenance Operations

Update the Script

  1. Open the project in the Google Apps Script console.
  2. Paste the updated script code into Code.gs (maintain your configured API_KEY).
  3. Click Deploy > Manage deployments.
  4. Click the Pencil (Edit) icon.
  5. In the configuration dropdown, select New Version, enter a description, and click Deploy. Note: The Deployment ID remains unchanged; no configuration updates are needed in AnythingLLM.

Delete the Connection

  1. Open the project in the Google Apps Script console.
  2. Click Deploy > Manage deployments.
  3. Select the active deployment(s) and click Archive.
  4. Navigate to Project Settings and click Delete.