When a new tweet is published, publish it on Wordpress

Hi. I’m trying to build a workflow that does what I indicated in the subject:

“When user X publishes a new tweet, publish a Wordpress post with the content of that tweet.”

I’m coming from Zapier, so n8n is a bit challenging for me.

So far, I understood that there’s no function that automatically triggers the workflow whenever a new tweet is published. So I assume that I need a Cron node (let’s say every minute), and then a Twitter node that executes a search (let’s say “from:X”).

I am struggling on what to do to check if the tweet/s is/are new or not, and how to publish it/them if new.

(assume that in between the searchers, user X could have published n tweets, and not just one).

Any help would be greatly appreciated. Thank you

Hi @RFB, welcome to the community!

You’re quite right, n8n doesn’t have a Twitter trigger node reacting to new Tweets which would make this simple.

So far, I understood that there’s no function that automatically triggers the workflow whenever a new tweet is published. So I assume that I need a Cron node (let’s say every minute), and then a Twitter node that executes a search (let’s say “from:X”).

I am struggling on what to do to check if the tweet/s is/are new or not, and how to publish it/them if new.

(assume that in between the searchers, user X could have published n tweets, and not just one).

Any help would be greatly appreciated. Thank you

So especially if you’re new to n8n I wouldn’t worry about de-duplication just yet (as it tends to add quite a bit of complexity). Running a workflow regularly and then searching for all tweets published in the last interval will be fine in most scenarios. A workflow could look like so:

This example uses expressions based on Luxon to work with times:

  • The Twitter node uses from:koelner_dom since:{{ $now.minus({hours: 1}).toFormat('yyyy-LL-dd') }}. The format uses the Twitter search operators from and since. The expression itself is $now.minus({hours: 1}).toFormat('yyyy-LL-dd') get’s the date from 1 hour ago and formats is as required by Twitter.
  • The IF node uses two expressions, the first one {{new Date($json["created_at"])}} simply reads the created_at field coming from Twitter and formats it as a date. The second one {{$now.minus({hours: 1}).toISO()}} gets the time one hour ago and formats it as an ISO string. n8n is then able to compare these two and keep only tweets newer than one hour (Twitter only allows filtering by day, that’s why these extra step is necessary when polling data more often).

Hope this helps!

On a related note, authentication with Twitter is quite cumbersome and we’ve seen a bunch of reports of Twitter no longer granting access to the legacy API used by n8n. So you might want to check first if your account is affected by this before investing a lot of time into building this workflow.

Thanks for such a detailed answer!

I’m trying the workflow but the Twitter node is returning:

:ERROR: The service is receiving too many requests from you! Perhaps take a break?

Rate limit exceeded"

Yet, I executed the node only once. Maybe this is a sign that twitter is not granting access to the legacy API?

1 Like

Do you by any chance have the “Return All” option enabled on the Twitter node? I suspect this can lead to more requests than allowed by Twitter, so it might be worth disabling this and starting with a small “Limit” value.

Yep, that was the problem. With a Limit value of 50, there’s no issue.

The workflow works just fine. Thanks again for your help.

1 Like

Glad to hear this works, thanks so much for confirming!