Automate Your Calendar with AI

Build an AI workflow in n8n that uses ChatGPT to manage your Google Calendar.

Introduction

โšก๏ธ 30 Second Summary

Manually adding events to your calendar multiple times a day is slow and distracting.

In this project, youโ€™ll build an AI workflow in n8n that uses ChatGPT to turn a short message into a Google Calendar event.

By the end, you'll have a simple text-to-calendar assistant and a repeatable pattern for future AI workflows you build in n8n.

What You'll Build

By the end of this project, you will:

  • ๐Ÿ”ง Set up an AI workflow using n8n.
  • ๐Ÿค– Integrate ChatGPT and Google Calendar into your workflow.
  • โš™๏ธ Configure dynamic expressions and a system message for accurate scheduling.
  • ๐Ÿ’Ž Secret Mission: Customize your AI assistant's personality with prompt engineering.

Want a complete demo of how to do this project, from start to finish? Check out our ๐ŸŽฌ walkthrough with Kahu ๐ŸŽฌ

Not sure if this project is right for you? Check if it matches your goals

If you're up for a bit of a challenge, quiz yourself on the key concepts up ahead in this project.

Sign up for n8n

To build our workflow, we need to set up our tools.

We'll use a tool called n8n to set up a workflow from scratch and connect it to other tools like ChatGPT and Google Calendar.

In this step, you're going to:

  • Sign up to n8n (for free)
  • Explore the n8n workspace

Sign up for n8n

What is n8n?

n8n is a no-code platform where you automate tasks by connecting apps and moving data between them. You build workflows by dragging and dropping, no code needed!

๐Ÿ’ก What do I get for free?

The free trial gives you access to n8n's platform for 14 days, and lets you build up to 5 workflows! We'll only be building one today, so we won't need to upgrade from the trial.

  • Enter your email address into the Company Email section.

โœ”๏ธ I already have an n8n account

Already have an n8n account? Let's sign you in!

  • Select Sign in from the top of the page.
  • Enter your n8n account name and select Sign in.
  • Enter your Email and Password, then select Sign in.

โŠ— I need to create an n8n account

No worries, let's get you set up!

  • Check your email for a verification link and verify your account.
  • Enter your details to start a free trial. You won't be asked for any payment or card details.
  • Select Start free 14-day trial.

My account name is getting rejected

Your n8n Account name has to be completely unique - think of it as your account's unique ID! If your first one gets rejected, try again until it gets accepted.

Set up Your Account

  • Awesome work! Once you've created your signup details, you'll need to answer a few questions.
  • These questions include:
    • What is the size of your company? Since we're here to learn, you can select the last option i.e. I'm not using n8n for work.
    • Which of these do you feel comfortable doing? Select any of the skills you're comfortable with, or leave them unselected if these are new to you!
    • How did you hear about n8n? Feel free to select Other and enter NextWork project
  • In the next page, select Skip. We won't need to invite others to your account!
  • Once your account is all set up, select Start automating.

Nice work! This kicks off your free trial of n8n, which should last 14 days.

Note

P.S. n8n also comes in a Community Edition, which is completely free to use with no trial or credit card required. The Community Edition takes longer to set up, so we'll save that for later projects! For now, we'll focus on diving into workflows as soon as we can.

Your Quick n8n Tour

Welcome to your n8n workspace!

If you'd like, you can switch to the dark mode of n8n!

โœ”๏ธ Skip dark mode

Sounds like a plan!

โŠ— Set up dark mode

  • Select the Settings icon on the bottom left corner of the workspace.
  • Select Personal.
  • Under Personalisation, select the Theme dropdown.
  • Select Dark theme.
  • Select Save.

Voilรก! You should see your n8n console in dark mode now.

Your n8n workspace is all set up and ready to go. Next up, we'll create our first workflow!

Start a new workflow

Now that we have n8n set up, let's set up a workflow from scratch!

A workflow is a chain of tools and actions that we automate. In this case, we're going to automate the process of booking new events into your digital calendar.

Let's see how we can start this workflow in n8n.

In this step, get ready to:

  • Create a new workflow in n8n
  • Add a chat trigger to the workflow
  • Test the chat trigger

Create a new workflow

  • Back in your n8n workspace, select Start from scratch.

What's the other option?

You might notice that the other option is to Build with AI. n8n also has a library of prompt templates that you can use to speed up developing AI agents and workflows.

We'll stick with building from scratch, but you can definitely explore workflow templates when you're ready to build another AI workflow!

Your first workflow

Welcome to your first workflow!

What is a workflow?

A workflow is a set of steps that complete a task; automating it means those steps run on their own, which saves you time and reduces errors.

A workflow becomes an AI workflow when it uses AI to automate tasks or decisions. For example:

  • Using image recognition to sort and categorize photos you upload to a folder.
  • Using generative AI to automatically draft a reply to new emails in your inbox.
  • Let's start by selecting Add first step in the middle of your canvas.
  • Here, you're asked for your workflow's trigger.

What is a workflow trigger?

A workflow trigger is like a starting point for a workflow.

It's what tells the workflow to begin. It can be something that happens at a specific time, like every hour, or something that happens because of an event, like getting a new email.

  • Select On chat message.

What does this trigger do?

We're using n8n's built-in chat window for our workflow, because it's the easiest one to test with. With this trigger, your workflow runs every time you enter a chat message. n8n will set up the chat window for you in just a second.

Set up your Chat Trigger

You're now in your chat trigger's setup!

  • We won't be adjusting these settings for now, so select Close on this modal.

Test your Chat Trigger

We don't have your workflow set up yet, but a great feature of n8n is that you can constantly test your workflow, and even isolate testing single parts of the workflow.

  • At the bottom of the canvas, select Open Chat.
  • Send your first chat message: Hello

The chat responds with raw JSON data instead of a real response.

That's okay! We haven't set up anything in the workflow to process a chat message yet. At least we've confirmed that we have a chat window for triggering the workflow.

And with our chat trigger working, we're ready to give our workflow a brain: something that can respond to our chat messages!

Integrate AI into Your Workflow

Now that our workflow has a chat to receive instructions, we'll add the "brain" of our workflow: an AI model.

The AI model will be responsible for turning chat commands like "book a meeting for tomorrow 10am" into instructions for scheduling events.

In this step, you're going to:

  • Add an AI Agent node to your workflow.
  • Connect an OpenAI Chat Model.

Connect a new node

  • Select the + button to add a new node.

What is a node?

Nodes are the key building blocks of a workflow. They can do a range of things, from triggering a workflow to processing and fetching data. Every block you add to your workflow is a node.

  • From the list of options, select AI.
  • Select AI Agent.

Hold on, are we creating an AI agent?

Good question! The node is called AI Agent, but we're building an AI workflow: it runs when you send a chat message (a trigger), not on its own. A true agent decides when to act without a trigger.

We'll keep saying "AI Agent" so you can find the node in n8n. You can read more on the distinction here if you're curious.

Configure the AI Agent node

Welcome to your AI Agent setup page!

As a quick rundown, the setup page is split into three parts:

  1. The left hand side represents the inputs i.e. the chat messages you send that trigger your workflow.
  2. The middle section represents the AI agent's setup.
  3. The right hand side represents the outputs i.e. the actions or results your agent will deliver.

In the middle section, check that:

  • The Source for Prompt (User Message) is set to Connected Chat Trigger Node.
  • The Prompt (User Message) shows ${{ $json.chatInput }}.

What is the Source for Prompt?

The Source for Prompt tells you where the AI agent gets its information. In our case, it's the chat window. The prompt field shows what data gets passed to the AI. $json.chatInput is the message you type.

  • Select the X to close the panel.

Nice! You'll see an AI Agent node on your canvas now, with three different sections beneath it.

What are the three different sections underneath the AI agent?

An AI agent is made of three key parts that you set up individually:

  • The Chat Model is the AI agent's brain, trained to analyze data to make decisions.
  • The Memory section stores data, past interactions, and learned information. This helps the AI agent learn from its past experiences and make better decisions over time.
  • The Tool section is the third-party software your agent will use. You can also use tools to enhance your AI agent, like using tools that help the AI communicate and speak in a different language.

Set up your Chat Model

  • Select the + for your agent's Chat Model.
  • Search for openAI and select the OpenAI Chat Model.

What is a chat model?

A chat model is a type of artificial intelligence (AI) that can understand and respond to text.

It's like a computer program that can have conversations with you. You type in a message, and the chat model uses its knowledge to understand what you're saying and generate a response.

The OpenAI Chat Model setup panel will open.

  • You'll see a banner offering 100 free OpenAI API credits. Select Claim credits.

What are these free credits?

n8n gives every account 100 free OpenAI API credits to claim, no OpenAI account needed! Once you use them up, you can replace this with your own OpenAI API key.

โœ”๏ธ I see the free credits banner

Once claimed, you'll see a success confirmation. The Credential to connect with dropdown now shows n8n free OpenAI API credits.

โ“ง I don't see the free credits banner

No worries! The banner should appear automatically for new n8n accounts, but sometimes it doesn't show up right away.

  • Try refreshing your browser and reopening the OpenAI Chat Model setup panel.
  • If the banner still doesn't appear, you can create your own API key at platform.openai.com and enter it in the Credential to connect with dropdown instead.

Still stuck?

Get help with your error or share your error with the NextWork community!

  • Check that the Model setting says gpt-4o-mini.

There are multiple OpenAI models?

Yup! OpenAI offers different AI models. Each model is made for different jobs. Some models are good at simple tasks like finishing sentences, while others are better at complex tasks like understanding conversations. We'll be using their simplest model, which still works perfectly for simple tasks like creating calendar events.

You can even check out OpenAI's own breakdown here.

  • Select the X to close the panel.

Your AI agent now has a brain! Next up, let's connect it to your calendar so it can actually book meetings.

Connect to Google Calendar

Your AI agent can now understand chat messages and respond intelligently. But it still can't touch your calendar. Let's fix that by connecting it to Google Calendar.

In this step, you're going to:

  • Add a connection to Google Calendar.
  • Set up dynamic expressions for event scheduling.

Add and connect the Google Calendar node

  • Select the + button for your AI Agent's Tool.

What is a Tool in my AI Agent?

A Tool is a piece of code or third party software that the agent can use to do a task.

Tasks could include retrieving data from a database, or in our case, creating an event in an external calendar (Google Calendar).

  • Search for Google Calendar and select it. We're going to use it to create new events in your calendar!

I don't use Google Calendar

You can also try this project using Outlook, and use the exact same setup over the rest of this project!

You're now in your Google Calendar tool's setup page!

  • Under Credential to connect with, select + Create new credential.
  • Select Sign in with Google.

Why do I need to sign in with Google?

This authorization lets your workflow act on your behalf, adding and checking events in your Google Calendar.

Without this authorization, your workflow can't access your calendar or do its job.

  • Select the account that's connected to a Google Calendar you use.

I don't want to give away access

You can remove access very easily at the end of this project! We'll show you how. Once access is removed, n8n will not be able to add or edit items in your calendar.

  • Make sure all access permissions are checked, then select Continue.

Once you're all connected, you'll see a success message: Connection successful

  • Close the tab, and head back to n8n.

Nice, you're all connected to your Google account!

  • Select the x icon on the top right corner.
  • Double check the default settings for your Google Account tool:
    • The Tool Description is Set Automatically.
    • The Resource is Event.
    • The Operation is Create.

What do these default settings mean?

  • Tool Description is Set Automatically - n8n writes the instructions that tell the AI agent how to use this tool. You'll learn to write these yourself in the next project!
  • Resource is Event - the tool works with calendar events, not the calendar itself.
  • Operation is Create - the tool's job is to add new events. Other operations like Get and Update are available if you want to expand your workflow later.
  • From the Calendar list, select your calendar.

Set up dynamic expressions

Right now, the Calendar tool has default Start Time and End Time settings that are hardcoded to now and now + 1 hour. If we left these as-is, the Calendar tool would always create events starting immediately, regardless of what time you ask for in the chat.

To let the AI model control when events are scheduled, we'll use n8n's $fromAI() expressions.

  • Update the Start to {{ $fromAI('start_time') }}
  • Update the End Time to {{ $fromAI('end_time') }}

Watch out for a common mistake!

It's easy to accidentally use start_time for both the Start and End fields. Double-check that your End Time uses $fromAI('end_time'), not $fromAI('start_time')!

What does $fromAI() do?

$fromAI() expressions tell the Calendar tool to get its values from the AI model, instead of using hardcoded defaults. The parameter name inside (like start_time) is a hint to the AI model about what information to look for in the chat.

For example, $fromAI('email') would make the AI model look for an email address instead of a time.

๐Ÿ™‹โ€โ™€๏ธ Why are both expressions in red?

Nothing to worry about! Red expressions in n8n usually indicate errors or missing data. In our case, it means the AI model needs a new chat message to start filling in values for these expressions. In the meantime, these values are empty.

  • Head back to your canvas.

Great! You have your AI chat model and calendar now set up.

Your workflow can now understand chat messages and create calendar events. Next up, we'll give the AI model context about today's date so it can schedule events accurately!

Write a System Message

Your Calendar tool can now receive scheduling times from the AI model. But there's one more thing the AI model needs: context about what today's date is.

Without knowing today's date, the AI model can't accurately schedule events for "tomorrow" or "next Monday." Let's give it that context with a system message.

In this step, you're going to:

  • Add a system message to your AI agent.
  • Configure the system message to use Expression mode.

Add a System Message

  • In your n8n workflow's canvas, double click on your AI Agent.

This opens up your AI Agent's settings!

  • Select Add Option at the bottom of the screen.
  • Select System Message.

What is a system message?

The system message is a prompt that your workflow sends to the AI agent before it starts processing your chat message.

If you don't enter a system message, your AI agent doesn't have any instructions on what it's meant to do and the current context (e.g. today's date).

  • Before you start typing, switch the System Message setting from Fixed to Expression.

What does the Expression setting do?

The Expression setting means you're entering dynamic input, i.e. input that can change based on the functions you've put inside.

The Fixed setting treats everything as plain text. Since our system message includes a DateTime function to calculate today's date, we need Expression mode so n8n actually runs the function instead of treating it as text.

  • Enter a system message that tells your AI Agent what it's meant to do, and information on today's date.
You are a calendar assistant. Your job is to check my availability and create new events for times that my calendar is free.

You are to use the Chat Model to process the user's requests, then check using the Check Availability tool on whether that time is free. You can use the Google Calendar tool to create a new event in my calendar if I am available.

Today's date is {{DateTime.now().setZone('[[LEARNER_TIMEZONE="TIMEZONE"]]').toFormat('dd LLL yyyy HH:mm:ss')}}
  • Check: Make sure to replace the TIMEZONE placeholder in the last line of the System Message with your local time zone.

How do I find my time zone?

You have two choices...

  1. Search for your time zone manually using this list.
  2. Ask an AI model like ChatGPT for help. Here's a prompt you could use:
You are setting a date in the local time zone for my city. Replace the TIMEZONE placeholder to my location. The ideal output format is simply the updated reference.
{{DateTime.now().setZone('[[LEARNER_TIMEZONE="TIMEZONE"]]').toFormat('dd LLL yyyy HH:mm:ss')}}
  • Jump back into the canvas!

Your AI agent now knows what today's date is and what it's meant to do. Time to put it all to the test!

Test Your Workflow

You've set up your Calendar tool with dynamic expressions and given your AI agent a system message. Let's see it all come together!

In this step, you're going to:

  • Test your AI workflow with a chat message.
  • Verify the calendar event was created at the correct time.

Test Your Chat

  • Close any open setup panels so you're back on your canvas.
  • Click into your chat's message box.
  • Start the conversation with Hello to confirm your chat model is working.

โœ”๏ธ My chat model is working

Nice work! Continue below ๐Ÿ‘‡

โ“ง I ran into an error

Don't worry - this is a common issue! It's usually caused by curly (smart) quotes sneaking into your DateTime expression.

  • Check that your system message uses straight quotes (') and not curly quotes (' or ') in the .setZone() and .toFormat() functions.

Here's an example of curly quotes that would trigger the error:

And here's what the correct straight quotes look like:

Still stuck?

Get help with your error or share your error with the NextWork community!

  • Now try to book a time in your own calendar.
  • Open your Google Calendar.
  • Look for a 1-hour slot that's free (i.e. empty in your calendar) for tomorrow.
  • Head back to your chat window, and ask your workflow to book a meeting at that time. Make sure you mention tomorrow in the request.

The AI agent confirms the meeting was scheduled and shares a Google Calendar link.

My AI agent didn't try to book an event

Try rephrasing your request to be more specific, like: "Book a meeting for tomorrow at 3pm for 1 hour called Team Standup."

If the issue persists, double check that your Google Calendar tool has the $fromAI() expressions for Start and End Time, and that your System Message is set to Expression mode (not Fixed).

Congrats! A meeting is scheduled at the right time. Your AI-powered calendar assistant is working!

Well done! You've built a fully functional AI workflow that takes natural language chat messages and turns them into real calendar events.

Secret mission

Your calendar assistant works, but it sounds... pretty generic. What if it could have a personality?

In this secret mission, you'll use advanced system messages to transform your assistant's tone, add custom rules, and see just how much control prompt engineering gives you over AI behavior.

In this secret mission, get ready to:

  • Change how your calendar assistant talks and books meetings.
  • Showcase advanced prompt engineering skills in your documentation!

Change your AI's personality

Clean Up Your Resources

Clean Up Your Resources

Now that you've built a working calendar assistant, let's manage the resources we created.

You won't be charged for leaving your resources in your account, but we'd recommend removing credential information if you no longer want to share your Calendar details with n8n.

Resources to manage:

  • Stop sharing your Google Calendar credentials in n8n.
  • Archive the n8n workflow.
  • Delete the test events in Google Calendar.

๐ŸŸข Keep everything running

Want to keep experimenting with your AI workflow? No action needed here! Your workflow will stay active and you can continue chatting with it anytime.

When you're ready to clean up, come back to this section and follow the steps in the other tabs.

๐ŸŸก Stop sharing credentials

  • From your left hand menu, select Overview.

You're now at the Overview page, which lets you see all your workflows and settings.

  • Select the Credentials tab.
  • Select the three dots for your Google Calendar account, and select Delete.
  • Select Yes, delete to confirm your deletion. Note that this means your workflow will be broken until you set up the connection again!

๐Ÿ”ด Delete everything

Archive your workflow

  • Head back to the Workflows tab.
  • Select the three dots next to My workflow.
  • Select Archive.

Delete test events

  • Switch tabs from n8n to Google Calendar.
  • Select a test event created by your AI assistant.
  • Select the delete icon to remove the event.

That's a wrap!

That's a wrap!

Congrats on building a fully functional AI-powered calendar assistant!

You've learned how to:

  • ๐Ÿ”ง Use n8n to build a workflow.
  • ๐Ÿค– Integrate ChatGPT as your AI model to understand requests.
  • ๐Ÿ—“๏ธ Integrate Google Calendar as your calendar tool.
  • โš™๏ธ Configure dynamic expressions and system messages for accurate scheduling.
  • ๐Ÿ’Ž Change your AI's personality with advanced system messages.

Ready to quiz yourself? ๐Ÿ’ช

p.s. Does it say "Still tasks to complete!" at the bottom of the screen?

This means you still have screenshots left to upload, or questions left to answer!

  1. Press Ctrl+F (Windows) or Command+F (Mac) on your keyboard.
  2. Search for the text Return to later.
  3. Jump straight to your incomplete tasks!
  4. ๐Ÿ™‹โ€โ™€๏ธ Still stuck? Ask the community!