logoCaywork Knowledge

Google Calendar Tool Node

Agent tool for interacting with the Google Calendar using per-user OAuth tokens.

Google Calendar Tool Node image

This node dispatches a multiple action-specific handlers and performs authenticated requests to the Google Calendar REST API using the calling user's stored Google OAuth token.

Actions

  • Retrieves per-user Google config (token, default_calendar, optional quota_project) from stored API keys and validates presence; errors if missing.
  • Builds request URLs and URL-encodes calendar and event IDs when required.
  • Performs HTTP requests with a shared async httpx client reused per asyncio event loop and default headers including the user's Bearer token.
  • Handles network errors and non-expected HTTP status codes by logging and raising descriptive runtime errors.
  • Parses JSON responses and returns text fallback when JSON parsing fails.
  • Supports the following actions (action-specific params described briefly below):
    • list_calendars list calendars for user (optional maxResults, pageToken).
    • get_calendar get calendar metadata (calendarId optional; defaults to configured default_calendar/"primary").
    • list_events list events on a calendar (calendarId; optional maxResults, pageToken, singleEvents, orderBy, timeZone, showDeleted, q, timeMin, timeMax).
    • get_event get a specific event (calendarId optional, eventId required).
    • create_event create an event (calendarId optional; provide event object or minimal params summary/start/end or start_datetime/end_datetime).
    • update_event update an event (calendarId optional, eventId required, event object required).
    • delete_event delete an event (calendarId optional, eventId required).
    • freebusy query free/busy (provide body or minimal timeMin, timeMax, items).

Outputs

  • Returns the parsed Google Calendar API response (JSON-decoded) or raw text if JSON decoding fails.
  • Errors surface as raised exceptions with logged context (network errors, validation errors, unexpected HTTP status codes).

Behavior and Constraints

  • Uses per-user stored OAuth tokens; expects a user API key named "GOOGLE_CALENDAR_TOKEN".
  • Reuses an async httpx client per asyncio event loop to limit connection overhead.
  • Default HTTP timeout is 20 seconds and max connections limited to 20.
  • Expected success status codes default to [200, 201, 204] unless overridden per-action.
  • Calendar identification uses provided calendarId or the configured default_calendar ("primary" by default).
  • Datetime parsing accepts ISO strings or naive datetimes; returns RFC3339-compatible ISO strings via dateutil parsing.
  • Minimal defaults: create_event and freebusy will synthesize minimal request bodies when explicit event/body is not provided.

Error Handling

  • Missing user Google config raises a RuntimeError indicating the missing key.
  • Network/request errors raise RuntimeError with logged exception details.
  • Non-success HTTP responses raise RuntimeError including status and body.
  • Action-specific parameter validation errors raise ValueError or pydantic ValidationError as appropriate.