"Has Anything Changed" Node?


I think a useful node to have would be one which takes as input information from the current workflow run and compares it to a previous workflow run. Basically an easy way to tell “did something change?”

I think n8n would be great to use to get alerts from things online that don’t support alerts on their own, but it turns out knowing whether anything has changed is a big part of that. Even something ‘straightforward’ like sending an alert when an RSS feed includes a given search term would end up triggering endlessly so long as the term remains in the feed.

I understand that there are ways to do it in Javascript, but this seems like something that would come up often enough that built-in support might be useful.

I imagine it looking and working similar to the “IF” node’s “string” condition. Perhaps one could even select whether it would compare to “Last run”, “Any time in last x runs” or “any time in last x days”.

Hope that this makes sense and is in the appropriate forum.

It’s almost like you can read my pm’s :expressionless: scary
But yeah i think this is a great and needed idea

@Binks really like the idea behind this. For your usecases, do you envision that the output for each item is a BOOL (i.e. did change or didn’t change) or is actually formatting the data that did change (i.e. like in a DIFF comparison of two text documents).

@maxT I think for my usecase the output would be a BOOL. I envision the node being used near the end of a workflow to stop getting repeated alerts when the source data hasn’t changed.

As perhaps the simplest example, Environment Canada makes XML files available that provide weather alerts for specific cities or regions:

A simple workflow would be to look at the entry’s title, and if it changes from “No alerts in effect, Iqaluit” to anything else, an alert could be sent.

I guess it gets more confusing if you were monitoring a feed with more than 1 item, and perhaps 2 new items were added between CRON runs. In that circumstance I would imagine the node comparing each item to all previous items, and passing along the new items. The net effect would be something like, “send me all the new news articles”.

Thanks @Binks! Sounds like the above scenario could be achieved with the IF node, where you’d be evaluating if title in XML file is equal to “No alerts in effect, Iqaluit” (would be a single string condition in the IF node).

I’m trying to think of scenarios where an IF node would not work for routing the WF data based on evaluating a conditional statement that has two outcomes (true or false). But at this time I can’t think of a case. Please do let me know if the IF node works for your scenario or if you have some cases where this method would not work.

If text diff output is something anyone would be interested in - please do comment on this thread and from there we could assess if it makes sense as a new mode for the Merge node.

Hi @maxT!

I don’t think I understand - the RSS node isn’t a trigger, so my understanding is that the workflow needs to be triggered by Cron every x minutes.

Every workflow run the RSS feed is pulled and evaluated by the IF, and so long as it remains true the notification fires.

So if you check the feeds for updates every minute, every minute you receive an alert with, “No alerts in effect, Iqaluit”.

How can the IF node suppress these superfluous triggers?

In my case i’m looking for a DIFF Comparison

Hi Binks,

To help visualize I mocked up a quick flow:

I’m using the NoOp nodes to show the different cases (i.e. one for true, one for false). In a real WF, you could keep the “Do nothing” No Op node and replace “continue + do something” with whatever you like (Send an email, post to slack etc).

In the IF node, it would look something like:

Now this is a simplification, but just wanted to check if something wasn’t clear in my original post as I am rather sure the IF node is the solution for your case. Let me know!

Hi @Damian_K,

So abstractly I see the utility in this node but a bit unsure as to the actual implementation. Off the bat, seems like of course the new text itself would be helpful but also maybe the anchor (i.e. where it came from in the file), or what it overwrote. If possible, most useful would be the exact JSON output you’d want to see when sending in two inputs (i.e. a before and after) - short of that though, details on how you’d want to use this data would be equally helpful.


Hi @maxT Thank you for diagramming it out. That’s exactly the workflow I’ve got; but IF doesn’t solve my problem.

The problem is that, every single time Cron runs, if the RSS feed’s content is “No alerts in effect” the “Continue + do something” node runs. So if you imagine the Cron is checking for updates every minute, every minute “Continue + do something” is triggered for as long as the “IF” evaluates true.

So every minute an email gets sent, or a message gets posted to slack, etc. That behavour is undesirable, and the problem I don’t think is solved with existing nodes.

The “Has Anything Changed” node I’m proposing could go in a few places, but to help visualize, it would sit between the RSS Feed Read and the IF node, and simply evaluate whether the string is the same as it was the last time that the workflow was run. That way the RSS feed gets checked every minute, but the IF node only gets run when the content of the RSS feed is updated.

The example on polling that I linked in my original post solves the problem with javascript; but I am proposing that javascript should be unnecessary for simple workflow like what we’re talking about.

The solution in that blog post is for new data, i’m more interested in changes in the data

I wonder if an expression value for a previous workflow job (like $lastRun.$node[...]['field']) could do the trick? Then you could use the IF statement to compare the current data vs the previous job.

1 Like