Gemini + Google Sheets: Facebook posts ready to publish
Posting on Facebook sounds simple until you’re staring at a rough idea, rewriting it three times, hunting for an image, then losing track of what you posted and when.
Marketing managers feel this when content calendars get tight. A small business owner feels it when “I’ll post later” turns into “I forgot again.” And agencies juggling client pages end up buried in approvals. This Gemini Sheets automation turns one idea into a publish-ready post and logs it automatically.
You’ll see what the workflow does, what you need to run it, and how to think about customizing it for your brand voice and posting process.
How This Automation Works
Here’s the complete workflow you’ll be setting up:
n8n Workflow Template: Gemini + Google Sheets: Facebook posts ready to publish
flowchart LR
subgraph sg0["On form submission1 Flow"]
direction LR
n0@{ icon: "mdi:swap-horizontal", form: "rounded", label: "If2", pos: "b", h: 48 }
n1@{ icon: "mdi:swap-horizontal", form: "rounded", label: "If1", pos: "b", h: 48 }
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/merge.svg' width='40' height='40' /></div><br/>Merge"]
n3["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/facebook.svg' width='40' height='40' /></div><br/>Facebook Graph API"]
n4["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/facebook.svg' width='40' height='40' /></div><br/>Facebook Upload Img"]
n5@{ icon: "mdi:swap-horizontal", form: "rounded", label: "If", pos: "b", h: 48 }
n6@{ icon: "mdi:code-braces", form: "rounded", label: "Format Content", pos: "b", h: 48 }
n7@{ icon: "mdi:database", form: "rounded", label: "save content", pos: "b", h: 48 }
n8@{ icon: "mdi:robot", form: "rounded", label: "Basic LLM Chain", pos: "b", h: 48 }
n9@{ icon: "mdi:robot", form: "rounded", label: "Basic LLM Chain1", pos: "b", h: 48 }
n10["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Convert to File code"]
n11@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model", pos: "b", h: 48 }
n12@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model1", pos: "b", h: 48 }
n13["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>code2"]
n14["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/httprequest.dark.svg' width='40' height='40' /></div><br/>HTTP Request"]
n15["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/form.svg' width='40' height='40' /></div><br/>On form submission1"]
n16@{ icon: "mdi:database", form: "rounded", label: "Append row in sheet", pos: "b", h: 48 }
n17@{ icon: "mdi:message-outline", form: "rounded", label: "Send a message", pos: "b", h: 48 }
n5 --> n8
n1 --> n17
n0 --> n14
n2 --> n3
n13 --> n0
n13 --> n9
n14 --> n10
n7 --> n6
n6 --> n2
n8 --> n13
n9 --> n7
n3 --> n1
n16 --> n5
n4 --> n2
n15 --> n16
n10 --> n4
n11 -.-> n8
n12 -.-> n9
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n15 trigger
class n8,n9 ai
class n11,n12 aiModel
class n0,n1,n5 decision
class n7,n16 database
class n3,n4,n14 api
class n6,n10,n13 code
classDef customIcon fill:none,stroke:none
class n2,n3,n4,n10,n13,n14,n15 customIcon
Why This Matters: Turning Ideas Into Posts Is Still Too Manual
Most Facebook “content systems” are really just a messy set of tabs: notes in one place, drafts in another, images somewhere else, and no reliable record of what went live. You start with a decent idea, then waste time polishing it, second-guessing the hook, trimming for length, and trying to make it sound like your brand (not like a template). Then you post… and forget to log it. Next week you can’t tell what worked, what you repeated, or what you promised you’d test.
The friction compounds. Here’s where it breaks down.
- You rewrite the same kind of post over and over, because the last “good version” is hard to find.
- Images become a blocker, so posting slips by a day (or three) while you look for something usable.
- Manual posting creates inconsistencies, like missing links, weird formatting, or a caption that doesn’t match the image.
- Your tracking is unreliable, which means decisions are based on vibes instead of a clean content log.
What You’ll Build: An AI Facebook Post Machine That Logs Everything
This workflow starts with a simple web form where you drop a raw idea (a sentence is enough). n8n saves that submission to a Google Sheet so nothing gets lost, then Gemini steps in to polish the writing. It creates a short version and a fuller version, and it also generates an image prompt that matches your topic. Next, the workflow calls an image generation endpoint via HTTP Request, turns the response into a file, and uploads the image to your Facebook Business Page. Finally, it publishes the post, checks that the publish step succeeded, logs the final content to your Content Log sheet, and emails you a confirmation with the post result.
The workflow begins at the form trigger. After that, it uses a content-length gate and a structured Gemini output (parsed from JSON) to keep things consistent. It ends with a Facebook post you can actually ship, plus a Google Sheets trail you can use for reporting and iteration.
What You’re Building
| What Gets Automated | What You’ll Achieve |
|---|---|
|
|
Expected Results
Say you publish 5 Facebook posts a week. Manually, you might spend about 20 minutes writing, about 15 minutes finding or making an image, and another 5 minutes posting and logging it, so roughly 40 minutes per post (around 3 hours a week). With this workflow, you spend maybe 5 minutes submitting ideas through the form, then wait for Gemini and image generation to finish in the background. You still review before relying on it fully, but you’ll be spending time on judgment, not blank-page work.
Before You Start
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Google Sheets for content logging and input tracking.
- Gemini API to generate and polish post copy.
- Facebook Page access token (get it from Facebook Graph API Explorer after creating an app).
Skill level: Intermediate. You’ll connect credentials, copy sheet IDs, and confirm Facebook permissions.
Want someone to build this for you? Talk to an automation expert (free 15-minute consultation).
Step by Step
A content idea is submitted through a form. The Form Trigger captures whatever you type (one sentence or a full paragraph). That submission is appended to an “Input Tracking” tab in Google Sheets so you have a raw record of every request.
The workflow checks and cleans the text. A length gate ensures the input isn’t too short or too long, then a small Function step cleans formatting so Gemini gets predictable input. This is one of those unglamorous steps that saves you later.
Gemini generates structured outputs. The workflow runs two Gemini chat model steps and LLM chains to produce a short post, a full post, and an image prompt. The output is parsed from JSON so downstream steps can reliably pull the “short content” vs. “full content” fields.
An image is generated and published with the post. An HTTP Request node calls an image generation endpoint, the response is turned into a real image file, and the file is uploaded to your Facebook Page. A merge step combines the final text and uploaded image reference, then the workflow publishes the Facebook post and checks the result before notifying you via Gmail.
You can easily modify the prompt and sheet columns to match your brand workflow (for example, add “Campaign,” “Offer,” or “CTA style”). See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Form Trigger
Start by capturing content ideas via the built-in form and gating minimum length before AI processing.
- Add and open Form Input Trigger, then set Form Title to
Input the post ideaand Form Description toInput the idea that you want upload to Facebook,. - In Form Input Trigger → Form Fields, ensure the textarea label is
Input Information hereand the placeholder isAt least 50 words. - Connect Form Input Trigger to Append Form Row, then to Content Length Gate.
- In Content Length Gate, set the boolean condition left value to
{{ $json["Content"] ? $json["Content"].length > 0 : ( $json["message"]?.text?.length >= 50 ) }}to allow only valid content.
Step 2: Connect Google Sheets
Log form inputs and AI outputs into Google Sheets for tracking and review.
- Open Append Form Row and select the target spreadsheet and sheet (document ID
[YOUR_ID], sheetPost via form). - Map columns in Append Form Row: Date →
{{ $now.toFormat("dd/MM/yyyy") }}, Time →{{ $now.toFormat("HH") }}, Content →{{ $json["Input Information here"] }}. - Credential Required: Connect your googleSheetsOAuth2Api credentials in Append Form Row.
- Open Log Content Sheet and select the document
[YOUR_ID]and sheetTự động. - Map columns in Log Content Sheet: Ngày →
{{ new Date().toLocaleDateString("vi-VN") }}, Nội dung ngắn →{{ $('Parse LLM JSON').item.json.content }}, Nội dung đầy đủ →{{ $json.text?.trim() ? $json.text : $json.message?.content }}. - Credential Required: Connect your googleSheetsOAuth2Api credentials in Log Content Sheet.
Step 3: Set Up AI Processing
Configure the LLM pipeline that summarizes, parses, and expands content into a publishable article.
- In LLM Summary Builder, keep the Text prompt as provided and ensure it includes the dynamic content block expression (e.g.,
{{ $json.message?.text?.trim() ? $json.message.text : $json.content?.trim() ? $json.content : $json['Content']?.trim() ? $json['Content'] : "" }}). - Ensure Gemini Chat Model A is connected as the language model for LLM Summary Builder.
- Credential Required: Connect your googlePalmApi credentials in Gemini Chat Model A (credentials should be added to the model node, not the chain node).
- Open Parse LLM JSON and keep the parsing code that extracts JSON from
```json ... ```blocks. - Parse LLM JSON outputs to both Image Prompt Check and LLM Article Writer in parallel.
- In LLM Article Writer, keep the Text prompt and ensure it references
{{ $json.content }}for the summary input. - Ensure Gemini Chat Model B is connected as the language model for LLM Article Writer.
- Credential Required: Connect your googlePalmApi credentials in Gemini Chat Model B (credentials should be added to the model node, not the chain node).
Step 4: Configure Image Generation and Content Assembly
This step generates optional images, cleans content, and merges text and media for publishing.
- In Image Prompt Check, confirm the boolean condition uses
{{ !!$json.prompt_image }}to trigger image generation only when a prompt exists. - Open Image Generation Call and set URL to
https://router.huggingface.co/together/v1/images/generations, Method toPOST, and JSON Body to{ "response_format": "b64_json", "prompt": "{{ $json.prompt_image }}", "model": "black-forest-labs/FLUX.1-schnell" }. - Set Header Parameters in Image Generation Call to
Authorization: Bearer [CONFIGURE_YOUR_TOKEN]andContent-Type: application/json. - In Build Image File, keep the code that converts
$json.data[0].b64_jsonto binary with filenameimage.png. - Open Upload Facebook Image and set Edge to
photos, Node to[YOUR_ID], Send Binary Data totrue, and Binary Property Name todata. Ensure published isfalse. - Credential Required: Connect your facebookGraphApi credentials in Upload Facebook Image (this node needs credentials but none are configured).
- Open Clean Content Text and keep the function that removes
#and*characters and outputscontentandplatform. - Set Combine Streams to Mode
combineand Combine BycombineByPositionto merge image and text data.
Step 5: Configure Publishing and Notifications
Publish the post to Facebook and send a confirmation email when the post is successful.
- Open Publish Facebook Post and set Edge to
feed, Node to[YOUR_ID], and Graph API Version tov22.0. - In Publish Facebook Post query parameters, set message to
{{ $('Clean Content Text').item.json.content }}and attached_media to{{ $json.id ? `[{\"media_fbid\":\"${$json.id}\"}]` : "" }}. - Credential Required: Connect your facebookGraphApi credentials in Publish Facebook Post.
- In Post Result Check, verify the condition uses
{{ $json.post_supports_client_mutation_id }}to gate the notification step. - Open Send Email Notice and set Send To to
[YOUR_EMAIL], Subject to✅ The draft version is uploaded, and Message to✅ The post will be published after 2 minutes! 📄 Review in: https://facebook.com/{{ $json.id.split('_')[0] }}/posts/{{ $json.id.split('_')[1] }}. - Credential Required: Connect your gmailOAuth2 credentials in Send Email Notice.
Step 6: Test and Activate Your Workflow
Run a full test to confirm AI output, image generation, publishing, and email notifications.
- Click Execute Workflow and submit the Form Input Trigger with a 50+ word idea.
- Confirm Append Form Row and Log Content Sheet add rows to their respective sheets.
- Verify that Parse LLM JSON outputs valid
prompt_imageandcontent, and that image generation only runs when a prompt exists. - Check Facebook to ensure Publish Facebook Post creates a post, and verify the email from Send Email Notice includes the correct post URL.
- When everything works as expected, toggle the workflow to Active for production use.
Troubleshooting Tips
- Facebook Graph API credentials can expire or lack permissions. If posting fails, check your long-lived Page Access Token and that it includes pages_manage_posts in the Facebook Developers dashboard.
- If you’re using Wait nodes or external rendering, processing times vary. Bump up the wait duration if downstream nodes fail on empty responses.
- Default prompts in AI nodes are generic. Add your brand voice early or you’ll be editing outputs forever.
Quick Answers
About 30–45 minutes if you already have your Facebook and Google credentials ready.
No. You’ll mostly connect accounts, paste IDs, and tweak prompts.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in Gemini API usage (often close to free at low volume) and any image generation API costs from the HTTP request provider.
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes, and you probably should. You can adjust the Gemini prompts in the LLM chain steps to match your tone, add extra fields to the form (like “Audience” or “Offer”), then write those values into Google Sheets. You can also swap the image generation endpoint in the HTTP Request node if you prefer a different provider, as long as it returns an image (or base64) that the “Build Image File” step can turn into an uploadable file.
Usually it’s an expired Page Access Token or missing permissions like pages_manage_posts. Regenerate a long-lived token, confirm you’re an admin on the target Facebook Page, and double-check the Page ID inside both the image upload and publish nodes. If it works once and then randomly fails later, rate limits or token revocations are also common culprits.
If you’re on n8n Cloud, the practical limit is your monthly execution allowance (Starter is designed for smaller workloads; Pro handles more). If you self-host, there’s no platform execution cap, but you’re still limited by your server and by Facebook/Gemini quotas. In real terms, most small teams can run dozens of posts a day without issue, as long as API limits aren’t being hammered.
Often, yes, because this workflow benefits from branching logic (gates, checks, merges) and structured AI outputs. n8n also gives you more control over how you parse and route the Gemini response, which matters when you’re generating both text and image prompts. If you want self-hosting, n8n is the straightforward choice. Zapier or Make can still be fine for very small “idea in, draft out” flows with minimal logic. Talk to an automation expert if you’re not sure which fits.
Once this is running, you stop treating “write a Facebook post” like a mini project. The workflow handles the repetitive parts, and you keep control over the final call.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.