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,
Once the installation is complete, at the end you will get a local host URL, open it in the browser,
Run this above URL in your browser and it will lead to following page, where you can set up your account,
Next,
Fill in the required details,
Next popup will come, get paid features sent to your email for a free license key,
Fill in the required details,
Next popup will come, get paid features sent to your email for a free license key,
n8n interface:
Lets start with understanding the concepts:
- Nodes: Nodes are the building blocks of a workflow. There are two types of node operations,
- 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.
- 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,
Add the first step,
As a first step, lets select Trigger Manually, by selecting the first option from right side bar,
By clicking on the plus button, lets select the ‘Action in an app’ in the right side bar options,
Search for Reddit and select it, the result will be multiple common actions of Reddit as below, then select, ‘Search for a post’,
We will now do the setup of parameters,
In the first drop down option, select Create a new credential. This is to establish reddit connection, so we can login and retrieve results.
Setup reddit connection, by following the steps from docs
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,
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,
If you want to view these results in a csv file, we can do Data Transformation operation,
Select the option, Convert JSON data to file, and then convert to CSV,
Test this node and we then can get output file in csv which can be downloaded from OUTPUT as,
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.
After executing Node Reddit1, you can see the output, and also check your reddit profile to view the comments that are posted,
Resources:
Related blog: How to evaluate the best AI tool for your business?