Google Calendar
Last updated
Last updated
Enable an Agent to work with Google Calendar to view and schedule meetings.
Reference:
Enable Google Calender API
Go to .
Select Project and Enable.
Go To API & Service -> OAuth Consent Screen
Select User Type
If you are a Google Workspace user, select Internal.
Otherwise, select External.
Fill in the app details (App name, logo, support email, etc).
Select Scope
Click on Add or Remove Scope.
Search for Google Calender API (Make sure you’ve enabled Google calender API otherwise scopes wont be visible).
Select scopes accordingly
From the dropdown check on /auth/calendar
scope
Save and continue.
Adding Test User
Click Add Users and enter the email addresses of the users you want to allow during testing.
NOTE : Only these users can access the app’s OAuth functionality when the app is in “Testing” mode. Any other users will receive access denied errors.
To make the app available to all users, you’ll need to move the app’s status to “In Production”. Before doing so, ensure the app is fully verified by Google if it uses sensitive or restricted scopes.
Click on Go back to Dashboard.
Generate OAuth 2.0 Client ID
Go to Credentials.
Click on Create Credentials -> OAuth Client ID
Select Application Type as Desktop app.
Download JSON.
Using Google Calender Tool
Pass the path of downloaded credentials as credentials_path to Google Calender tool.
Optional: Set the token_path
parameter to specify where the tool should create the token.json
file.
The token.json
file is used to store the user’s access and refresh tokens and is automatically created during the authorization flow if it doesn’t already exist.
If token_path
is not explicitly provided, the file will be created in the default location which is your current working directory.
If you choose to specify token_path
, please ensure that the directory you provide has write access, as the application needs to create or update this file during the authentication process.
The following agent will use GoogleCalendarTools to find today’s events.
cookbook/tools/googlecalendar_tools.py
credentials_path
str
None
Path of the file credentials.json file which contains OAuth 2.0 Client ID.
token_path
str
None
Path of the file token.json which stores the user’s access and refresh tokens.
list_events
List events from the user’s primary calendar.
create_event
Create a new event in the user’s primary calendar.