Twitter Filtered Stream Endpoint to N8N Webhook

Twitter provides a streaming endpoint that also you “listen” for and get real time tweets related to a specific search criteria. This is especially useful if you run one of those video downloader bots like @this_vid. When someone wants to download a video from a specific tweet and when @this_vid is mentioned, their service is instantly notified a triggers a download because the this_vid is constantly listening for their tag.

You can get an overview here. Building an app to stream Tweets in real-time | Docs | Twitter Developer Platform

My question is has anyone used the filtered stream endpoint with an N8N webhook? Every tutorial I’ve seen and even the Twitter tutorial suggests I setup a node.js app to create the persistent connection with the streaming endpoint. Any way to do this with N8N?

It looks like the endpoint used is a GET endpoint, so the Webhook node wouldn’t be of much use here and you would instead need to actively fetch data from Twitter.

It does however seem the endpoint returns a continuous stream of data instead of a single response. Trying to consume this would require a custom implementation, making sure n8n doesn’t run out of memory once the response has grown too big and implementing backfill and deduplication logic upon connection loss.

This is a lot of work and I am not aware of an existing implementation unfortunately. So perhaps you want to raise a feature request for a Twitter Trigger?

As a simplified alternative until then, you might want to consider a “near real-time” implementation instead and just poll Twitter in short intervals (for example by checking every 60 seconds if a Tweet matching your search criteria has been posted in the last 60 seconds).

1 Like