Form-Driven Content Publishing to X (Twitter) - n8n Workflow

Use this powerful n8n workflow to streamline posting content (text, image, video) to X (Twitter) using a simple web form. This n8n template handles complex media uploads automatically.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Social Media Managers needing a simplified interface for immediate posting.

  • Marketing Teams standardizing how content is delivered to X.

  • Users looking for ready-made n8n templates for external content submission.

  • Anyone who wants to leverage a dedicated n8n workflow for conditional media handling on X.

Overview

Managing content posting to social media often requires logging into dedicated platforms. This n8n workflow provides a cleaner, API-driven solution by generating a public submission form. This form acts as the initial n8n trigger, allowing users to submit both textual content and optional media files (images, videos). The key value of this n8n template lies in its ability to conditionally handle the submission: if media is attached, the n8n workflow executes a complex multi-step upload and post process; if no media is present, it posts the text directly. This ensures flexibility and reliability for anyone needing a robust content pipeline built on n8n.

How it Works

This automation starts with the 'On form submission' n8n trigger node.


  1. Form Submission: A user fills out the generated web form, providing the 'Post Content' and optionally uploading 'Media'.

  2. Data Extraction & Preparation: The 'Extract Media Details' n8n node (a Code node) analyzes the incoming data. It isolates the text content and checks for the presence, mime type, and binary data of the uploaded media file.

  3. Conditional Routing: The 'If Image Exists' n8n node checks if a mime_type was detected. This determines the flow of the n8n workflow.

  4. Path A (Media Included): If media exists, the flow proceeds to the 'Upload Media (X)' n8n node. This HTTP Request node handles the necessary OAuth1 upload sequence to X's media API. The resulting media ID is then passed to the final 'X' n8n node, which performs the actual post, attaching the uploaded media.

  5. Path B (Text Only): If no media is detected, the flow skips the upload steps and proceeds directly to the 'X1' n8n node, posting only the text content.

  6. Completion: Both successful paths merge into the 'End Form' n8n node, which provides a customized thank-you confirmation message to the submitting user.

Installation Guide

To deploy this powerful n8n template, follow these steps:


  1. Import: Copy the provided n8n workflow JSON code and import it into your n8n instance via the 'New' menu -> 'Import from JSON'.

  2. Credentials Setup: This n8n workflow requires two separate X (Twitter) credentials due to API constraints:

Twitter OAuth 1.0a API: Needed for the 'Upload Media (X)' n8n node. Set this up with appropriate read/write permissions for media uploads.
Twitter OAuth 2.0 API: Needed for the 'X' and 'X1' n8n nodes for posting tweets/posts.

  1. Activate Trigger: Ensure the 'On form submission' n8n trigger node is active. You can then access the live form URL provided by this n8n node to start submitting content.

  2. Testing: Run the n8n workflow once manually using the form URL to confirm the connections and conditional paths are functioning correctly.

Node Details

On form submission (n8n trigger): The starting point of this n8n workflow. It generates a public URL form configured to accept 'Post Content' (required textarea) and optional 'Media' uploads (supporting common image and video types).
Extract Media Details (Code n8n node): Essential for handling binary data. It safely extracts the text content and analyzes the uploaded file's metadata, classifying it as IMAGE, VIDEO, or AUDIO, and passing the binary data forward.
If Image Exists (If n8n node): This control flow n8n node directs the automation, checking if the mime_type property is present in the data item, ensuring the media upload steps are only executed when necessary.
Upload Media (X) (HTTP Request n8n node): A critical step for media posting. It uses the X Media Upload API (oauth.twitter.com/1.1/media/upload.json) with OAuth 1.0a credentials to upload the binary media file, preparing it for the final post.
X / X1 (Twitter n8n node): These nodes handle the final posting action. The 'X' node uses the media ID obtained from the upload step to attach the file, while the 'X1' node handles text-only posts. Both utilize OAuth 2.0 credentials for secure API access.
End Form (Form n8n node): This node concludes the n8n workflow for the user, displaying a confirmation message after the content has been successfully posted to X.

Related n8n Workflows

Free

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

I'm a full stack developer passionate about building intelligent, scalable solutions that automate workflows and enhance productivity. I love working at the intersection of AI, APIs, and automation—using tools like n8n to streamline processes, integrate data, and unlock smarter decision-making. Whether it's crafting custom backend services or designing intuitive frontends, I’m always exploring ways to build more with less manual effort.

Featured*