Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agno.com/llms.txt

Use this file to discover all available pages before exploring further.

Search, read, and send emails. By default, exposes query_gmail for searching and reading. Enable write=True to also expose update_gmail for drafting and sending.
from agno.agent import Agent
from agno.context.gmail import GmailContextProvider

gmail = GmailContextProvider()

agent = Agent(
    model=...,
    tools=gmail.get_tools(),
)

agent.print_response("Do I have any unread emails from the engineering team?")

Authentication

Gmail requires Google OAuth or a service account with domain-wide delegation.
Set these environment variables:
export GOOGLE_CLIENT_ID=...
export GOOGLE_CLIENT_SECRET=...
export GOOGLE_PROJECT_ID=...
Opens browser on first use. Token cached to gmail_token.json.

Configuration

ParameterTypeDefaultDescription
idstr"gmail"Tools become query_<id> and update_<id>.
modelModelNoneModel for sub-agents.
readboolTrueExpose query_gmail.
writeboolFalseExpose update_gmail. Disabled by default for safety.
modeContextModedefaultSee Mode.

Tools Exposed

ToolDescription
query_gmailSearch emails, get messages, get threads, list labels. Always exposed.
update_gmailCreate drafts, send emails, send replies, manage labels. Requires write=True.

Example queries

For draft/send queries, enable writes: GmailContextProvider(write=True)
QueryWhat happens
”Find emails from Alice about the Q4 report”Searches with from:alice subject:Q4 report
”Summarize the thread about the API outage”Gets thread and synthesizes
”Draft a reply saying I’ll review it tomorrow”Creates draft in thread
”Send a quick update to the team about the fix”Composes and sends

Resources

GmailTools Reference

All methods and OAuth setup

Cookbook Example

Working example