n8n is a visual, node-based automation platform that lets you automate tasks with drag-and-drop nodes. It’s popular for multi-step automations and AI chains thanks to built-in nodes for agents and app integrations.
In this tutorial, you’ll build a small personal calendar agent that listens to a chat message, extracts event details, and creates a Google Calendar entry. Along the way, you’ll learn how to set up n8n, add an AI Agent node, and pass structured data between nodes.
Table of Contents
Prerequisites
n8n account – setup steps below.
Google account – you’ll create events in Google Calendar.
How to Set Up Your n8n Account
You can setup n8n either on the cloud or locally.
To set it up on the cloud (the easiest option), you can create a free trial account on the n8n website.
If you’d rather self-host via npm, you can install the free n8n npm package and run it on your localhost (here are the steps for that).
You can also self-host via Docker and run the n8n image on your machine. I’ll walk you through how to do that now.
First, download and install the Docker Desktop application.
Then click “Search Images” and select the n8nio/n8n
image:
Click run
on the image and set your localhost port in the options.
You should now be able to access n8n on your localhost.
How to Build a Personal Calendar Agent
Now for the fun part! We’re going to build a workflow that listens for a chat message, uses an AI Agent to understand the user's request, and automatically creates a Google Calendar event. This simple workflow highlights n8n’s new AI capabilities.
Here’s a breakdown of the steps we’ll go through below:
Add a Chat node to send a message to the agent.
Let the AI Agent parse the message and extract key details (title, location, times).
Create a Google calendar event with those details.
Step 1: Set Up the Chat Trigger
Every workflow starts with a trigger. This is the event that kicks everything off. Use a chat trigger that listens for new messages.
Visit the dashboard at
https://<YOUR_USERNAME>.app.n8n.cloud/home/workflows
and ClickCreate Workflow
.Click “Add first step..” and add
On chat message
as the trigger.In the node's properties panel, Enable
Make Chat Publicly Available
(This will provide a URL which you can share with friends to book events on your calendar).
Step 2: Configure the AI Agent
This node is the “brain” of the workflow. The AI Agent node can understand natural language, make decisions, and extract structured data. Each agent has 4 main modules: model, prompt, tools, and output.
1. Setup the Model
Click the + icon after the trigger node and add the AI Agent
node. The AI Agent needs a model to power its reasoning. Click + below Chat Model
and select OpenAI Chat Model
node.
Then select n8n free OpenAI API credits
as your credential for now**.** In the future, you can sign up on the OpenAI Platform website and navigate to the "API keys" section to create a new secret key
2. Enable date time tool
A tool is a connected node the agent can call during execution to perform actions (like fetching data, formatting dates, or running code) rather than only reasoning in text. We will be using the “Date Time” tool to convert the user readable date into a Unix Timestamp before calling the Google calendar API.
Here are the steps to enable this tool:
Click the + button below the AI Agent Tool
Find the Date & Time tool
Set Operation as
Format a Date
Select Date as
Defined automatically by the model
(allow agent to pass date itself)Select Format as
Unix Timestamp
Rename Output field name to
unixTime
3. Add agent prompt
An agent prompt is the set of instructions and context you give an AI Agent that defines its behavior, goals, and how it should interpret or respond to user inputs.
Double-click the AI Agent to edit the prompt.
Select Source for Prompt (User Message) as
Define below
Copy the following prompt in the Prompt (User Message)
## Overview
You are an agent which helps parse the user message to identify the following details:
1. The title for the meeting
2. The location of the meeting
3. The meeting start and end Unix times.
Here is the User Message: {{ $json.chatInput }}
## Rules for event time identification:
- The current date time now is: {{ $now }}
- Resolve relative phrases like "tomorrow", "next Friday", "in 2 hours" relative to now.
- If duration given (e.g., "30 min" or "2 hours"), compute end_time from start_time.
- If only a start time given, default duration = 60 minutes.
## Getting event_start and event_end unix
- Use the "Date & Time" tool to convert the computed event start and end time to unixtime.
4. Set up structured output
Enable the
Require Specific Output Format
switch in AI AgentClick + below Output Parser and select
Structured Output Parser
Copy the following example JSON which we want to extract from user message
{
"meeting_title": "Learn Geometry",
"meeting_location": "Library",
"event_start": 1759644763,
"event_end": 1759644764
}
Step 3: Add Google Calendar Node
The final step is to take the structured data from the AI Agent and create the calendar event.
Click the + icon after the AI Agent node and search for the Google Calendar node.
Select Resource as
Event
and Operation asCreate
Create new OAuth2 credentials and sign in to your Google account. You'll be prompted to sign in to Google and grant N8N permission.
Now, you’re going to map the data from the AI Agent to the fields in the Google Calendar node. This is where the magic happens.
Select Start as
{{ DateTime.fromSeconds($json.output.event_start).toFormat("yyyy-MM-dd HH:mm:ss") }}
Select End as
{{ DateTime.fromSeconds($json.output.event_end).toFormat("yyyy-MM-dd HH:mm:ss") }}
Select Location as
{{ $json.output.meeting_location }}
Select Summary as
{{ $json.output.meeting_title }}
Step 4: Time to Test!
That’s it! You now have an AI-powered workflow that creates events on your calendar. You can activate your workflow using the toggle at the top of the screen. Click “Open Chat” to initiate a chat conversation and send a message. You will see the entire workflow in action along with input and output of each node
You can also click on the Google calendar node to find the htmlLink
column which will provide a URL where you can see your created event.
Conclusion
In this tutorial, you’ve learned how to build a simple, AI-driven automation workflow in n8n’s visual interface. The true power lies in creating personalized AI workflows by easily customizing your own agent, prompt, and tools to fit your exact needs.
n8n's ecosystem thrives on community templates, allowing you to utilize thousands of pre-built solutions or share your own creations with the community. If this guide helped you, try extending the workflow on your own and explore the n8n docs for more nodes. Happy coding!