Automate WeChat Content Publishing with Google Gemini and AI Tools

Automate content generation and publishing to WeChat Official Accounts using Google Gemini and Doubao AI. This workflow simplifies the process of creating and scheduling posts, ensuring your audience receives fresh content without manual input. Features memory buffer for seamless content management, HTTP requests for API integration, and real-time wait conditions for optimal timing. Perfect for AI-driven marketers and social media managers looking to engage their audience without extra effort. Requires 0 accounts: just set up the workflow in n8n. Save up to 10 hours weekly by automating content delivery and increase audience engagement with consistent, relevant posts.

Form Trigger
72 views14 nodesJul 2025Emily Watson

APIs

Google Gemini

AI Features

AI AgentGoogle GeminiAI Chat

Quick Actions

Copy or download to import into your n8n instance

Workflow JSON
{
  "id": "zdj8QZIGdqHiE5V4",
  "meta": {
    "instanceId": "a21e13a97de5f9ad314c691bdf01d44ff26c3bc4a189d09f7a0785f2bdce7b81"
  },
  "name": "Generate and Publish Content to WeChat(Weixin) Official Accounts with Gemini and Doubao AI",
  "tags": [],
  "nodes": [
    {
      "id": "e85f6404-a916-48c2-9d9c-8d29d633281d",
      "name": "WeChat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "notes": "Langchain memory to maintain AI conversation context.",
      "position": [
        96,
        528
      ],
      "parameters": {
        "sessionKey": "WeChat",
        "sessionIdType": "customKey",
        "contextWindowLength": 100
      },
      "typeVersion": 1.3
    },
    {
      "id": "25f4905a-dcb0-4a6a-af08-bd37bc8936c2",
      "name": "Format AI Output",
      "type": "n8n-nodes-base.code",
      "notes": "Parses and formats the AI-generated JSON output, extracting required fields and cleaning data.",
      "position": [
        272,
        368
      ],
      "parameters": {
        "jsCode": "// Get the single data item passed from the previous node\nconst item = $input.item;\n\n// Get the value of the field named 'output' from the input item's json property\nconst rawString = item.json.output;\n\n// 1. Robustness check\nif (typeof rawString !== 'string' || rawString.trim() === '') {\n  return [{ json: { error: \"Input is not a valid string.\" } }];\n}\n\n// 2. Clean the string, find the start and end positions of the JSON content\nconst startIndex = rawString.indexOf('{');\nconst endIndex = rawString.lastIndexOf('}');\n\nif (startIndex === -1 || endIndex === -1) {\n  return [{ json: { error: \"No valid JSON object structure found in the input string.\", rawInput: rawString } }];\n}\n\nconst cleanJsonString = rawString.substring(startIndex, endIndex + 1);\n\n// 3. Parse, reorganize, and output\ntry {\n  const parsedData = JSON.parse(cleanJsonString);\n  \n  // Create a brand new, clean output object\n  const finalOutput = {};\n\n  // =====================【Core Optimization Logic】=====================\n\n  // 1. Handle title: From the AI-generated title array, select only the first one as the main title\n  if (Array.isArray(parsedData.title) && parsedData.title.length > 0) {\n    finalOutput.title = parsedData.title[0];\n  } else {\n    finalOutput.title = parsedData.title || \"No Title\";\n  }\n\n  // 2. Directly copy simple text fields\n  finalOutput.author = parsedData.author;\n  finalOutput.digest = parsedData.digest;\n  finalOutput.image_prompt = parsedData.image_prompt;\n  \n  // 3. Create a short content preview (content_preview) instead of displaying full HTML\n  if (typeof parsedData.content === 'string') {\n    // Remove all HTML tags and truncate to the first 50 characters as preview\n    finalOutput.content_preview = parsedData.content.replace(/<[^>]*>/g, '').substring(0, 50) + '...';\n  }\n\n  // 4. Also retain the complete, unmodified original content for future use\n  finalOutput.full_content_html = parsedData.content;\n  \n  // ========================================================\n\n  // Return this carefully reorganized, clearly structured JSON object\n  return [{\n    json: finalOutput\n  }];\n\n} catch (error) {\n  // If parsing fails, return clear error information\n  return [{\n    json: {\n      error: \"Failed to parse JSON string.\",\n      details: error.message,\n      string_that_failed: cleanJsonString\n    }\n  }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "73317701-d20c-4b07-b35d-a89907291319",
      "name": "Doubao Image Generation",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Invokes the Doubao AI model to generate article images based on AI-generated image prompts.",
      "position": [
        400,
        368
      ],
      "parameters": {
        "url": "https://ark.cn-beijing.volces.com/api/v3/images/generations",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "doubao-seedream-3-0-t2i-250415"
            },
            {
              "name": "prompt",
              "value": "={{ $json.image_prompt }}"
            },
            {
              "name": "response_format",
              "value": "url"
            },
            {
              "name": "size",
              "value": "900x423"
            },
            {
              "name": "n",
              "value": "1"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "044dd4f4-dcfc-4f70-80e6-30b6cb58f30a",
      "name": "Wait for Image Generation",
      "type": "n8n-nodes-base.wait",
      "notes": "Waits for image generation to complete to avoid immediate download request failures.",
      "position": [
        576,
        368
      ],
      "webhookId": "07bbadcc-b12f-4bd1-823c-2be6957f7f4a",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "972dda2f-dd39-4a46-bd7e-33e01fc906a6",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Downloads the image generated by Doubao AI.",
      "position": [
        704,
        368
      ],
      "parameters": {
        "url": "={{ $json.data[0].url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "68f8a375-ac91-482e-b635-abd0f883e2e8",
      "name": "Check Image Generation Status",
      "type": "n8n-nodes-base.if",
      "notes": "Checks if Doubao AI successfully generated the image.",
      "position": [
        832,
        368
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "81130ff2-a30b-4c95-9812-484abbc7cd71",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.usage.generated_images }}",
              "rightValue": 1
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2a295c1e-6681-4a6a-b205-e4e0a4cc95c3",
      "name": "Crop Image (Remove Watermark)",
      "type": "n8n-nodes-base.editImage",
      "notes": "Crops the image to remove potential watermarks and fit WeChat Official Account cover dimensions.",
      "position": [
        1008,
        368
      ],
      "parameters": {
        "width": 900,
        "height": 383,
        "options": {},
        "operation": "crop"
      },
      "typeVersion": 1
    },
    {
      "id": "d4f26007-726a-416d-a255-abf5cf446a70",
      "name": "Upload Cover Image",
      "type": "n8n-nodes-wechat-offiaccount.wechatOfficialAccountNode",
      "notes": "Uploads the processed image as a cover to the WeChat Official Account's material library.",
      "position": [
        1136,
        368
      ],
      "parameters": {
        "resource": "media",
        "operation": "media:uploadOther"
      },
      "typeVersion": 1
    },
    {
      "id": "43818d82-77d9-4312-9465-b2ab102d3d5d",
      "name": "Create Draft Article",
      "type": "n8n-nodes-wechat-offiaccount.wechatOfficialAccountNode",
      "notes": "Uploads the AI-generated article content and cover image to the WeChat Official Account's draft box.",
      "position": [
        1264,
        368
      ],
      "parameters": {
        "articles": "=[\n  {\n    \"title\": \"{{ $('Format AI Output').item.json.title }}\",\n    \"author\": \"{{ $('Article Topic Input Form').item.json['作者'] }}\",\n    \"digest\": \"{{ $('Format AI Output').item.json.digest }}\",\n    \"content\": \"{{ $('Format AI Output').item.json.full_content_html }}\",\n    \"thumb_media_id\": \"{{ $json.media_id }}\"\n  }\n] ",
        "resource": "draft",
        "operation": "draft:add"
      },
      "typeVersion": 1
    },
    {
      "id": "e322f25d-507d-4b69-8dbc-440eb2835333",
      "name": "Generate Article Draft (Gemini)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "notes": "Uses the Gemini model to generate article content and image prompts based on user input and a predefined prompt.",
      "position": [
        -32,
        368
      ],
      "parameters": {
        "text": "=Please create a draft WeChat Official Account article based on the following topic:\n{{ $json.chatInput }}",
        "options": {
          "systemMessage": "# Role & Core Objective\nYour role is that of a seasoned **Content Strategist and Top-tier Copywriter**. You possess the ability to simplify complexity, gain deep insights, and have extremely high standards for textual quality and visual aesthetics. Your sole task is to intelligently analyze the input materials provided by the user, and, revolving around the core theme, create all necessary elements for a high-quality, deeply original, **elegantly formatted**, and engaging WeChat Official Account article draft.\n\n# Input & Creation Logic\n1.  **Input Understanding**: Your input is a JSON object containing three fields: 'author', 'generate_article_with_one_sentence' (may be empty), 'generate_article_with_reference_article' (may be empty).\n2.  **Creation Priority Judgment (Mandatory Rule)**: You must follow the following priority to determine the core creation material:\n    * **First Priority: Process 'generate_article_with_one_sentence'**. If this field has content, it is the **absolute core theme** for this creation. You must conduct all research and writing around this theme.\n    * **Second Priority: Process 'generate_article_with_reference_article'**.\n        * **As a Supplement**: If the 'one_sentence' theme **exists**, you need to judge whether the 'reference_article' content is **highly relevant** to this theme. If relevant, you can extract arguments, data, or viewpoints from it to enrich your article. If not relevant, you must **completely ignore** the 'reference_article' content.\n        * **As Main Material**: If the 'one_sentence' theme **is empty**, but 'reference_article' **has content**, then the core idea of the 'reference_article' becomes the theme for this creation.\n3.  **Author Field**: Always use the value of the 'author' field from the input as the final output's author name.\n\n# Output Format & Layout Aesthetics\nYour final output **must be** a pure, unwrapped, strictly formatted **JSON object**. Strictly prohibit any additional text. This object must contain all the following fields:\n\n* **`title`**: (String) Devise an eye-catching, informative Chinese title.\n* **`author`**: (String) **【Data Replication Task】** Directly use the value of the 'author' field provided in the input.\n* **`digest`**: (String) You must originally write a brilliant digest for sharing and preview. **This is a hard requirement: the final length must be strictly controlled between 50 and 120 characters, including all punctuation.**\n* **`content`**: (String)\n    * **【Core Creation Task】**: Write an in-depth Chinese report of 1500 to 5000 characters.\n    * **【Elegant Formatting Hard Requirements】**:\n        * **Breathing Room**: Paragraphs and sections should have appropriate spacing, avoiding dense text. All text paragraphs must be wrapped in `<p>...</p>`, and paragraphs should be brief (typically 2-4 sentences).\n        * **Rhythm**: Alternate between long and short sentences, avoiding continuous sequences of structurally uniform sentences. Enrich the language rhythm through questions, exclamations, quotes, etc.\n        * **Structuring**:\n            * **Hook**: Must be a powerful 'hook' that grabs the reader within three sentences.\n            * **Subheadings `<strong>`**: The main body must be divided into 3-5 logical sections, with each subheading wrapped in `<strong>...</strong>`. Subheadings should be concise, powerful, and serve as 'signposts'.\n            * **Lists `<ul><li>`**: If the content contains multiple parallel points, steps, or examples, **you must use** `<ul>` and `<li>...</li>` lists for formatting, as this is clearer and more elegant than plain text paragraphs.\n            * **Conclusion**: The conclusion must be powerful and thought-provoking.\n        * **Embellishments (Emoji)**: You can **strategically and sparingly** use one or two minimalist emojis (e.g., ✨, 🚀, 💡, 🎯) that match the context's mood, as paragraph embellishments, but **strictly prohibit overuse or flashy emojis**.\n* **`image_prompt`**: (String)\n    * **【Creative Generation Task】**: After you have completed the article creation, based on your generated **Chinese title** and **core content**, extract and create a vivid, detailed, high-quality **Chinese** image prompt suitable for AI painting models. Artistic Guidance: The prompt should focus on pure visual description, incorporating styles such as 'concept art', 'cinematic lighting', 'technological sense', 'minimalism', and the theme must be highly relevant to the article content."
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "05b88133-6b62-465e-b709-e6261fb1fa5e",
      "name": "Gemini",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "notes": "Connects to the Google Gemini AI model's language model credentials.",
      "position": [
        -32,
        528
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-pro"
      },
      "typeVersion": 1
    },
    {
      "id": "90de8e9b-6553-44cc-8d7a-1adccd159b49",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -224
      ],
      "parameters": {
        "color": 4,
        "width": 720,
        "height": 560,
        "content": "## 🚀 Generate and Publish Content to WeChat(Weixin) Official Accounts with Gemini and Doubao AI\n\nEffortlessly automate the entire process from article conceptualization to draft publishing! This n8n workflow integrates powerful AI capabilities to automatically write high-quality WeChat Official Account articles, generate exquisite accompanying images, and finally publish them to your WeChat Official Account's draft box, significantly boosting content creation efficiency. For questions, WeChat ID: atang658\n\n### ✨ Workflow Overview\n\n1.  **💡 Intelligent Topic Selection & Input**: The workflow starts with a simple form. You only need to provide the article topic (a single sentence or a reference article) and specify the author to initiate the creation process.\n2.  **✍️ AI Deep Content Generation**: Utilizing the advanced Google Gemini AI model, based on your input topic and a preset professional-grade Prompt, it automatically generates all essential elements including a captivating title, precise digest, rich main content, and detailed prompts for accompanying images. The article content emphasizes elegant formatting and reading experience.\n3.  **🖼️ Doubao AI Image Generation**: Based on the image prompts generated by the AI writing, it automatically calls the Doubao AI painting model to tailor a cover image highly relevant to your article's theme.\n4.  **✂️ Smart Image Processing**: Automatically downloads the generated image and performs cropping optimization to fit the standard dimensions of a WeChat Official Account cover, while also removing potential watermarks.\n5.  **🚀 One-Click Draft Publishing**: Seamlessly uploads the final generated article content (including title, author, digest, full HTML body) and the processed cover image to your WeChat Official Account's draft box, awaiting your final review and publication."
      },
      "typeVersion": 1
    },
    {
      "id": "6ec26bc1-d214-4db6-b24b-11f0321e41e4",
      "name": "Setup Steps & Notes",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -224
      ],
      "parameters": {
        "color": 3,
        "width": 784,
        "height": 560,
        "content": "### 🛠️ Setup Steps\n\nTo ensure this workflow runs smoothly, you need to perform the following simple credential configurations:\n\n1.  **AI Credentials**:\n    * **Google Gemini**: Configure your Google Gemini API Key credentials.\n    * **Doubao AI**: Configure your Doubao AI (Volcano Engine) API Key credentials, usually of type `Header Auth`.\n2.  **WeChat Official Account Credentials**:\n    * **WeChat Official Account**: Configure your WeChat Official Account API credentials, ensuring they have permissions to upload materials and manage drafts.\n\nAfter completing the above credential configurations, save and activate your workflow to start using it.\n\n### 📝 Important Notes\n\n* Please ensure your AI services (Gemini, Doubao) have sufficient call quotas.\n* WeChat Official Account APIs have rate limits; please use them reasonably. Remember to set up IP whitelisting.\n* The `Crop Image (Remove Watermark)` node is cropped according to current specific dimensions; you can adjust cropping parameters or choose to skip this step based on your actual needs.\n* The workflow canvas contains detailed **Sticky Notes**; it is recommended to view them after importing to get specific function descriptions and configuration tips for each node."
      },
      "typeVersion": 1
    },
    {
      "id": "cf1f54f0-f778-426d-b27a-eea05b299904",
      "name": "Article Topic Input Form",
      "type": "n8n-nodes-base.formTrigger",
      "notes": "Users input article topics and author information via this form.",
      "position": [
        -160,
        368
      ],
      "webhookId": "9410f8a7-57d2-4dc0-99ee-d51dd40fdbc4",
      "parameters": {
        "options": {},
        "formTitle": "WeChat Official Account",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Author"
            },
            {
              "fieldLabel": "Generate Article with One Sentence"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Generate Article with Reference Article"
            }
          ]
        }
      },
      "typeVersion": 2.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "e8d68f4b-e7be-4b71-8979-1b1aa2277bb4",
  "connections": {
    "Gemini": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Article Draft (Gemini)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "WeChat Memory": {
      "ai_memory": [
        [
          {
            "node": "Generate Article Draft (Gemini)",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Check Image Generation Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format AI Output": {
      "main": [
        [
          {
            "node": "Doubao Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Cover Image": {
      "main": [
        [
          {
            "node": "Create Draft Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Doubao Image Generation": {
      "main": [
        [
          {
            "node": "Wait for Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Article Topic Input Form": {
      "main": [
        [
          {
            "node": "Generate Article Draft (Gemini)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Image Generation": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Image Generation Status": {
      "main": [
        [
          {
            "node": "Crop Image (Remove Watermark)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait for Image Generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Crop Image (Remove Watermark)": {
      "main": [
        [
          {
            "node": "Upload Cover Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Article Draft (Gemini)": {
      "main": [
        [
          {
            "node": "Format AI Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Related Workflows

Automate Customer Queries with OpenAI GPT & Serp API Integration

Automate customer queries with an AI assistant powered by OpenAI GPT and Serp API. Use the chat Trigger and memory Buffer Window to provide instant and accurate responses to customer inquiries 24/7. Features include conversation memory for seamless interactions, real-time data processing for updated answers, and automatic filtering to prioritize urgent messages. Perfect for e-commerce businesses handling over 100 daily product inquiries, SaaS support teams, or any customer-facing role that requires fast, reliable answers. Requires 2 accounts: OpenAI API and Serp API. Save up to 5 hours daily by managing unlimited customer conversations with contextual, product-specific answers from your resources.

966,017 views
Personal ProductivityAI Chatbot

Automate WhatsApp Customer Inquiries with OpenAI and Vector Storage

Automate customer inquiries on WhatsApp using an AI assistant powered by OpenAI GPT. By integrating WhatsApp Business API, this workflow enables your AI to respond to customer questions 24/7, enhancing user experience and engagement. Features conversation memory for seamless interactions, vector storage for precise answers, and automatic message processing for real-time responses. Perfect for e-commerce stores with over 50 daily inquiries, SaaS customer success teams, or sales departments requiring instant product information. Requires 3 accounts: WhatsApp Trigger API, OpenAI API, and WhatsApp Business API. Handle unlimited inquiries efficiently, saving up to 5 hours daily with contextual, accurate responses from your product documentation.

378,452 views
Lead NurturingAI Chatbot

Automate Customer Inquiries with OpenAI Chat and HTTP Request

Automate customer inquiries using an AI assistant powered by OpenAI GPT and HTTP Request integration. This workflow enables real-time responses to customer questions, ensuring support is available 24/7. Features include conversation memory for engaging chats, automatic message processing for instant replies, and HTML for rich content rendering. Perfect for e-commerce businesses managing over 100 daily inquiries or SaaS platforms requiring real-time user support. Requires 1 account: OpenAI API. Save 5 hours weekly by handling unlimited customer inquiries with precise, context-aware answers from your product documentation.

330,215 views
Market ResearchAI Summarization

Automate Social Media Content Creation with Google Gemini & OpenAI

Streamline your social media content strategy with an automated workflow using Google Gemini and OpenAI GPT. This solution allows social media managers to generate, schedule, and publish posts across Facebook, Instagram, and LinkedIn seamlessly, saving hours of manual work each week. Features real-time content generation, intelligent scheduling, and integration with Facebook Graph API and Twitter API for effective outreach. Perfect for social media managers handling multiple accounts and needing consistent, engaging content for their audience. Requires 9 accounts: Google Palm API, OpenAI API, Facebook Graph API, and more. Experience up to 70% faster content creation and manage over 30 posts daily with AI-driven insights.

271,744 views
Social MediaMultimodal AI

How to Use This Workflow

1Import to n8n

  1. Copy the JSON using the button above
  2. Open your n8n instance
  3. Click “Import workflow” or press Ctrl+V
  4. Paste the JSON and click “Import”

2Before Running

Configure credentials and update service-specific settings before executing the workflow. Review required credentials in the Technical Details section above.

72