Google Calendar Tools (Legacy - Use `langchain-google-community[calendar]`)

0.0.1 · deprecated · verified Thu Apr 16

This package, `langchain-google-calendar-tools` (version 0.0.1), is an early-stage project or demonstration for connecting to the Google Calendar API within LangChain. It appears to be a separate, less maintained effort. For robust and actively supported Google Calendar integrations with LangChain, it is *strongly recommended* to use the `langchain-google-community` package with the `calendar` extra, which provides comprehensive and up-to-date tools for calendar operations. This entry focuses on the requested `langchain-google-calendar-tools` but highlights the recommended alternative.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the recommended way to initialize the Google Calendar Toolkit and individual tools using `langchain-google-community`. It assumes you have `credentials.json` configured as per Google's OAuth 2.0 Desktop App flow. The toolkit will automatically attempt to use these credentials.

import os
import getpass

# Ensure you have a credentials.json file from Google Cloud Project setup
# See https://developers.google.com/calendar/api/quickstart/python

# Install the recommended package:
# pip install -qU langchain-google-community[calendar]

from langchain_google_community import CalendarToolkit
from langchain_google_community.calendar.tool import CalendarCreateEvent, CalendarSearchEvents

# Initialize the toolkit. It defaults to reading credentials.json
# You might need to place credentials.json in the root of your project
# or specify the path to the credentials file.
# For custom authentication, refer to LangChain documentation.

try:
    toolkit = CalendarToolkit()
    # You can also use individual tools directly
    create_event_tool = CalendarCreateEvent()
    search_events_tool = CalendarSearchEvents()

    print("CalendarToolkit initialized successfully.")
    # Example: Accessing a tool (this won't run without proper OAuth flow)
    # For a full example, you would typically integrate with an agent.
    # print(search_events_tool.name)

except Exception as e:
    print(f"Error initializing CalendarToolkit: {e}")
    print("Please ensure 'credentials.json' is correctly set up and OAuth flow is completed.")
    print("Refer to LangChain's Google Calendar documentation for detailed setup.")

view raw JSON →