This workflow automates the creation of WordPress draft posts from Google Docs or TXT files.
It uses Gemini AI to generate structured article JSON (title, excerpt, content, hero prompt, etc.), converts it to HTML, and posts it directly to WordPress via the REST API.
- The workflow is built and tested locally in n8n, currently triggered manually.
- Input: hardcoded Google Docs export URL (TXT format), fetched and normalized into plain text.
- Gemini AI (API Key): chosen for formatting due to free and stable access for testing.
- Credentials: all keys (Gemini API, WordPress endpoint) are stored securely in the n8n Credential Manager — nothing is hardcoded in nodes.
- Output: HTML content formatted by Gemini, verified via Webhook.site, and ready for WordPress import.
- Input — Title & Doc URL
Manual input of a document link and optional title. - Fetch Doc (TXT)
Retrieves the document text from the provided link. - Normalize — raw_text
Cleans and prepares the text for AI formatting. - AI Formatting (Gemini-2.5-pro)
Generates structured JSON with title, excerpt, content HTML, and metadata. - Extract & Clean Gemini JSON
Parses the AI output into usable fields. - Prepare Preview File
Builds filename and clean HTML content. - Convert to File
Converts HTML content into a.htmlpreview file. - HTTP Request — WordPress
Sends the article data (title, content, excerpt, status=draft) to the WordPress REST API.
Figure 1 — n8n workflow from input to WordPress post creation.
- Endpoint:
https://your-site.com/wp-json/wp/v2/posts - Auth: Basic Auth with a WordPress Application Password.
- Status: Posts are created as drafts by default.
- Open n8n editor.
- Import
wordpress-auto-posting.json. - Set up Gemini and WordPress credentials.
- Run the workflow manually.
- Post title:
Common Insurance Claims in HR Consulting - Status:
draft - WordPress response:
201 Created - HTML preview:
common-insurance-claims-in-hr-consulting.html
- Add automated Google Drive trigger (folder watcher) to replace manual start.
- Experiment with Gemini prompt tuning to achieve more refined HTML styling and layout (headings, subheadings, images).
- Improve AI node processing time to make content generation faster and more efficient during each execution (now around 10s).
- Add duplicate prevention logic to avoid re-posting identical drafts.
- Implement dynamic category and tag mapping using extracted keywords or Gemini metadata.
- Google Drive API Authentication could not be completed in n8n due to credential approval issues.
- WordPress API connection was not tested end-to-end yet, pending valid access credentials.
