Learn the basics of n8n: self-hosted automation for a lower price

With a lower price and self-hosting options, n8n stands out as a unique automation provider. In this guide, we'll show you how to build your first automation in n8n step by step.

Written by
Tom Nassr
and
Matt Jasinski

March 17, 2025

Are you spending too much on Zapier or Make? Meet n8n, the powerful automation provider that lets you build workflows and AI agents for a fraction of the cost. 

Whether you need enterprise-grade security with self-hosting or just want to save money on your automated setup, n8n has you covered.

In this beginner's guide, we'll walk you through setting up n8n and creating your first automation from scratch - a simple workflow that sends Slack notifications when you receive specific emails.

What Is n8n?

n8n is a flexible automation platform that connects your apps and services, allowing you to build custom workflows without coding knowledge. What sets it apart is its competitive pricing and the option for self-hosting, giving you more control over your data and potentially significant cost savings compared to other automation platforms.

Additionally, if you or your team have a background in software development, you’ll find that n8n offers extensive support for inserting custom code into your automated workflows. However, in this guide, we’ll focus on n8n’s no-code automation capabilities. 

Getting started with n8n

When you first log into n8n, you'll see the “Overview” page which will give you a summary of your workflows, credentials, and executions. For new users, this will be empty and inviting you to create your first automation. 

Simply click the "Create" button in the top right corner to create a new automated workflow.  

creating a new workflow in n8n

Building your first workflow: Gmail to Slack notification

Let's create something practical and immediately useful - a workflow that notifies you in Slack when you receive important emails. We'll start simple and then add some intelligence to the system.

Our workflow will:

  • Detect new emails in your Gmail inbox
  • Send details to you in Slack with a direct link to the email
  • Filter for emails containing a specific term in the subject ("marketing")
  • Share emails matching the filter with a team channel

Bear in mind that this is just one example that we’re using to demonstrate how n8n works. These same principles will apply to the hundreds of apps supported in n8n, like Jira, Hubspot, Notion, and Wordpress. 

You can find the full list of n8n’s integrations here

Setting up your workflow’s trigger: New emails in Gmail

Choose a trigger type

Click "Add first step" on your canvas, and you'll see a side menu appear with various trigger options. 

Adding a trigger to an n8n workflow

We want our workflow to run when something happens in another app, so select "Run on an app event."

Trigger types in n8n

Pick an app and event for your trigger

Search for your trigger app (Gmail) in the search box and select it. 

Searching for a trigger app

Then, choose the specific event that will trigger your automation. You'll only see one option here for Gmail  - "On message received" - which is exactly what we need. Select it and move to the configuration screen.

Selecting a trigger event

Connect an account to authorize your trigger app

Next, you’ll need to connect a credential for your trigger app. In this case, that means signing in to your Gmail account to authorize n8n to look for new emails in your inbox. 

Click on the credentials dropdown and create a new credential. 

Create a new credential for a connected app in n8n

This will prompt you to sign in with your Google account and allow n8n to access your emails. 

Signing in with Google to authorize Gmail in n8n

Don't worry - n8n only uses this access to detect new messages and read their contents for your automation, similar to how Zapier or other platforms work. It will only access your account how you instruct it to in your automations. 

Authorizing n8n to access Gmail

Once you’ve created your Gmail credential, click on the ‘x’ in the top right corner of the credential window to return the configuration menu for your trigger. 

A newly created credential in n8n

Configure your trigger

On the configuration screen, you'll see several options. Here’s the setup we’ll use:

• Poll times: Determines how often n8n checks for new emails. We’ll use the default option, and search for new emails every minute.

• Simplify: Toggle this off to receive comprehensive email data. For this tutorial, make sure to keep this setting off. 

• Filters: Optional restrictions for specific senders or labels. You won’t need to apply any filters in this tutorial, but you can add them if you’d like to narrow down the list of emails your automation runs for. 

Configuring a Gmail trigger in n8n

Test your trigger

Once your configuration is all set, click "Fetch test event" to retrieve a sample email. 

Testing a trigger in n8n

On the right hand “Output” panel, you’ll see a preview of the data your workflow will process when it triggers. 

Reviewing test data in a table

Switch to the "Schema" view for a clean list of all variables like subject, sender address, and timestamp - you'll use these later when crafting your Slack notification.

Reviewing test data in a "schema" view

Creating an automated action: Direct message in Slack

With your Gmail trigger configured, it's time to decide what happens when a new email arrives. Go back to your canvas, and click the "+" button to the right of your Gmail node to add an automated action to your workflow. 

Add a new action to an n8n workflow

You’ll see several options for what happens next, including flexible data transformation and flow control modules. For this tutorial, we’ll choose "Add an action in another app" so we can set up an automated Slack message. 

Automating an action in another app

Choose your app and action

Search for the app you want to automate – in this case, Slack. Then, select it from the search results.

searching for an app to automate

Next, you’ll need to pick the action that you want to automate within that app. For our example, that will be "Send a message." 

Choosing an automated action

Connect an account for your automated action

Just like with our Gmail trigger, you'll need to connect your Slack account by creating a new credential. 

Creating a credential for an automated action

You might see a warning that n8n isn't officially approved by Slack – this is normal for many automation platforms and nothing to worry about. This just means that n8n hasn’t yet gone through the formal process of creating a Slack app. 

Authorizing n8n to access Slack

After connecting your Slack account, return to the configuration screen and select it from the credentials dropdown.

Configure your automated action

Now for the fun part – designing your notification message. First, decide where to send it by selecting "User" and choosing yourself as the recipient. 

Configuring an automated Slack message in n8n

Tip - you can select users from a list of their display names, or by entering their Slack ID. 

With your user chosen, you can craft your message with a mix of static text and dynamic content from your email. To add dynamic content to your message, just drag data from the “Inputs” schema on the left into the text field. 

In our example, we’ll include dynamic data for the email’s subject, the “from” address, and the time the email was sent. Note that once you drop a variable into the text window, it will transform into a bit of JSON formatted code. 

Adding dynamic data from the trigger into the automated message

We’ll also include a link to view the email in our inbox. n8n didn’t retrieve a complete URL in the Gmail trigger, but it did retrieve an ID for the email. We can use this in combination with some static text to construct a complete link. 

Enter [start of link[ directly into the text field, then drag and drop the “ID” variable to complete the URL. 

Adding the email's URL to the Slack message

Tip: you can click the icon in the bottom right of the message text field to expand it into a larger window. 

We’ll also use some Slack-compatible markdown to embed this link into our message text. That syntax looks like this:

<your link | your text >

Reformatting data with simple functions

Finally, before testing this automated action, let’s reformat the “Date” timestamp to be easier to read. We can do this with a couple of simple functions appended to the end of the $json.date object. 

Use the toDateTime() function to convert the text into timestamp data, then use the format() function to reformat it however you’d like. We’ll use ‘MMM dd yyy hh:mma’ to get a result like Feb 06 2025 03:27PM. 

Using functions to reformat a date or timestamp

Augment your automations with AI

Not sure how to transform your data with functions? Try asking n8n’s built-in AI assistant. Just ask it any question you have about building a workflow, and it will make its best attempt at helping you out. 

In our experience, it was pretty useful, but definitely not perfect. It will get you 80% of the way there, but you’ll need to fix some of its errors and finish things up on your own. 

n8n's AI assistant

You can find the AI assistant in the bottom right hand corner while you’re building. 

Test your automated action

Once you’ve configured your message to your liking, give the action a test. Testing an action in n8n will actually perform the action, so testing a “send message” action will actually send a message in Slack. 

Click on “Test step” to execute the node. 

Testing an automated action

After your test runs, you’ll see data appear in the “outputs” panel on the right. This is the data you can access in any future steps you add to your workflow. 

You can also check Slack to see the message that got sent. 

A Slack message created by n8n

After our test, we see a message complete with a correctly formatted date and a link that leads directly to the email in our inbox. 

Create a more versatile workflow with filters

Simple, straightforward automations like this can be useful in some contexts, but you’ll often need something that’s a little more flexible. In many cases, you’ll want to process emails differently based on their content and metadata. 

To run different actions based on different inputs, you can use n8n’s flow control features. For example, let’s imagine you want to add a second Slack message that sends a similar alert to the Marketing channel in Slack, but only if the email’s subject contains the term ‘marketing’. 

To accomplish this, you only need to add a filter after the original Slack message, then add an action for a second Slack message after the filter. 

Adding a filter

Click the "+" button after your Slack action and select “Flow” from the list of actions.

Adding a "flow" action to a workflow

Then, choose "Filter" from the flow control options. 

Adding a filter to a workflow

This node acts as a gatekeeper, only allowing emails that match specific criteria to continue through additional steps.

Configuring your filter

Every filter consists of one or more conditions. When the automation runs, it will test the incoming data against those conditions, and will only proceed to the subsequent steps in the automation if the data matches the conditions. 

For our example, we’ll just evaluate one simple condition. We’ll drag and drop the “Subject” variable from the Input window into the first value field. 

Adding a value to a condition

Tip: you may need to click “execute previous nodes” to generate input data. 

Then, we’ll set the operator to "contains," and enter "marketing" as the second value. We’ll also add an option to ignore case. 

Configuring a condition in an n8n filter

Now only emails with "marketing" in the subject line will pass through.

Testing your filter

Once your filter is configured with all of the conditions you want, give it a test by clicking on “Test step”. 

If the currently loaded test data passes the filter, you’ll see data populate the output window as normal. Otherwise, it will be sent to the “Discarded” tab. 

Adding actions after a filter

With your filter set up and tested, you can add any actions you want to perform for data that passes it. Remember, these actions will not run for any data that doesn’t match your specified conditions. 

We’ll just add another Slack message, but this one will go to a channel instead of a specific user. It will also include the full body of the email in question, rather than a link. 

Configuring a second Slack message sent after the filter

You can test these actions to see their outputs as well. 

A second Slack message sent by n8n

Saving and Activating Your Workflow

With all your nodes configured, click "Save" in the top right corner of the builder to commit all your changes. 

Saving an automation in n8n

Return to the workflows overview and make sure your new automation is toggled on. 

Toggling an automation on in the overview screen

That's it! Your workflow is now live and monitoring your inbox.

From now on, you'll receive a Slack message whenever an email arrives in your inbox. If the subject contains "marketing," your team channel will also get notified with the contents.

n8n pricing overview

One of n8n's most compelling features is its pricing structure. At $50/month, the Pro plan includes 10,000 executions and unlimited users – significantly more affordable than Zapier's $170/month Team plan, which only supports 25 users and counts individual tasks rather than complete executions.

n8n pricing

Self-hosting n8n

For organizations with security or compliance requirements, n8n offers a unique advantage: self-hosting. 

Available through either an enterprise plan or a free community version on GitHub, this capability gives you complete control over your automation infrastructure and data.

The community version follows n8n's "fair code" model, making the source code freely available with some restrictions on commercial use. 

While it has certain limitations (like lack of variable support), it provides an option that simply isn't available with most other automation platforms.

Affordable, self-hosted automation with less frills

n8n might lack some of the polished features found in more established platforms like Zapier, but its combination of affordability, flexibility, and self-hosting options makes it a compelling choice for individuals and teams looking to build powerful automated workflows without breaking the bank.

If you’d like to use n8n or other low-code automation platforms to create more time for your team, just reach out to XRay for a free consultation to get started. 

For more DIY automation tips and tutorials, check out the other posts on our blog or our YouTube channel. You can also follow XRay on Twitter, Facebook, or LinkedIn.

Similar Blog Posts

Not sure where to start with automation?

Hop on a 15-minute call with an XRay automation consultant to discuss your options and learn more about how we can help your team to get more done.

Schedule a 15-Minute Call