AI Agent : Google calendar assistant using OpenAI n8n Workflow Template

n8n workflow template · 6 nodes · OpenAI

AI Agent : Google calendar assistant using OpenAI is a free n8n workflow template that starts when a chat message is received and works with OpenAI and Google Calendar. It has 6 nodes, 4 of them AI nodes (Chat Trigger, OpenAI Chat Model, Window Buffer Memory and AI Agent). The notes inside the workflow say: “This node specifies the chat model used by the agent. In the template, the default LLM is gpt-4o for its high relevance.” To run it, you add your own credentials for Google Calendar OAuth2 and OpenAI API.

At a glance

Trigger
Chat Trigger (When chat message received)
Nodes
6
Apps
OpenAI and Google Calendar
AI nodes
4
Credentials
2 types
Category
Spreadsheets, databases and docs

Apps and integrations

  • OpenAI
  • Google Calendar

Node types used

  • Chat Trigger
  • OpenAI Chat Model
  • Window Buffer Memory
  • Google Calendar Tool
  • AI Agent

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

OpenAI chat model

This node specifies the chat model used by the agent. In the template, the default LLM is gpt-4o for its high relevance.

  • You can try gpt-4o-mini, which is more cost-effective.
  • You can also choose other LLM providers besides OpenAI, but make sure the LLM you select supports tool-calling.

Google Calendar - Get Events

This sub-node is a tool used by the AI agent. Its purpose is to retrieve events based on the user input. For example: "Can you give me the events from last week about internal process?"

The AI agent is designed to use this tool only when it has a date range. If the user hasn’t provided a date range, the AI agent will ask the user for it.

The variables and are dynamically filled by the AI.

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Chat trigger - When a message is received

This node is the entry point of the workflow. It triggers the workflow whenever a message is sent to the chat interface.

Options with n8n

  • Embed the chat interface anywhere you want.
  • Use a webhook node instead of this node to connect with interfaces like Streamlit or OpenWebUI.
  • Use nodes for communication platforms (Slack, Teams, Discord, etc.) if you know how to configure them.

Tools Agent - Calendar AI Agent

This node configures the AI agent for interaction with Google Calendar. It includes the following features

  • A prompt source: This is the user message derived from the chat input of the preceding node (When chat message is received).
  • A system message: This defines the system prompt to guide the AI agent's behavior. It incorporates the variable {{ DateTime.local.toFormat('cccc d LLLL yyyy') }, allowing the AI agent to determine the current date and interact with Google Calendar accordingly. For example, the agent can understand a request like "Create an event called 'n8n workflow review' for next Tuesday."

n8n nodes come with built-in guardrails, ensuring that if the user requests tasks outside the AI agent's setup, it may not function as intended. (Feel free to test it!)

Window buffer memory

This node manages the memory of the agent, specifically the context window length for chat history. The default is set to 5 messages.

Note: The memory is temporary. If you want to store conversations with the agent, you should use other nodes like Postgres chat memory. This can be easily set up with services like Supabase.

Having fun with it? Here’s how to level up this AI agent!

This workflow demonstrates how easily you can set up an AI agent to call tools for you using n8n. The tasks here are useful but very basic.

If you want to enhance the tool-calling capabilities, consider the following

  • Explore the "options" in the Google Calendar nodes to see additional features you can use.

For example, let the AI agent add attendees to events it creates.

  • Implement the AI agent with your teammates and link it to each calendar.

Use a variable for the calendar field and refine the prompts to suit your needs.

  • Add more actions for the AI agent to perform with the Google Calendar API, expanding its functionality.

Google Calendar - Create Events

This sub-node is a tool used by the AI agent. Its purpose is to create events based on the user input. For example: "Can you create an event 'Quarter revenue meeting' on [date] from [hour] to [hour]?"

The AI agent is designed to use this tool only when it has a date range. If the user hasn’t provided a date range, the AI agent will ask the user for it. The variables and are dynamically filled by the AI.

Before creating the event, the AI agent will confirm with the user if the title and description of the event are correct. The variables used for this are

Nodes in this workflow

The 6 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. When chat message received (Chat Trigger)
  2. OpenAI Chat Model (OpenAI Chat Model)
  3. Window Buffer Memory (Window Buffer Memory)
  4. Google Calendar - Get Events (Google Calendar Tool)
  5. Google Calendar - Create events (Google Calendar Tool)
  6. Calendar AI Agent (AI Agent)

Credentials you need

  • Google Calendar OAuth2 – used by Google Calendar - Create events and Google Calendar - Get Events
  • OpenAI API – used by OpenAI Chat Model

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us