Gmail Agent Actions (gmail/actions.py)

ai-agent-book · chapter9/browser-use-rpa/browser-use/browser_use/integrations/gmail/actions.py · python · Apache-2.0
auth, email, automation, ai

Registers browser-use agent actions for Gmail, enabling retrieval of recent emails (e.g. 2FA codes) by keyword search for automated login flows.

# Source: https://github.com/bojieli/ai-agent-book | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""
Gmail Actions for Browser Use
Defines agent actions for Gmail integration including 2FA code retrieval,
email reading, and authentication management.
"""

import logging

from pydantic import BaseModel, Field

from browser_use.agent.views import ActionResult
from browser_use.tools.service import Tools

from .service import GmailService

logger = logging.getLogger(__name__)

# Global Gmail service instance - initialized when actions are registered
_gmail_service: GmailService | None = None


class GetRecentEmailsParams(BaseModel):
	"""Parameters for getting recent emails"""

	keywo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key