This workflow corresponds to n8n.io template #15794 — we link there as the canonical source.
This workflow follows the Agent → Facebookgraphapi recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "ceee847d-28a3-43c0-9a24-3df27bc8c46a",
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-2928,
-592
],
"parameters": {},
"typeVersion": 1
},
{
"id": "687ec262-a414-40a1-ad9e-02c166b25e0b",
"name": "Set Context",
"type": "n8n-nodes-base.set",
"position": [
-2672,
-592
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "ctx-01",
"name": "raw_content",
"type": "string",
"value": "Verified n8n Creator is an official member of the n8n Automation Workflows Creators program. They design, build, and share n8n workflows with the community. This badge demonstrates professional automation capabilities. Creators often come from Marketing, Product, Dev, or Business backgrounds - not necessarily programmers. The goal of the program is to build a high-quality workflow library to make n8n easier to adopt."
},
{
"id": "ctx-02",
"name": "fanpage_name",
"type": "string",
"value": "Jay Nguyen - GenStaff AI Solutions"
},
{
"id": "ctx-03",
"name": "content_style",
"type": "string",
"value": "Professional, inspiring, tailored for the automation and no-code/low-code community. Confident, brief, and concise tone. A light touch of humor can be used."
},
{
"id": "ctx-04",
"name": "original_image_url",
"type": "string",
"value": "https://nguyenthieutoan.com/wp-content/uploads/2026/05/NguyenThieuToan-photo-Jay-Nguyen-n8n-creators.webp"
},
{
"id": "ctx-05",
"name": "language",
"type": "string",
"value": "English"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "74fd2304-ad56-45b4-abc3-fc6c02305483",
"name": "AI Agent: Write Post & Image Prompt",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-2224,
-592
],
"parameters": {
"text": "={{ $('Set Context').item.json.raw_content }}",
"options": {
"systemMessage": "=## ROLE\nYou are a social media copywriting expert for the Fanpage **{{ $('Set Context').item.json.fanpage_name }}**.\n\n## STYLE & TONE\n{{ $('Set Context').item.json.content_style }}\n\n## MISSION\nBased on the provided raw content, you will:\n1. Write a complete, engaging Facebook post suitable for the fanpage and its style.\n2. Create a detailed image prompt to generate a matching illustration.\n\n## FACEBOOK POST RULES\n\n### Structure:\n- **Hook:** The first 1-2 sentences must be extremely engaging to make the reader stop scrolling. Use a question, a shocking fact, or a strong statement.\n- **Body:** Develop the main idea from the raw content concisely and with depth. Use line breaks after each point for mobile readability.\n- **CTA (Call-to-Action):** End with a specific, natural call to action (e.g., \"Are you using automation yet?\", \"Tag someone who needs to know this \ud83d\udc47\", \"Save this for later \ud83d\udd16\").\n- **Hashtags:** 4-6 relevant hashtags, placed at the end of the post on a separate line.\n\n### Strict Requirements:\n- Use emojis naturally, do not overuse (3-6 emojis/post).\n- Length: 100-250 words.\n- Write in {{ $('Set Context').item.json.language }} (hashtags can be mixed).\n- DO NOT use bullet points (\u2022) in the text, use line breaks instead.\n- DO NOT insert direct links into the post.\n- The tone must be consistent with the fanpage style.\n\n## IMAGE PROMPT RULES\n\n### Prompt Structure:\n`[Art Style], [Main Subject Description], [Background Setting], [Lighting & Colors], [Mood/Emotion], [Technical Details]`\n\n### Strict Requirements:\n- Style: {{ $json.content_style }}\n- Colors: Vibrant but not garish, matching the content.\n- DO NOT include identifiable real human faces.\n- The image MUST relate DIRECTLY to the post content.\n- Describe the layout and text hierarchy clearly if applying text to the image.\n- Any text in the image (titles, content) must use {{ $('Set Context').item.json.language }}.\n- If a reference image is provided: Carefully review the layout to generate an appropriate, adhering prompt that guides the model on what to follow and what details to alter. Title should be standardized to {{ $json.language }}.\n\n## OUTPUT FORMAT\nOutput JSON with the exact structure:\n{\n \"post_text\": \"Complete Facebook post content\",\n \"image_prompt\": \"Image generation prompt\"\n}\n\n**ABSOLUTELY DO NOT** add text, markdown, or explanations outside the JSON."
},
"promptType": "define",
"hasOutputParser": true
},
"retryOnFail": true,
"typeVersion": 3.1,
"waitBetweenTries": 1000
},
{
"id": "e7cc2486-7801-41a2-8680-a24fa5bd11eb",
"name": "Google Gemini Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
-2320,
-320
],
"parameters": {
"options": {},
"modelName": "models/gemini-3.1-flash-lite"
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.1
},
{
"id": "061c8700-184b-4aad-9603-8c1876163087",
"name": "JSON Output Parser",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
-2128,
-384
],
"parameters": {
"autoFix": true,
"jsonSchemaExample": "{\n \"post_text\": \"\u2728 Powerful hook to make the reader stop scrolling.\\n\\nDevelop main content from raw input, concise with depth.\\n\\nNext line with the next idea.\\n\\nNatural CTA, calling for a specific action \ud83d\udc47\\n\\n#Hashtag1 #Hashtag2 #Hashtag3 #Hashtag4\",\n \"image_prompt\": \"Modern digital illustration of [subject related to content], [detailed visual description], [background setting], [lighting style], [color palette], professional social media aesthetic, square 1:1 aspect ratio, high quality, ultra detailed\"\n}"
},
"typeVersion": 1.3,
"alwaysOutputData": false
},
{
"id": "7c593691-140b-4a55-8408-2fbb1d98eaae",
"name": "Select Image Mode",
"type": "n8n-nodes-base.if",
"position": [
-1728,
-592
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 3,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "check-image-before-generate",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $('Set Context').item.json.original_image_url }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.3
},
{
"id": "1e2a1b54-f565-41a6-9930-1f51cc96f5ff",
"name": "Download Image to Edit",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
-1424,
-688
],
"parameters": {
"url": "={{ $('Set Context').item.json.original_image_url }}",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"typeVersion": 4.4
},
{
"id": "8c7fc417-429b-4b68-ba24-15d4af12e178",
"name": "Edit Original Image",
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"onError": "continueRegularOutput",
"position": [
-1168,
-688
],
"parameters": {
"images": {
"values": [
{}
]
},
"prompt": "={{ $('AI Agent: Write Post & Image Prompt').item.json.output.image_prompt }}\n\nIMPORTANT REQUIREMENTS:\n- Keep the overall composition and main subject from the original image\n- Enhance colors to be more vibrant and eye-catching for social media\n- Apply a modern, professional aesthetic\n- Make it suitable as a Facebook post image\n- Ensure 1:1 square format\n- High quality output",
"modelId": {
"__rl": true,
"mode": "list",
"value": "models/gemini-3.1-flash-image-preview",
"cachedResultName": "models/gemini-3.1-flash-image-preview (Nano Banana 2)"
},
"options": {
"binaryPropertyOutput": "data"
},
"resource": "image",
"operation": "edit"
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "e4711cf1-990e-4882-bf3c-2ee626832c92",
"name": "Generate New Image",
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"onError": "continueRegularOutput",
"position": [
-1424,
-496
],
"parameters": {
"prompt": "={{ $('AI Agent: Write Post & Image Prompt').item.json.output.image_prompt }}\n\nCRITICAL REQUIREMENTS:\n- Create a stunning, professional image for a Facebook post\n- Style: modern, clean, visually striking and scroll-stopping\n- Perfect square 1:1 composition\n- High contrast and vibrant colors that work on mobile screens\n- NO text, letters, words, or typography in the image\n- NO real identifiable people or celebrities\n- Focus on concepts, objects, abstract elements, or illustrations\n- Ultra high quality, sharp details",
"modelId": {
"__rl": true,
"mode": "id",
"value": "models/gemini-2.0-flash-preview-image-generation"
},
"options": {
"binaryPropertyOutput": "data"
},
"resource": "image"
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "ff348ea6-b09b-4edf-a99d-5bef3deb2bad",
"name": "Post to Facebook",
"type": "n8n-nodes-base.facebookGraphApi",
"onError": "continueRegularOutput",
"position": [
-768,
-592
],
"parameters": {
"edge": "photos",
"node": "={{ $('Set Context').first().json.page_id || 'me' }}",
"options": {
"queryParameters": {
"parameter": [
{
"name": "caption",
"value": "={{ $('AI Agent: Write Post & Image Prompt').first().json.output.post_text }}"
}
]
}
},
"sendBinaryData": true,
"graphApiVersion": "v23.0",
"httpRequestMethod": "POST",
"binaryPropertyName": "data"
},
"credentials": {
"facebookGraphApi": {
"name": "<your credential>"
}
},
"typeVersion": 1
},
{
"id": "4c4f90c2-772c-4921-b068-a60eee9cbdf9",
"name": "Post Result",
"type": "n8n-nodes-base.set",
"position": [
-528,
-592
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "result-01",
"name": "status",
"type": "string",
"value": "={{ $json.id ? 'SUCCESS' : 'FAILED' }}"
},
{
"id": "result-02",
"name": "facebook_post_id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "result-03",
"name": "post_text_preview",
"type": "string",
"value": "={{ $('AI Agent: Write Post & Image Prompt').first().json.output.post_text.substring(0, 100) }}..."
},
{
"id": "result-04",
"name": "image_mode",
"type": "string",
"value": "={{ $('Set Context').first().json.original_image_url ? 'Edited from original' : 'AI Generated' }}"
},
{
"id": "result-05",
"name": "posted_at",
"type": "string",
"value": "={{ $now }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a2756725-b74b-4d26-a615-46e7e698f43f",
"name": "Sticky Note - Main Overview",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3488,
-944
],
"parameters": {
"width": 438,
"height": 914,
"content": "## Facebook AI Post Creator: Auto-Write & Generate Images\n\nThis workflow automatically generates professional **Facebook posts** and matching illustrations from raw text. It operates seamlessly in two modes: remixing an existing image with new copy, or generating a completely new image from scratch using **Google Gemini**.\n\n### How it works\n1. **Trigger:** Receives input data manually or from any source (Webhook, Google Sheets, etc.).\n2. **Configuration:** The `Set Context` node standardizes the raw content, target fanpage name, brand style, and optional original image URL.\n3. **AI Generation:** A Gemini AI Agent writes the Facebook post and crafts a highly detailed prompt for the image generation model.\n4. **Image Processing:** The workflow branches based on image presence. If an original image exists, Gemini beautifully edits/remixes it. If not, Gemini generates a brand-new illustration based on the AI's prompt.\n5. **Delivery:** The final post (caption + binary image data) is published directly to your Facebook Page.\n\n### Setup\n* [ ] Connect **Google Gemini** credentials in all AI nodes (`googlePalmApi`).\n* [ ] Connect **Facebook Graph API** credentials in the `Post to Facebook` node.\n* [ ] Edit the **Set Context** node to update `raw_content`, `fanpage_name`, `content_style`, and your `page_access_token`.\n* [ ] Activate the workflow and test.\n\n### Customization tips\n* **Change trigger:** Swap the Manual Trigger for a Webhook or Schedule trigger for full automation.\n* **Different AI Model:** You can replace Gemini Flash with another LLM for text, but image generation requires compatible image models.\n\n### LICENCE\nThis template is shared free of charge. Copyright belongs to Nguyen Thieu Toan. Any copying or modification must credit the author."
},
"typeVersion": 1
},
{
"id": "aa7306cd-98c8-4cb0-aa15-9086e12f9ba9",
"name": "Sticky Note - Section 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3024,
-944
],
"parameters": {
"color": 7,
"width": 664,
"height": 600,
"content": "## Section 1: Trigger & Input Configuration\nReceives raw data from any source. The **Set Context** node defines the raw text, target fanpage, writing style, language, and image preferences."
},
"typeVersion": 1
},
{
"id": "57cf22bf-9de7-4951-87f9-aa0d2d4859a2",
"name": "Sticky Note - Section 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2320,
-944
],
"parameters": {
"color": 7,
"width": 550,
"height": 600,
"content": "## Section 2: AI Content Generation\nThe **Gemini AI Agent** receives the raw content and outputs two structured elements: a Facebook-ready caption (with emojis & hashtags) and a precise image generation prompt."
},
"typeVersion": 1
},
{
"id": "96f61214-c778-48b2-8173-88fa80f10d1d",
"name": "Sticky Note - Section 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1728,
-944
],
"parameters": {
"color": 7,
"width": 900,
"height": 600,
"content": "## Section 3: Image Creation & Processing\nRoutes the workflow based on the presence of an image URL. It either downloads and **edits the original image** using Gemini, or **generates a brand-new image** based on the AI's prompt."
},
"typeVersion": 1
},
{
"id": "b4d24e70-9510-470a-8f88-883bd46bf83a",
"name": "Sticky Note - Section 4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-784,
-944
],
"parameters": {
"color": 7,
"width": 550,
"height": 600,
"content": "## Section 4: Facebook Publishing\nPublishes the final composed image and AI-generated caption directly to the **Facebook Fanpage** via Graph API, then formats the execution results."
},
"typeVersion": 1
},
{
"id": "562ac2fa-be95-4070-8a44-7d81bd92ff1e",
"name": "Sticky Note - Warning",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2736,
-736
],
"parameters": {
"color": 3,
"width": 250,
"height": 180,
"content": "## \u26a0\ufe0f Edit this node!\n\nUpdate the `raw_content` and configure your Fanpage details here before running."
},
"typeVersion": 1
},
{
"id": "9de01999-1efe-403f-823b-f40820f22a5a",
"name": "Sticky Note - Author Message",
"type": "n8n-nodes-base.stickyNote",
"position": [
-3024,
-320
],
"parameters": {
"color": 4,
"width": 662,
"height": 284,
"content": "## Author Message\n\nHi! I am **Nguyen Thieu Toan (Jay Nguyen)** \u2014 a Verified n8n Creator and CEO/Founder of **GenStaff**. Thank you for using this template!\n\nThis workflow is shared with you for free. If it brings value to your work, optimizes your operations, or saves you time, you can buy me a coffee here: **[My Donate Website](https://nguyenthieutoan.com/payment/)** *(PayPal, Momo, Bank Transfer)*\n\n* Website: [nguyenthieutoan.com](https://nguyenthieutoan.com)\n* Email: me@nguyenthieutoan.com\n* Company: GenStaff ([genstaff.net](https://genstaff.net))\n* Socials (Facebook / X / LinkedIn): @nguyenthieutoan\n\n*Discover more of my automation solutions:* **[Click here](https://n8n.io/creators/nguyenthieutoan/)**"
},
"typeVersion": 1
}
],
"connections": {
"Set Context": {
"main": [
[
{
"node": "AI Agent: Write Post & Image Prompt",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Set Context",
"type": "main",
"index": 0
}
]
]
},
"Post to Facebook": {
"main": [
[
{
"node": "Post Result",
"type": "main",
"index": 0
}
]
]
},
"Select Image Mode": {
"main": [
[
{
"node": "Download Image to Edit",
"type": "main",
"index": 0
}
],
[
{
"node": "Generate New Image",
"type": "main",
"index": 0
}
]
]
},
"Generate New Image": {
"main": [
[
{
"node": "Post to Facebook",
"type": "main",
"index": 0
}
]
]
},
"JSON Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent: Write Post & Image Prompt",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Edit Original Image": {
"main": [
[
{
"node": "Post to Facebook",
"type": "main",
"index": 0
}
]
]
},
"Download Image to Edit": {
"main": [
[
{
"node": "Edit Original Image",
"type": "main",
"index": 0
}
]
]
},
"Google Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent: Write Post & Image Prompt",
"type": "ai_languageModel",
"index": 0
},
{
"node": "JSON Output Parser",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AI Agent: Write Post & Image Prompt": {
"main": [
[
{
"node": "Select Image Mode",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
facebookGraphApigooglePalmApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This n8n template automates the creation of professional Facebook posts and visually striking illustrations directly from simple raw text. If you want to maintain a consistent social media presence without spending hours writing copy and designing images, this workflow is…
Source: https://n8n.io/workflows/15794/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This Shopify AI automation is an advanced n8n-powered workflow that transforms Shopify product collections into SEO-optimized blog articles with images, while maintaining full visibility and control t
22-Automate_Multi_Platform_Social_Media_Content_Creation. Uses outputParserStructured, lmChatGoogleGemini, lmChatOpenAi, httpRequest. Event-driven trigger; 57 nodes.
This workflow is designed for e-commerce, marketing teams, or creators who want to automate the production of high-quality, AI-generated product visuals and ad creatives.
This workflow monitors Gmail for unread emails from a specific sender, classifies attached documents with Google Gemini, then extracts and validates structured data for bills of lading, invoices, and
This workflow acts as an intelligent content engine. Simply send a link to your Telegram bot (e.g., a product page or news article), and it will automatically scrape the content, rewrite it into a hig