3 Datacleaning n8n with HAILogo
Krithi walks through cleaning messy API data and adding retry logic in n8n, turning a fragile demo workflow into one that can survive real-world failures.
A workflow that only works when the API behaves perfectly is not a workflow you can rely on. This installment of the Madison framework tutorial series, presented by Krithi, treats data cleaning and error handling as the point where a fragile automation becomes a robust one, and walks through exactly how to build that robustness in n8n.
The case for clean data
The video opens by naming the problem directly: an AI agent is only as good as the data it learns from, and real API responses routinely arrive with missing fields, null values, inconsistent formatting, or duplicate and irrelevant entries. Since demonstrating an improved success rate is often a required part of a project, cleaning the data feeding into a workflow is treated as the first lever worth pulling, not a nice-to-have.
Cleaning API data with a Code node
The demonstration extends a previous workflow built around an API call, adding a few more variables and parameters to the same request so there is actually messy data to clean. After the HTTP Request node, a Code node running JavaScript strips out null values and can standardize the response, including adding timestamps where needed. Executing the workflow shows the cleaned output coming through successfully, which confirms the code is doing its job before moving on to error handling.
Retry loops with the If node
n8n offers a few ways to make a workflow more resilient: an If node that behaves like a try/catch block, Error Trigger nodes that fire when something fails, and retry logic for handling temporary outages. The video builds the retry pattern step by step. After the HTTP Request node, an If node checks whether a specific ID field came back in the response. A present ID routes the flow into data processing as usual. A missing ID routes instead to a second HTTP Request node, configured with the same settings as the first, which connects back into the If node to form a loop. That loop lets the workflow retry automatically when a call fails temporarily, instead of stopping outright.
Proving the improvement with a testing plan
Building the retry logic is only half the job; the video insists on documenting whether it actually helped. That means creating a simple test plan across five to ten different inputs, running the workflow against each, documenting the results, and calculating a success percentage each time. The point is not to run the test once and stop, but to keep testing the API and response data as changes are made, documenting the improvement between each version rather than only reporting a single end result. The example given is concrete: a workflow that originally succeeded around 70% of the time can climb to 85–90% reliability once cleaning and error handling are in place, and that improvement is exactly the kind of metric a Madison framework contribution needs to show.
Why this step matters before scaling up
Cleaning and error handling are positioned as groundwork rather than a final polish step. A workflow that silently breaks on a null field or a single failed API call will not survive being pushed to handle larger volumes of data, so this stage of the series is what makes the next one possible. Once a workflow can reliably clean its inputs and recover from a temporary failure on its own, it is in a position to be scaled up to handle real production-level data loads without falling over on the first bad response it encounters.
Key takeaways
- Real API data commonly arrives with null values, missing fields, duplicates, or inconsistent formatting that needs to be cleaned before use.
- A JavaScript Code node placed after the HTTP Request node can strip nulls and standardize the response format.
- Retry logic is built by connecting an If node's failure branch to a second, identically configured HTTP Request node that loops back to the same If node.
- n8n also supports Error Trigger nodes for handling failures outside the main retry loop.
- Testing across five to ten inputs and calculating a success rate turns an assumed improvement into a documented one.
Who this is for
This tutorial is built for Humanitarians AI Fellows and other Madison framework contributors working in n8n who need their workflows to hold up under real-world conditions and to show measurable reliability gains as part of their project work. The series continues next with scaling and production testing.
Full transcript(auto-generated, with timestamps)
[0:01]Welcome back to Madison framework tutorial series. I'm Kiti and today we are focusing on making data pipeline more robust. Once you have collected data from APIs, next step is you need to clean it and handle all the potential errors and it is a crucial skill. But before we dive into the techniques, let's talk about why clean data matters for your project. Your AI agent is only as good as the data it learns from. And common data issues include missing fields or null values. Inconsistent formatting, duplicate entries, or irrelevant information. Clean data improves your agents reliability and it must be a key focus where you need to demonstrate
[0:44]Improvement in your workflows success rate. Now let's look at how to clean your API data using nodes. And let me just give a quick demonstration of this. And for that, I'm going to be building on top of my previous demo. So after this HTTP request node, I'm going to be adding a function node. But before that, uh here I had the API to get the you know, OpenAI details basically. So yeah, this was the JSON data that I was getting basically. So I'm going to add a few more variables and parameters to the same API. If you see um it's the same but I have just
[1:23]Added few more fields just to explain the concept of this demo. Yeah. So now this will be helpful for you know showing the cleaning of the data. Basically that's it. And let me proceed with adding a code which is uh I'm choosing JavaScript and basically this is uh the code that I'll be using to clean the data from my API and this will remove all the null values and if I want to add some time stamps or standardize all the response then this code will perform all those functions. Yep, that's it. And let me just execute. Yes, this workflow is successfully executed. As you can see the data is cleaned.
[2:09]Now let's make our workflow more reliable by handling errors. And this is a very crucial step where you need to improve your workflow success rate. And there are several approaches in NAN. There is a if node that will handle this try catch pattern and there are error trigger nodes that activates some when something is failing and there's also a retry logic that you can handle temporary failures. Now let's implement a basic retry system back to our demo. And after this HTTP request, I'm going to be adding a if node. So I'm checking whether my ID field is present. So if yes then it is proceeding to you
[2:59]Know data processing first cleaning and then uh processing. But if no I'm going to be adding another HTTP request node. Basically the same thing I'm calling the same API and uh requesting the same data. And don't forget these steps I explained in my previous video. Yes. Now this request node, HTTP request node has the same settings and I'm going to be connecting this back to the if node and that will create a retry loop. Now this will give your workflow resilience against any temporary failures. Next step is you need to document your success rate improvements. And here's how to test your workflow. Start by creating a simple testing plan with five
[3:52]To 10 different inputs. Run your workflow with each input and document results and calculate your success percentage. Keep on making improvements and testing the API or response data again and again. And don't forget to document the improvement between each versions. For example, you might find your original workflow succeed 70%age of the time, but with error handling and data cleaning, it improves to 85 to 90%age of the reliability. By now you have the skills to clean the data and handle errors in any 10 workflows. These improvements are essential for your project where you need to demonstrate incre increased reliability in Madison framework contribution. In our next video, we'll
[4:34]Explore scaling your workflow and preparing it for production use. Remember your goal is to transform your workflow from a basic MVP to something robust enough for real world deployment. Up next is scaling and testing your NAN workflow. Thank you so much for watching this video. I hope this was helpful.
More from INFO7375 Branding & AI
4:581 - Getting Started n8n
14:52Automate Everything with n8n! No Code & Low Code Workflow Automation | Humanitarians AI
6:124 - Scaling & Testing Your n8n Workflow
4:513 - Datacleaning n8n
9:45Automating LinkedIn AI Posts in 5 Minutes with n8n
10:00