Google Gemini to LinkedIn, posts with images ready
You sit down to “just post on LinkedIn,” and suddenly it’s 45 minutes later. The idea was there, but the writing, formatting, image creation, and upload steps turned into a mini project.
This hits marketing managers hard, because consistency is part of the job. founders feel it when the week gets busy. And if you run a small agency, it’s one more thing that slips when client work piles up. With Gemini LinkedIn automation, one topic becomes a publish-ready post plus a matching image.
Below, you’ll see how the workflow runs in n8n, what you need to connect, and what kind of time you get back once the boring parts are automated.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Google Gemini to LinkedIn, posts with images ready
flowchart LR
subgraph sg0["On form submission Flow"]
direction LR
n0["<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 submission"]
n1@{ icon: "mdi:swap-vertical", form: "rounded", label: "Mapper", pos: "b", h: 48 }
n2@{ icon: "mdi:robot", form: "rounded", label: "AI Agent", pos: "b", h: 48 }
n3@{ icon: "mdi:brain", form: "rounded", label: "Google Gemini Chat Model", pos: "b", h: 48 }
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/code.svg' width='40' height='40' /></div><br/>Normalizer"]
n5["<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"]
n6["<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/>Register Image Upload"]
n7["<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/>Text to image1"]
n8["<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/>Upload Image to LinkedIn1"]
n9["<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 binary buffer"]
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/>Code"]
n11@{ icon: "mdi:cog", form: "rounded", label: "Wait", pos: "b", h: 48 }
n10 --> n11
n11 --> n5
n1 --> n2
n2 --> n4
n4 --> n7
n7 --> n6
n0 --> n1
n6 --> n9
n9 --> n8
n3 -.-> n2
n8 --> n10
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 n0 trigger
class n2 ai
class n3 aiModel
class n5,n6,n7,n8 api
class n4,n9,n10 code
classDef customIcon fill:none,stroke:none
class n0,n4,n5,n6,n7,n8,n9,n10 customIcon
The Problem: LinkedIn Posting Becomes a Multi-Step Chore
Writing a decent LinkedIn post is only part of the work. You also have to turn rough notes into something structured, clean up formatting that looks fine in a doc but weird on LinkedIn, come up with an image that doesn’t feel like stock-photo filler, and then go through the upload process without breaking line spacing or losing hashtags. On a busy week, the “I’ll post later” delay is what kills consistency. And when you do rush it, mistakes show up in public.
The friction compounds. Not because any one step is impossible, but because there are too many of them.
- Drafting from scratch for every post makes you second-guess tone, length, and structure.
- Manual formatting often turns bullet points and spacing into a messy wall of text.
- Finding or designing a relevant image can take about 30 minutes on its own.
- Uploading the image, waiting for processing, and publishing becomes a repetitive checklist you repeat every time.
The Solution: Generate the Post and Image, Then Publish Automatically
This workflow turns a single topic submission into a finished LinkedIn post with a custom AI-generated image, then publishes it for you. It starts with a simple form where you drop the topic you want to write about. From there, Google Gemini generates two things in one go: the LinkedIn post copy (with a coherent structure and hashtags) and a separate image prompt that matches the theme. The workflow then calls Google Imagen 4 to create a square, LinkedIn-friendly image, registers an upload session with LinkedIn, converts the image data into the right format, and uploads it. Finally, it adapts the text into LinkedIn-safe formatting, waits briefly so the asset is ready, and publishes the post with the image attached.
The workflow kicks off from your form submission. Gemini produces post text plus an image description, then Imagen 4 creates the visual. LinkedIn’s API handles upload registration, the image is attached, and the post goes live after a short wait.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you publish three LinkedIn posts per week. Manually, a reasonable routine is about 30 minutes to write, 20 minutes to clean up formatting and hashtags, and another 20 minutes to create or find an image, so roughly 70 minutes per post (about 3.5 hours a week). With this workflow, you submit a topic in about 2 minutes, then wait while Gemini and Imagen run (image generation is usually 10–30 seconds, plus upload time). You still may review the output, but the “blank page + design task” part is gone.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- LinkedIn Developer App for OAuth and posting permissions.
- Google Gemini API to generate the post and image prompt.
- Google Cloud access token (get it from Google Cloud SDK via gcloud auth print-access-token)
Skill level: Intermediate. You’ll be connecting OAuth credentials and pasting API tokens, plus minor prompt edits if you want a specific brand voice.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A topic submission triggers everything. You fill out a form with one topic (for example, “3 mistakes teams make with onboarding emails”). n8n captures it and maps the input into the format the AI agent expects.
Gemini writes the post and plans the image. The content agent asks Google Gemini for structured output, which includes LinkedIn post text plus an image prompt description. A formatting step cleans the response, so you are not stuck fixing JSON quirks or odd line breaks.
Imagen creates the visual and LinkedIn accepts the upload. n8n sends the prompt to Google Imagen 4 (square aspect ratio), then registers an upload with LinkedIn. The workflow converts the returned base64 image into a binary payload and uploads it as an asset.
The post is curated and published. Another formatting step adapts the text into LinkedIn-friendly formatting (so markdown doesn’t show up like raw symbols). After a short wait to ensure the asset is processed, the workflow publishes the post with the image attached.
You can easily modify the tone and formatting rules to match your brand, then publish as a draft-review flow instead of auto-posting based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Form Trigger
This workflow starts with a form that captures a LinkedIn post topic and maps it into the AI prompt pipeline.
- Add and open Form Submission Trigger.
- Set Form Title to
LinkedIn Post Generator. - In Form Fields, keep the Topic field as required with placeholder
Enter prompt here..... - Connect Form Submission Trigger to Map Input Fields to pass the form data downstream.
Step 2: Connect Primary Services (AI + LinkedIn)
Set credentials for the AI model and LinkedIn API requests used in the workflow.
- Open Gemini Chat Engine and set Model Name to
models/gemini-2.5-pro. - Credential Required: Connect your
googlePalmApicredentials in Gemini Chat Engine. - Open Generate Image Prompt and verify URL is
https://us-central1-aiplatform.googleapis.com/v1/projects/[YOUR_ID]/locations/us-central1/publishers/google/models/imagen-4.0-generate-preview-06-06:predict. - Credential Required: Connect your
httpBearerAuthcredentials in Generate Image Prompt. - Open Initiate Image Upload and Publish LinkedIn Post.
- Credential Required: Connect your
httpBearerAuthandlinkedInOAuth2Apicredentials in both Initiate Image Upload and Publish LinkedIn Post.
[YOUR_ID] placeholder in LinkedIn and Vertex AI URLs with your actual project/person IDs, or the API calls will fail.Step 3: Set Up the AI Content Strategy Chain
The workflow maps the form topic into a structured prompt, then uses the AI agent to generate post content and an image prompt.
- In Map Input Fields, add an assignment with Name
chatInputand Value={{ $json.Topic }}. - Open Content Strategy Agent and keep the System Message expression that starts with
=I need help creating a professional LinkedIn post for the topic: "{{ $json.chatInput }}". - Ensure Gemini Chat Engine is connected as the language model for Content Strategy Agent (credentials are set on Gemini Chat Engine, not the agent).
- Connect Content Strategy Agent to Format Output Data to parse the JSON response into
post_contentandimage_prompt.
```json and ``` before parsing.Step 4: Configure Image Generation and LinkedIn Asset Upload
This stage generates the image, registers a LinkedIn upload, builds a binary payload, and uploads the asset.
- In Generate Image Prompt, set Method to
POSTand Content Type toraw. - Set Body to the JSON expression that includes
"prompt": "{{ $json.image_prompt }}"and"aspectRatio": "1:1". - In Initiate Image Upload, keep URL as
https://api.linkedin.com/v2/assets?action=registerUploadand ensure the header X-Restli-Protocol-Version is set to2.0.0. - Open Build Binary Payload and keep the code that reads from Generate Image Prompt and Format Output Data (no changes required).
- In Upload Image Asset, set URL to
={{ $('Initiate Image Upload').item.json.value.uploadMechanism['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest'].uploadUrl }}and Content Type tobinaryData. - In Upload Image Asset, set headers Authorization to
Bearer [CONFIGURE_YOUR_TOKEN]and Content-Type toimage/png.
Step 5: Adapt Post Text and Publish to LinkedIn
The post text is converted to LinkedIn-friendly formatting, then a short pause allows the asset upload to finalize before publishing.
- In Adapt LinkedIn Text, keep the code that converts markdown to LinkedIn-compatible text and outputs
linkedin_content. - In Pause for Upload, set Amount to
60seconds to allow asset processing time. - In Publish LinkedIn Post, keep URL as
https://api.linkedin.com/v2/ugcPosts. - Set the Body field to the existing JSON expression, including
"text": {{ $json.linkedin_content ? JSON.stringify($json.linkedin_content) : "\"\"" }}and"media": "{{ $('Initiate Image Upload').item.json.value.asset }}". - Confirm the execution flow is linear: Upload Image Asset → Adapt LinkedIn Text → Pause for Upload → Publish LinkedIn Post.
Step 6: Test and Activate Your Workflow
Run a manual test to confirm the form input produces a LinkedIn post with an image.
- Click Execute Workflow and submit the Form Submission Trigger with a test Topic.
- Verify Format Output Data returns
post_contentandimage_promptwithout JSON parsing errors. - Confirm Upload Image Asset succeeds and Adapt LinkedIn Text outputs
linkedin_content. - Check LinkedIn for a new published post with the generated image after Pause for Upload completes.
- Toggle the workflow Active to enable it for production form submissions.
Common Gotchas
- LinkedIn credentials can expire or need specific permissions. If things break, check your LinkedIn Developer App token and the w_member_social scope first.
- 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.
Frequently Asked Questions
About an hour if you already have your LinkedIn and Google credentials ready.
No. You will mostly connect accounts and paste tokens into n8n. The only “code” parts are already in the workflow and usually don’t need changes.
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 Google Gemini and Google Imagen 4 usage from your Google accounts.
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, but you’ll change one key behavior. Keep the Gemini generation steps the same, then replace the “Publish LinkedIn Post” HTTP request with a draft-saving step (for example, write the final text and asset URL to Google Sheets) and add an approval workflow before publishing. Common tweaks include adjusting the agent prompt for your brand voice, changing the hashtags style, and increasing the Wait duration if LinkedIn assets aren’t ready in time.
Usually it’s expired credentials or missing scopes on your LinkedIn app. Regenerate the token, confirm you included w_member_social, then update the credentials used by the HTTP Request nodes that register the upload and publish the post. If it works sometimes and fails in batches, you may also be hitting LinkedIn rate limits, so spacing out executions helps.
A lot.
For this use case, n8n is typically a better fit because you’re doing multi-step API work (image generation, upload registration, binary conversion, then publishing). Zapier and Make can do it, but you often end up paying more as the steps and volume grow, and handling binary file uploads can get finicky. n8n also gives you a self-hosting route, which matters if you want unlimited runs without counting every task. If you just want “topic in, draft out” with minimal logic, Zapier or Make can be simpler. If you’re unsure, Talk to an automation expert and we’ll point you to the cleanest option.
Once this is running, LinkedIn stops being a weekly scramble. The workflow handles the repeatable parts, so you can focus on ideas and results.
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.