Skip to main content

You already use Claude Code or Cursor to describe, test, and refine automations. Glean Headless Agent Builder lets you create an agent there, while discovering the triggers and action tools available in your deployment. You can preview the result before publishing it.

This recipe builds an agent that watches messages from one customer domain, decides whether a reply is needed, drafts a grounded response in Gmail, and alerts you in Slack. It handles the preparation; you remain in control of what is sent.

GmailA new thread arrives from the selected customer domain
Glean TriggerPermission-aware event starts the published agent
Glean agentClassifies, retrieves evidence, and prepares a response
Gmail draft + Slack DMThe owner reviews the draft and decides whether to send
Glean Headless Agent Builder enabled for auto-mode agents, with content triggers available
Gmail content indexed in Glean, including messages from the chosen customer domain
Gmail draft and owner-only Slack DM actions enabled for your account
Claude Code, or Cursor with Glean vNext available in its plugin marketplace
1

Choose the mailbox and customer domain

Provide the work email that owns the agent and the exact customer sender domain to watch. The trigger matches only messages that this user receives from that domain.

2

Add the Glean plugin marketplace

In Claude Code, add the marketplace with the command above. In Cursor, open Customize, find Glean vNext, and install it at user scope. A team admin can add it under Dashboard → Plugins → Add Marketplace → Import from Repo.

claude plugin marketplace add gleanwork/glean-plugins-vnext
3

Install the agent-builder plugin

Install the agent_builder skill at user scope so it remains available across projects. Cursor users can skip this step.

claude plugin install glean-vnext@glean-plugins-vnext --scope user
4

Reload the host and confirm the plugin

Reload or restart the host so it loads the plugin. Then confirm that /glean_run resolves.

5

Authenticate the plugin

Run setup, enter your work email when prompted, and complete the browser sign-in. The current setup flow does not require a server URL or API token.

6

Build the agent with the headless builder

Run /glean_run agent_builder and name the target directory. Use the builder to generate the agent files; do not manually author or edit spec.yaml or instructions.md. Request a Gmail thread trigger scoped to the owner and customer domain, search grounding, a reply-draft tool, and an owner-only Slack DM. Do not add an email-send tool. Stop without tool calls when the latest thread item is a draft, owner-authored, or already handled. Let the builder discover tenant-specific IDs.

7

Preview against a real thread

Run the agent against a real Gmail thread URL and name the same directory. The URL is passed as the reserved content input; inspect the run result before publishing. If the result is wrong, return to agent_builder instead of manually editing the generated spec or instructions.

8

Review the boundary, publish, and activate

Review the trigger scope and the unattended write boundary, then give one explicit confirmation before saving. Saving publishes the agent but does not activate it. On the returned page, allow connected-app actions, select Activate agent, and confirm ACTIVE.

9

Verify with a real email

Send one genuine customer question from the chosen domain. Confirm one run, one unsent draft on the original thread, and one Slack DM to the owner.

The unattended agent may create a reply draft but must never send it. A person owns the final customer communication.

Instructions inside the email cannot change recipients, tools, or the workflow's safety boundary.

Saving a draft may retrigger the Gmail thread. The agent treats draft, owner-authored, or already-handled messages as a no-op.

Take it further
  • Expand from one customer domain to a reviewed domain allow-list after the single-domain workflow is reliable.
  • Route unclear questions to a support queue while preserving the same no-send boundary.
  • Commit the generated .glean/agents/ folder in your own repo and wire up the Git ADLC sync action, so agent changes ship through pull requests.

Send a realistic customer question from the configured domain

One actionable run classifies the message, creates an unsent reply draft on the original Gmail thread, and sends the owner one Slack DM. Nothing is sent automatically.

Send an automated or FYI-only message from the configured domain

The agent sends the owner a short classification DM but creates no Gmail draft.

Paste into Claude Code, Cursor, or Codex.

Auth

The host signs in with Glean OAuth. Do not mint an API token for this recipe. Resolve the server URL first if a setup command asks for it.

At a glance
SurfacesAgents, MCP
StatusShowcase
Time~30 min
Required scopes
MCP