n8n Workflow Automation : A Step-by-Step Tutorial for Report Generation & Scheduling

Ose Verma
Intelliconnect Engineering
7 min readNov 16, 2023

--

n8n flow

What is n8n?

n8n is an open-source, workflow automation tool that simplifies and streamlines tasks by connecting various applications and services.

n8n offers a visual interface where users can create automated workflows called “n8n workflows” using a wide range of pre-built nodes representing popular services like Outlook, teams, and more.

Users can design workflows that trigger actions and data transfers between these services, making it
a. an invaluable tool for automating repetitive tasks,
b. improving productivity, and
c. integrating software tools.

n8n is highly customizable, making it suitable for both individuals and businesses seeking to enhance their efficiency through automation.

Basic terms/info for n8n

Nodes: The actions and triggers are called nodes.

For all inputs (mostly), the inputs are of two types:

Fixed: it is a static value
Expression: here we can add dynamic values from the previous nodes

You can run individual nodes to test the flow, unlike power automate, we don’t need to run the complete flow at once to test.

You can see the inputs for the node on the left side and outputs on the right side.

Now let’s build a flow where we have a scheduling trigger.
This flow calls an API for fabric reports and we need to filter out the data of pending_fabrics being 0 and 1, for that, we use the switch node and send the mail and teams message based on that.

Step 1: Schedule trigger

schedule trigger

The scheduling trigger is to run the flow every day at 4 pm for 0 minutes. You can use custom(cron) to define the time too. Cron Custom Time

Step 2: HTTP Request

In HTTP request, we are doing the POST method for the URL, we can send the body as Json.

As you press on “Execute node”, you get the output as JSON on the right-hand side. You can change the format to schema, table, and JSON.

Step 3: Switch node

Now, we have the data for the report we need to filter the data according to the column called pending_fabrics. Here, the mode is Rules, as we’re checking numbers then, Data Type is number. In the value which we will compare, the expression is from the previous node. When you click on the column you get it in the expression.

Rules for switch: when it is equal to 1 and when the value is equal to 0.

When you click on Execute node, you get the outputs labeled as 1,2,3, etc. We only have two useful outputs.

Step 4: Running JavaScript to Add Serial Number

Here, the loop runs for the previous JSON and adds the field as a count variable. When we execute it, you can see on the right-hand side the serial number is added.

Step 5: Items List Action: Collect the Data and Name the Columns

The action is Item Lists, and the operation is Split Out Items. I selected the columns which we need to put on the report and in the options, we give the Destination Field Name for all the columns.

Step 6: Convert to HTML table

The action is HTML and the operation is Convert to HTML Table. I have added a few attributes for the table, header, and cell. This node takes the JSON from the previous node and adds it to an HTML table.

For table:

style = “font-family:Arial, Helvetica, sans-serif;border-collapse: collapse;width: 100%;”

For header,

style = “font-size:15px;font-weight:bold;height:30px;padding:12px 12px;background-color:#1C6EA4;color:white”

For cells,

style = “border:1px solid #ddd; padding:3px 3px”

Step 7: Microsoft Teams Create a Chat Message

Link to create the connection for teams After connection, we can choose the resource and operation. Here the resource is Chat Message and the operation is Create. From the Chat Name, select the person you want to send the message to. Here, the message type is HTML. And we can add the HTML table that we created earlier from the expression with a click!

Step 8: Send an Outlook Email

The action is Microsoft Outlook, and the operation is to send a message. You can connect the credentials the same way as for teams with a new app registration in Azure. We add the recipients, the subject, and the message same as in teams.

After execution, you will get an email with the report and the team’s message.

Why our Teams like n8n?

n8n is wonderful to work on, as
1. it has great documentation. For every node, you can see a doc tab which will take you to the documentation for the respective tab.

2. An active forum where members usually reply within an hour. The visual tool is a charm to work with.

3. The Visual Tool unlike the others we worked in is very intuitive.

4. Adding code snippets in both Javascript and Python gives the tool a boost.

5. The self-hosted option gives our customer relief from IT security and privacy concerns.

Certainly! n8n, like any other tool, comes with its own set of advantages and disadvantages. Here’s an overview:

Advantages of n8n:

1. Open Source: n8n is an open-source platform, that allows users to access, modify, and contribute to the source code. This fosters a collaborative community and ensures transparency.

2. User-Friendly Interface: n8n provides a visual workflow editor that is user-friendly and doesn’t require extensive coding knowledge. This makes it accessible to a broader audience, including those without strong programming skills.

3. Wide Range of Integrations: n8n supports a variety of integrations with popular applications and services, enabling users to create comprehensive workflows that span multiple platforms.

4. Flexibility and Customization: Users can customize workflows to meet their specific needs. n8n allows for the creation of complex workflows with conditional logic, loops, and other advanced features.

5. Active Community: n8n has an active and growing community. Users can seek help, share their workflows, and contribute to the development of the platform.

6. Cross-Platform Compatibility: n8n can be run on different platforms, including self-hosted environments, cloud services, and Docker containers.

7. Secure as you can self-host n8n: It can be self-hosted. The data is secured then. However, users should ensure proper authentication and access controls are in place to protect sensitive data used in workflows.

8. Speed and Performance of n8n: For normal hardware with 4GB RAM using the Postgres database, the flow can take 200 requests in under 100 seconds.

This graph shows the percentage of requests to the webhook trigger node getting a response within 100 seconds (about 1 and a half minutes), and how that varies with load. Under higher loads, n8n usually still processes the data but takes over 100s to respond.

Here are some Drawbacks :

1. Learning Curve for Complex Workflows: While the visual editor makes it easy to create simple workflows, more complex scenarios may require a learning curve, especially for users not familiar with workflow automation concepts.

2. Resource Intensive: Running n8n workflows may require a significant number of resources, especially for larger and more complex workflows. Users should consider the resource requirements when deploying n8n.

3. Limited Enterprise Features: n8n might not offer the same level of enterprise features and support as some commercial alternatives. This could be a consideration for large organizations with specific requirements.

4. Dependency on Third-Party Services: The success of n8n workflows depends on the stability and availability of third-party services and APIs. If a service undergoes changes or experiences downtime, it could impact the reliability of workflows.

Conclusion

n8n is a powerful and flexible automation tool with a range of advantages, especially for users looking for an open-source and customizable solution. However, users should carefully evaluate their specific use cases and requirements before choosing n8n or any other automation platform.

About Intelliconnect

We at Intelliconnect work with leaders who have ambitious plans to grow their businesses. Our custom solutions

1. Enable autonomous decision-making, reducing and ultimately eliminating the need for human intervention.

2. Provide signals & insights that enable swift action.

3. Empower teams with real-time information for strategic and operational decision-making, driving the development of a data-driven culture.

4. Are personalized for the role and easy & seamless to use ie efforts by the user are zero or minimum

Connect with us at solutions[at]intelliconnectq.com

--

--