Stagger tweets posted from RSS feed

Hi n8n,

I am using a workflow that takes data from an RSS feed and bulk posts to Twitter twice a week.

The RSS feed has between 3 - 15 items each time.

Is there a way to stagger the tweets so they post one item every hour or so?

The code I am using is below, I have a Cron, RSS Feed Read, Function and Twitter node.

I am using the n8n desktop version

Thanks in advance,

Hi @Glean, the asynchronous scenario you describe would be possible, but a bit more complex than your current workflow.

Assuming the n8n desktop app isn’t running all the time for you (unless you run it on a machine that’s always on), you might want to store your Tweets outside of n8n, for example a Google Sheet or database. You would need to have an indicator of whether a tweet has already been posted.

You could then build two separate workflows: One to check the RSS feed and store the results in the aforementioned Google Sheet. You could utilize a polling technique to avoid duplicates, similar to what is described in this blog post (but of course adjusted to your RSS source). This can run as often as needed.

The other workflow could then run once per hour, read your Google Sheet and filter for the Tweets that have not been posted yet. Keep only the first such item and post on Twitter, lastly update the row in the Google Sheet to indicate the tweet has been posted.

I hope this makes sense! Let me know if you struggle with any of the above or would like to approach this in any other way.

As long as you keep n8n open on your desktop you can use split in batches and a wait node. In this case you might want to set your cron 1 hour earlier because it will wait 1hr before the first tweet.

1 Like

Thank you for your answer Muted Jam.

Pemontto I like the simplicity of your workflow but when I execute it, the first item of four items in the current RSS feed is published to Twitter four times rather than cycling through the items and publishing each item once.

Any suggestions on how to fix this?

Can’t seem to reproduce, I see the twitter node outputting 4 distinct articles from the RSS node. Can you post your workflow?

I’ve simplified by using a function item node and referencing only the $json in the twitter node. (note wait time is set to 1 second). This avoid referencing nodes before the split. You may also try moving the loop back to splitinBatches from the Wait node to the Twitter node…

Thank you Pemontto!

That new workflow staggers all four tweets nicely when I do it manually.

Now all I have to do is see if it works with the cron node.

Will I need a start node connected for the workflow to execute?

No, the start node can remain disconnected. The cron node will start/generate events when the workflow is active