The JavaScript code node in n8n lets you process data with custom logic. This demo searches YouTube videos, fetches metrics like views and likes, then uses a ChatGPT-generated script to calculate engagement rates and write ranked results to Google Sheets.
Chapters
This is easily the most underrated node in NAN. It's the JavaScript code node, and I never hear anyone talking about it, which is crazy to me because it's so powerful. I have a system here from one of my last YouTube videos that can analyze YouTube videos, and then it can give you content generation suggestions. This part here at the beginning just searches YouTube videos in a certain niche, and after getting the initial videos here, we then do a custom HTTP request that basically just gives us the metrics that we actually want— things like views, likes, comments, things that determine if the video is actually good or not. But then this code node here is crazy. Basically what it is, it's just a long chunk of JavaScript that will go through all of this information by looking at all of the engagement and then looking at when it was published. It can calculate the views per minute and then also the engagement per minute, and then it can score both of those metrics. And then we get an output in Google Sheets like this. So we get a views per minute, an engagement score, and then an overall score for all these different creators and all these different YouTube videos. And ChatGPT generated all of the JavaScript for me. It's crazy.