π± Post text and images to X using a simple form trigger
β‘ 192 views Β· π± Social Media & Email Marketing
π‘ Pro Tip β Twitterβs API is paid now, which makes simple data pulls expensive. ScraperNode is a community node that scrapes Twitter profiles and posts without needing API access.
Description
Quick overview
This workflow uses an n8n Form trigger and the X (Twitter) API to publish a text-only post or a post with a single uploaded image, then returns a success/error payload including the resulting tweet URL.
How it works
- Receives a form submission with required post text and an optional image upload.
- Validates and normalizes the input, enforcing supported image types (JPG/PNG/WEBP/GIF) and size limits.
- If no image is provided, creates a post on X via the X API v2
POST /2/tweetsendpoint. - If an image is provided, uploads the media to X via
POST /2/media/upload, extracts the returned media ID, and creates the post with that media attached viaPOST /2/tweets. - Returns a success response with the tweet ID and tweet URL, or a structured error message when X returns an API error.
Setup
- Create an X OAuth2 API credential with user-context scopes
tweet.read tweet.write users.read offline.access media.writeand apply it to all X HTTP requests in the workflow. - Copy the public URL of the n8n form path
x-content-scheduler-freeand use it to open the βPost to Xβ form for publishing. - (Optional) Run the manual connection test that calls
GET /2/users/meto confirm the credential is connected to the correct X account.
Requirements
- x.com api app oauth2 credentials (pay as you go)
π Nodes Used
HTTP Request, n8n Form Trigger
π₯ Import
Download workflow.json and import into n8n:
Workflow menu β Import from File