Somewhere between debugging OAuth errors at midnight and watching a bot post better LinkedIn content than most humans I know, I realized I'd accidentally built something genuinely useful.
This is the story of how I built a fully automated LinkedIn posting agent from scratch — zero dollars spent, zero manual effort after setup, running daily on its own. It finds real trending topics, writes a human-sounding post, generates a banner image, and publishes it to LinkedIn while I sleep. No subscription. No paid APIs. Just free-tier tools duct-taped together in the best way possible.
The Problem With "Just Post Consistently"
Everyone tells you to post consistently on LinkedIn. Nobody tells you how exhausting that actually is. Coming up with a topic, writing something that doesn't sound like a press release, finding an image, posting at the right time — it's a part-time job on top of your actual job.
I wanted to automate the whole thing. Not with some $50/month SaaS tool. From scratch, with code, for free.
The Stack (All Free, No Credit Card Required)
Before getting into the how, here's what the whole thing runs on:
- Gemini 2.5 Flash via Google AI Studio — the brain of the operation
- NewsAPI — pulls real trending headlines in my niche every day
- Stability AI — generates the banner image (25 free credits/day)
- LinkedIn API — publishes the actual post
- GitHub Actions — runs the whole thing on a cron schedule daily
Total cost: genuinely zero. The kind of zero that doesn't secretly become $20 next month.
How It Actually Works
The pipeline is straightforward once you see it laid out:
- GitHub Actions wakes up every morning at 10 AM
- The script hits NewsAPI for the top 5 headlines in my niche from the last 24 hours
- Gemini reads those headlines and picks the single most interesting topic
- Gemini then writes a full LinkedIn post about that topic — hook, insights, hashtags, CTA
- A second Gemini call writes a detailed image generation prompt (this part matters a lot — more on that in a second)
- Stability AI takes that prompt and generates a 16:9 banner
- The image uploads to LinkedIn, the post goes live
The whole thing runs in under 90 seconds. No human involved.
The Part That Actually Took Time: LinkedIn OAuth
I want to be honest — the hardest part of this entire build was not the AI stuff. It was LinkedIn's OAuth flow.
LinkedIn's documentation is... generous in what it leaves out. A few things that burned me:
- The
r_liteprofilescope is completely deprecated. Don't use it. Useopenid,profile,email, andw_member_socialinstead. - When exchanging your auth code for an access token, the request body must be
x-www-form-urlencoded. If you useform-data(the Postman default), you'll get a crypticinvalid_clienterror and spend two hours questioning your life choices. - Your app needs the "Share on LinkedIn" and "Sign In with LinkedIn using OpenID Connect" products enabled from the Products tab — not just the scopes.
Once those three things clicked, everything else was smooth.
The Image Problem (And How Gemini Fixed It)
Early versions of this used a generic prompt sent directly to Stability AI. The results were... creative. One image had a monitor displaying the text "Drawer Bortetdter Bomicks" in a very confident font. Not ideal for a professional post.
The fix was adding a middle step: ask Gemini to write the image prompt first. Gemini gets the topic, understands the context, and writes a detailed prompt that explicitly says things like "NO text, NO words, NO letters, abstract geometric shapes, navy blue and teal palette." Stability AI follows a well-written prompt dramatically better than a vague one.
That one change went from embarrassing to actually post-worthy. 🎨
What I Learned Building This
A few things worth taking away from this:
- Free-tier tools can compose into genuinely powerful systems. Gemini Flash, NewsAPI free tier, Stability AI's daily credits, and GitHub Actions together cover a surprisingly full automation stack.
- The AI part is often the easiest part. It's the plumbing — OAuth, API quirks, encoding formats — that eats your time.
- Prompting for image generation is a real skill. Vague prompts get weird results. Specific, negative-prompt-heavy prompts get professional results.
- Build dry-run modes early. Being able to preview the post and image before it goes live saved me from posting some genuinely terrible content during testing.
The Takeaway
If you've been meaning to build something with AI APIs but felt intimidated, this kind of project is the perfect starting point. It's real automation, real APIs, real results — and the hardest bugs are the boring ones, not the AI ones.
I do freelance web development and build tools like this for clients too — if you're curious about what's possible, you can check out my work at hire-sam.vercel.app.
Save this if it was useful — I'll be writing more about building practical AI tools without spending money.





Top comments (0)