Gmail enables an Agent to interact with Gmail, allowing it to read, search, send, and manage emails.

Prerequisites

The Gmail toolkit requires Google API client libraries and proper authentication setup. Install the required dependencies:

pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib

You’ll also need to set up Google Cloud credentials:

  1. Go to Google Cloud Console
  2. Create a project or select an existing one
  3. Enable the Gmail API
  4. Create OAuth 2.0 credentials
  5. Set up environment variables:
export GOOGLE_CLIENT_ID=your_client_id_here
export GOOGLE_CLIENT_SECRET=your_client_secret_here
export GOOGLE_PROJECT_ID=your_project_id_here
export GOOGLE_REDIRECT_URI=http://localhost  # Default value

Example

cookbook/tools/gmail_tools.py
from agno.agent import Agent
from agno.tools.gmail import GmailTools

agent = Agent(tools=[GmailTools()], show_tool_calls=True)
agent.print_response("Show me my latest 5 unread emails", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
get_latest_emailsboolTrueEnable retrieving latest emails from inbox
get_emails_from_userboolTrueEnable getting emails from specific senders
get_unread_emailsboolTrueEnable fetching unread emails
get_starred_emailsboolTrueEnable retrieving starred emails
get_emails_by_contextboolTrueEnable searching emails by context
get_emails_by_dateboolTrueEnable retrieving emails within date ranges
create_draft_emailboolTrueEnable creating email drafts
send_emailboolTrueEnable sending emails
search_emailsboolTrueEnable searching emails

Toolkit Functions

FunctionDescription
get_latest_emailsGet the latest X emails from the user’s inbox
get_emails_from_userGet X number of emails from a specific sender
get_unread_emailsGet the latest X unread emails
get_starred_emailsGet X number of starred emails
get_emails_by_contextGet X number of emails matching a specific context
get_emails_by_dateGet emails within a specific date range
create_draft_emailCreate and save an email draft
send_emailSend an email immediately
search_emailsSearch emails using natural language queries

Developer Resources