Twitter Thread Extractor and Merger - n8n Workflow

Use this advanced n8n workflow to reliably extract, filter, and merge all tweets belonging to a single Twitter (X) thread using external API calls. Find more n8n templates here.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content marketers and writers who repurpose Twitter threads into blog posts or newsletters.
Researchers requiring structured, clean data from social media threads.
Developers looking for advanced examples of HTTP Request and data processing logic within an n8n workflow.
Users seeking high-value n8n templates for social media automation.

Overview

The modern challenge of managing and repurposing long-form content often starts with extracting data from platforms like Twitter (X). Manually compiling a tweet thread is tedious and error-prone. This specialized n8n workflow solves this by reliably fetching all component tweets of a thread, filtering out unrelated replies, and merging them into a single, coherent data item. By leveraging external APIs through an n8n node setup, this automation ensures clean, high-quality data output ready for subsequent actions (like AI summarization or database storage). This robust n8n template is essential for anyone integrating social media data extraction into their overall automation strategy.

How it Works

The entire process begins with an n8n trigger, which can be a manual test or an execution from another workflow, typically receiving a URL for the initial tweet. The initial data is routed to the 'Extract Tweet ID and Username' Function n8n node, which parses the input to isolate the Tweet ID necessary for API interaction. The 'Get first tweet' HTTP Request n8n node then fetches the root tweet data. Following this, the 'Extract Conversation and Author ID' Function n8n node pulls critical thread identifiers. This information is merged and used by the 'Get Tweet Replies' HTTP Request n8n node to query the API for all related conversation items. Crucially, the 'Fetch tweets which are connected to first tweet' Code n8n node applies specific logic to filter the returned items, ensuring only tweets belonging to the original thread (posted by the original author) are retained. Finally, the 'Merge first tweet and others' n8n node consolidates the initial tweet with the filtered thread components, delivering the complete thread structure. This systematic approach showcases the power of a well-designed n8n workflow.

Installation Guide


  1. Import: Copy the provided JSON and import it directly into your n8n instance via the 'Workflows' section using the 'Import from JSON' option.

  2. Credentials: This n8n workflow uses the HTTP Request n8n node to interface with a Twitter data API (such as TwitterAPI.io, RapidAPI, or similar). You must configure the API Key or Bearer Token required by your chosen service and set up the corresponding credentials within the n8n node parameters for both the 'Get first tweet' and 'Get Tweet Replies' nodes.

  3. Testing: Execute the workflow using the 'When clicking ‘Test workflow’' n8n trigger and provide a sample tweet URL in the input pin data to verify extraction and merging are successful. Save the active n8n workflow.

Node Details

When clicking ‘Test workflow’ / When Executed by Another Workflow (n8n trigger): Serves as the initiation point for this n8n workflow. It is configured to accept the tweet URL or ID as input.
Extract Tweet ID and Username (Function n8n node): Essential for transforming the input URL into usable Tweet ID and user handle variables needed for API calls.
Get first tweet (HTTP Request n8n node): Fetches the foundational data of the thread starter tweet. Requires configuration of the API endpoint and authorization headers/keys.
Extract Conversation and Author ID (Function n8n node): Processes the API response from the first tweet to retrieve the conversation ID and author ID, which are necessary parameters to fetch the full thread.
Get Tweet Replies (HTTP Request n8n node): Queries the external API to retrieve all tweets associated with the identified Conversation ID. The error handling is set to continueRegularOutput to prevent flow stoppage if the query is unsuccessful.
Fetch tweets which are connected to first tweet (Code n8n node): This critical custom n8n node uses JavaScript to iterate through the retrieved list and filter out external replies, keeping only the thread tweets posted by the initial author.


  • Merge first tweet and others (Merge n8n node): Combines the data from the single, starting tweet with the subsequent, filtered thread tweets, completing the data consolidation for this n8n workflow.

Related n8n Workflows

Paid

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

Software developer with hands-on experience across a wide range of automation domains, including autonomous vehicles, bots, AI-driven automations, and intelligent agents. Passionate about building solutions that leverage cutting-edge technology to solve real-world problems and streamline complex processes. Always eager to explore new challenges and contribute to innovative projects in the automation and AI space.

Featured*