Back to blogs

Exploring n8n: A Step-by-Step Guide with example of Reddit Automation

Cover image for Exploring n8n: A Step-by-Step Guide with example of Reddit Automation
Introduction:
N8n (pronounced n-eight-n) is a fair-code licensed workflow automation tool that combines AI capabilities with business process automation. It offers a flexible and intuitive interface for building automations without the need for extensive coding knowledge. We will be doing a walkthrough of n8n interface and creating an automation workflow.

Goals:
  • Login to Reddit account
  • Search for posts related to ‘AI Agent’ key word
  • Save the results in a csv file
  • Add comments in these retrieved posts
Housekeeping:
In today’s example, we will be doing a local installation of n8n which has a pre-requisite of nodejs, so lets begin with the below steps. Alternatively, refer to the docs from n8n here
 
Install nodejs: https://nodejs.org/ 
Install n8n: In your terminal or command prompt in Apple or Windows system, run the command, npx n8n,

reference image for blog
1.png 18.1 KB

Once the installation is complete, at the end you will get a local host URL, open it in the browser,

reference image for blog
2.png 20.5 KB


Run this above URL in your browser and it will lead to following page, where you can set up your account,

reference image for blog
3.png 31.8 KB
Next,

reference image for blog
4.png 59 KB


Fill in the required details,

reference image for blog
5.png 27.4 KB


Next popup will come, get paid features sent to your email for a free license key,

reference image for blog
6.png 63.8 KB


n8n interface:

Lets start with understanding the concepts:
  • Nodes: Nodes are the building blocks of a workflow. There are two types of node operations,
  1. Trigger Nodes: Triggers start a workflow in response to specific events or conditions in your services. In short, they tell n8n when and how to start the workflow.
  2. Action Nodes: They perform specific tasks. Examples include manipulating data, calling an API, etc. 
  • Building workflow: Let’s create a workflow to search for posts related to ‘AI Agents’ on Reddit, store the links in a google sheet, then add comments in those posts.
Lets start from scratch, 

reference image for blog
7.png 58.7 KB


Add the first step,

reference image for blog
8.png 189 KB


As a first step, lets select Trigger Manually, by selecting the first option from right side bar,

reference image for blog
9.png 17.4 KB


By clicking on the plus button, lets select the ‘Action in an app’ in the right side bar options,


reference image for blog
10.png 70.7 KB


Search for Reddit and select it, the result will be multiple common actions of Reddit as below, then select, ‘Search for a post’,

reference image for blog
11.png 43 KB

We will now do the setup of parameters,

reference image for blog
12.png 93.7 KB

In the first drop down option, select Create a new credential. This is to establish reddit connection, so we can login and retrieve results.

reference image for blog
13.jpg 28.5 KB

Setup reddit connection, by following the steps from docs

reference image for blog
14.png 44.7 KB


Click on connect my account and a popup will appear, then, give access to your reddit account. Once the connection is established, go to the main canvas, test your workflow as,


reference image for blog
15.png 23.4 KB


Click on the Reddit node, to view the result of 10 reddit posts (as we setup 10 limit) that matches ‘AI Agents’ keyword, the result can be viewed in json as,

reference image for blog
16.png 168 KB
If you want to view these results in a csv file, we can do Data Transformation operation,

reference image for blog
17.png 78.6 KB


Select the option, Convert JSON data to file, and then convert to CSV,

reference image for blog
18.png 37.2 KB

Test this node and we then can get output file in csv which can be downloaded from OUTPUT as, 

reference image for blog
19.png 22 KB

reference image for blog
20.png 176 KB


Now, for a simpler demonstration of adding comments to the reddit posts retrieved before, I will discard the 'Convert to File' node. 
Create a node by following the same steps previously explained for adding Reddit node. 
Next, Drag and drop the ‘’id’’ field from INPUT to the Post ID field (red box in below image), and specify the comment text to post in the reddit.

reference image for blog
21.png 190 KB


reference image for blog
22.png 23.1 KB

After executing Node Reddit1, you can see the output, and also check your reddit profile to view the comments that are posted,


reference image for blog
23.png 249 KB

reference image for blog
24.png 39.9 KB
Resources: