Custom tools for searching/adding events to Google Calendar #17586
mingxuan-he
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wrote two custom tool classes that lists and adds events to Google Calendar. I'm using them in one of the agents in my langgraph agent swarm. If anyone is looking for the same functionality, here's a quick reference and code file.
To use
gmail.utils
, and specifying the scope as["https://www.googleapis.com/auth/calendar"]
. (See example at the bottom)ListGoogleCalendarEvents
takes instart_datetime, end_datetime, max_results, timezone
CreateGoogleCalendarEvent
takes instart_datetime, end_datetime, summary, location, description, timezone
withlocation
anddescription
essentially treated as optional.With agents (get_current_time):
Typically agents don't know the current time / timezone when using calendar tools so it gets confused when you tell it to e.g. "Show me my upcoming events".
My solution is adding a minitool called
get_current_time
for the agent to use before using the calendar query tool. To work with applications hosted on servers, this requires a timezone specification in the agent's prompt. This minitool can also help agents handling todo-lists, meeting schedules, etc.Improvement suggestions are greatly appreciated!
Credits
This is heavily inspired by the O365 calendar and Gmail tools in
langchain_community.tools
. If anyone is interested in publishing these classes to the community tools collection, feel free to ping me for a PR.Code
Beta Was this translation helpful? Give feedback.
All reactions