Storing and loading content from filesystem

Hello, i want to scrape a knowledge base and send myself new posts. For this I plan to store the article IDs somwhere in n8n and then filter them out in subsecuent executions.

Can this be done?

Welcome to the community @luisito345!

There are multiple ways to store data. If it is just very little data like a few values you can store it directly in the workflow with static data:

Apart from that can you anytime save data in a file:
https://n8n.io/integrations/n8n-nodes-base.readBinaryFile

Or in a database like Redis, Mongo, Postgres or MySQL:
https://n8n.io/integrations/n8n-nodes-base.redis

1 Like

You might want to have a look here. It’s a workflow that tracks sitemap changes.

How to get new RSS item? - #3 by jan

Until there is no better support for tracking node data changes it’s going to be ugly - but doable.

1 Like

Thanks all for the information, I’m having a hard time making this work, can some one point where the problems are??

In a previous function I generate a lot of items, they haven an ID, so my idea is to get the previous latest id and send all items with a bigger number, then saving the new id in node data. Or that is what i want to believe it does.

Function Code
let SITEURL = 'https://site.com';
let HTMLHEADER = '<html>'; //'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
//<html xmlns="https://www.w3.org/1999/xhtml">
//<body>';
let HTMLFOOTER = '</body></html>';
let emailText = `${HTMLHEADER}` + 'KB de Site: \n\n<ul>';

let idMasGrande = 0;
let newidMasGrande = 0;
const staticNodeData = getWorkflowStaticData('node');
const oldidMasGrande = staticNodeData.idMasGrande;
const newItems = [];

for (let item of items) {
  if (item.json.articuloID >= idMasGrande) {
      newidMasGrande = item.json.articuloID;
      item.json.estado = "pasaFiltro";
      newItems.push({ json: item });
  }
  // filtrarlo
  if (item.json.articuloID > oldidMasGrande) {
      //newidMasGrande = item.json.articuloID;
      //item.json.estado = "pasaFiltro";
      //newItems.push({ json: item });
  }
  // fin filtrarlo

}
staticNodeData.idMasGrande = newidMasGrande;
// fim seteo el id

emailText += `\n\n results:`;
for (let item of newItems) {
  emailText += `<li>${item.json.estado} * ${item.json.articuloTitulo}
   ${item.json.airticuloDate} - ${SITEURL}${item.json.articuloHref}\n
   ${item.json.articuloCuerpo}\n</li>`;
}
emailText += `<ul> ${HTMLFOOTER}`;

return [{json: {emailText}}]

Also, i love to use ‘console.log’ is there any way for me to just log/debug messages ?

thanks

Hey @luisito345, where are you having the issue exactly?

Yes, you can use console.log() in the function node, just add it and you will see the data in the terminal you ran n8n.

1 Like

Hello Jan,
You are doing an amazing job with N8N !!
I would like to know, for self hosted n8n (like on heroku, nocode deployment method) how to store data/files (it´s for decoding a base64 to mp3 format) so I can get the url link.mp3 of the generated file (its ok if its temporary like 24h) so I can use the link in json response or/and send the file to external storage service.