<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Soham Mehta - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Soham Mehta - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 22:23:56 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/mehtasoham/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Build AI Workflows with n8n ]]>
                </title>
                <description>
                    <![CDATA[ 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 sm... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-build-ai-workflows-with-n8n/</link>
                <guid isPermaLink="false">68ed22c02001907a6cb6d50a</guid>
                
                    <category>
                        <![CDATA[ AI ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Workflow Automation ]]>
                    </category>
                
                    <category>
                        <![CDATA[ n8n ]]>
                    </category>
                
                    <category>
                        <![CDATA[ n8n workflows ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Soham Mehta ]]>
                </dc:creator>
                <pubDate>Mon, 13 Oct 2025 16:03:12 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760371342462/f8874220-238b-4819-a6f1-c35756b355bc.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>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.</p>
<p>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.</p>
<h2 id="heading-table-of-contents"><strong>Table of Contents</strong></h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-how-to-set-up-your-n8n-account">How to Set Up Your n8n Account</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-build-a-personal-calendar-agent">How to Build a Personal Calendar Agent</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-step-1-set-up-the-chat-trigger">Step 1: Set Up the Chat Trigger</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-configure-the-ai-agent">Step 2: Configure the AI Agent</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-add-google-calendar-node">Step 3: Add Google Calendar Node</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-time-to-test">Step 4: Time to Test!</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>n8n account – setup steps below.</p>
</li>
<li><p><a target="_blank" href="https://support.google.com/accounts/answer/27441">Google account</a> – you’ll create events in Google Calendar.</p>
</li>
</ul>
<h3 id="heading-how-to-set-up-your-n8n-account">How to Set Up Your n8n Account</h3>
<p>You can setup n8n either on the cloud or locally.</p>
<p>To set it up on the cloud (the easiest option), you can create a free trial account on the <a target="_blank" href="https://n8n.io/">n8n website</a>.</p>
<p>If you’d rather self-host via npm, you can install the free <a target="_blank" href="https://www.npmjs.com/package/n8n">n8n npm package</a> and run it on your localhost (here are the <a target="_blank" href="https://docs.n8n.io/hosting/installation/npm/">steps</a> for that).</p>
<p>You can also self-host via <a target="_blank" href="https://www.docker.com/">Docker</a> and run the n8n image on your machine. I’ll walk you through how to do that now.</p>
<p>First, download and install the <a target="_blank" href="https://www.docker.com/">Docker Desktop</a> application.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760074532772/e3987b3e-403c-4a96-b7a7-ed3347acbca0.png" alt="Screenshot of the Docker website showing navigation links and buttons for &quot;Download Docker Desktop&quot; and &quot;Learn about Docker for AI&quot; under the heading &quot;Develop Agents&quot;." class="image--center mx-auto" width="2524" height="690" loading="lazy"></p>
<p>Then click “Search Images” and select the <code>n8nio/n8n</code> image:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760074368306/eff04dd0-dcae-4c34-b5a1-f28c0db72373.png" alt="Docker Desktop interface showing a search for &quot;n8nio&quot; under Images. Several container images are listed with download and star counts. Options to Pull and Run the selected image are visible." class="image--center mx-auto" width="1542" height="452" loading="lazy"></p>
<p>Click <code>run</code> on the image and set your localhost port in the options.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760076583465/5f0bea8c-8d9d-4703-9561-1ede643c852e.png" alt="Screenshot of a browser window showing a &quot;Set up owner account&quot; page for n8n, a workflow automation tool. The form requires email, first name, last name, and password." class="image--center mx-auto" width="1548" height="498" loading="lazy"></p>
<p>You should now be able to access n8n on your localhost.</p>
<h2 id="heading-how-to-build-a-personal-calendar-agent">How to Build a Personal Calendar Agent</h2>
<p>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.</p>
<p>Here’s a breakdown of the steps we’ll go through below:</p>
<ol>
<li><p>Add a Chat node to send a message to the agent.</p>
</li>
<li><p>Let the AI Agent parse the message and extract key details (title, location, times).</p>
</li>
<li><p>Create a Google calendar event with those details.</p>
</li>
</ol>
<h3 id="heading-step-1-set-up-the-chat-trigger">Step 1: Set Up the Chat Trigger</h3>
<p>Every workflow starts with a trigger. This is the event that kicks everything off. Use a chat trigger that listens for new messages.</p>
<ol>
<li><p>Visit the dashboard at <code>https://&lt;YOUR_USERNAME&gt;.app.n8n.cloud/home/workflows</code> and Click <code>Create Workflow</code>.</p>
</li>
<li><p>Click “Add first step..” and add <code>On chat message</code> as the trigger.</p>
</li>
<li><p>In the node's properties panel, Enable <code>Make Chat Publicly Available</code> (This will provide a URL which you can share with friends to book events on your calendar).</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759649236134/c9ffc656-26b9-45a1-9c17-a6aa97a9e997.gif" alt="n8n workflow where you click &quot;On chat mesage&quot; as starting node" class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h3 id="heading-step-2-configure-the-ai-agent">Step 2: Configure the AI Agent</h3>
<p>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.</p>
<h4 id="heading-1-setup-the-model">1. Setup the Model</h4>
<p>Click the <strong>+</strong> icon after the trigger node and add the <code>AI Agent</code> node. The AI Agent needs a model to power its reasoning. Click + below <code>Chat Model</code> and select <code>OpenAI Chat Model</code> node.</p>
<p>Then select <code>n8n free OpenAI API credits</code> as your credential for now**.** In the future, you can sign up on the <a target="_blank" href="https://platform.openai.com/">OpenAI Platform</a> website and navigate to the "API keys" section to create a new secret key</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759692503994/ac37a0bf-1d39-4fbe-9393-94fda82ea7a8.gif" alt="Click &quot;AI agent&quot; node and select the OpenAI chat model " class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h4 id="heading-2-enable-date-time-tool">2. Enable date time tool</h4>
<p>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 <a target="_blank" href="https://help.clicksend.com/en/articles/44235-what-is-a-unix-timestamp">Unix Timestamp</a> before calling the Google calendar API.</p>
<p>Here are the steps to enable this tool:</p>
<ol>
<li><p>Click the + button below the AI Agent Tool</p>
</li>
<li><p>Find the Date &amp; Time tool</p>
</li>
<li><p>Set Operation as <code>Format a Date</code></p>
</li>
<li><p>Select Date as <code>Defined automatically by the model</code> (allow agent to pass date itself)</p>
</li>
<li><p>Select Format as <code>Unix Timestamp</code></p>
</li>
<li><p>Rename Output field name to <code>unixTime</code></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759692990713/e59e5f3e-4898-4aeb-af3a-e7dffbb44615.gif" alt="n8n workflow where we click the Tool under AI agent and select the Date time tool and select &quot;Unix timestamp&quot; for format" class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h4 id="heading-3-add-agent-prompt">3. Add agent prompt</h4>
<p>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.</p>
<ol>
<li><p>Double-click the AI Agent to edit the prompt.</p>
</li>
<li><p>Select Source for Prompt (User Message) as <code>Define below</code></p>
</li>
<li><p>Copy the following prompt in the Prompt (User Message)</p>
</li>
</ol>
<pre><code class="lang-plaintext">## 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 &amp; Time" tool to convert the computed event start and end time to unixtime.
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759693520456/df1a9a71-f790-42c3-9128-7289aaa35b22.gif" alt="User interface of the n8n workflow editor displaying a workflow named &quot;My workflow 2.&quot; The screen shows nodes including &quot;When chat message received,&quot; &quot;AI Agent,&quot; and connections to OpenAI Chat Model and Date &amp; Time. The user is interacting with the interface, and various menu options are visible on the left sidebar." class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h4 id="heading-4-set-up-structured-output">4. Set up structured output</h4>
<ol>
<li><p>Enable the <code>Require Specific Output Format</code> switch in AI Agent</p>
</li>
<li><p>Click + below Output Parser and select <code>Structured Output Parser</code></p>
</li>
<li><p>Copy the following example JSON which we want to extract from user message</p>
</li>
</ol>
<pre><code class="lang-json">{
    <span class="hljs-attr">"meeting_title"</span>: <span class="hljs-string">"Learn Geometry"</span>,
    <span class="hljs-attr">"meeting_location"</span>: <span class="hljs-string">"Library"</span>,
    <span class="hljs-attr">"event_start"</span>: <span class="hljs-number">1759644763</span>,
    <span class="hljs-attr">"event_end"</span>: <span class="hljs-number">1759644764</span>
}
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759693798967/bc8ba49e-09f3-43ed-9278-1cd4ada54560.gif" alt="Screenshot of an AI agent interface with a dialogue box showing parameters such as source for the user message and options for enabling specific output format. The workspace also displays input and output sections with no data." class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h3 id="heading-step-3-add-google-calendar-node">Step 3: Add Google Calendar Node</h3>
<p>The final step is to take the structured data from the AI Agent and create the calendar event.</p>
<ol>
<li><p>Click the <strong>+</strong> icon after the AI Agent node and search for the <strong>Google Calendar</strong> node.</p>
</li>
<li><p>Select Resource as <code>Event</code> and Operation as <code>Create</code></p>
</li>
<li><p>Create new OAuth2 credentials and sign in to your Google account. You'll be prompted to sign in to Google and grant N8N permission.</p>
</li>
</ol>
<p>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.</p>
<ol>
<li><p>Select Start as <code>{{ DateTime.fromSeconds($json.output.event_start).toFormat("yyyy-MM-dd HH:mm:ss") }}</code></p>
</li>
<li><p>Select End as <code>{{ DateTime.fromSeconds($json.output.event_end).toFormat("yyyy-MM-dd HH:mm:ss") }}</code></p>
</li>
<li><p>Select Location as <code>{{ $json.output.meeting_location }}</code></p>
</li>
<li><p>Select Summary as <code>{{ $json.output.meeting_title }}</code></p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759696195078/a35054a9-5c3d-44e8-9a30-5539f3675525.gif" alt="Workflow automation interface displaying a chat message integration with an AI agent, using nodes for OpenAI Chat Model, Date &amp; Time, and Structured Output Parser. Sidebar shows options for AI, app actions, data transformation, and more. A save button and trial information are visible at the top. Add &quot;Google Calender&quot; create event node" class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h3 id="heading-step-4-time-to-test">Step 4: Time to Test!</h3>
<p>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</p>
<p>You can also click on the Google calendar node to find the <code>htmlLink</code> column which will provide a URL where you can see your created event.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759696671635/a98acab0-2fa6-4c86-976e-996d5af00c59.gif" alt="A workflow automation setup in n8n showing a process where a chat message triggers an AI agent, which interacts with the OpenAI Chat Model and a Structured Output Parser to create an event. The interface includes various options like adding projects, templates, and accessing the admin panel." class="image--center mx-auto" width="2558" height="1024" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>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.</p>
<p>n8n's ecosystem thrives on <a target="_blank" href="https://n8n.io/workflows/">community templates</a>, 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!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
