- Build With Petar
- Posts
- I Built an Autonomous Social Media Agent for $0.01/Month
I Built an Autonomous Social Media Agent for $0.01/Month
No manager, no templates, no manual work. Just one Python script and a cron job.
I run a niche SaaS product. It has a small audience and a very specific market. While it’s successful in its own right, I simply don’t have the time to be a social media manager-and I certainly can’t justify paying one for a product that generates a few hundred euros a month.
So, I built an agent to do it for me.
Every Monday at 8:00 AM, it pulls live data from my production database, writes posts, generates branded images, and publishes them to Facebook and Instagram. I don’t touch a thing.
Total monthly cost: about one cent.
Here is exactly how I built it.
The Problem
I know social media matters. I know consistency matters even more. But my typical week is consumed by fixing bugs, shipping features, and handling support.
Usually, around Thursday, I’d realize I hadn't posted anything. I’d open Canva, stare at a blank screen for 10 minutes, get frustrated, and tell myself I’d "do it next week."
Meanwhile, my users were active-signing up, searching for items, and building playlists. I had zero social presence to highlight that growth. I didn't need a scheduling tool; I needed a system.
The Research
In 2026, the automation landscape is crowded. I spent a day vetting the options:
For posting: Meta Graph API (Free), Buffer/Hootsuite ($6-$49/mo), or Playwright automation (Free but risky).
For images: DALL-E/Midjourney (AI-generated), Canva API ($13/mo), or HTML templates + Playwright (Free).
For orchestration: n8n/Make.com (Visual tools), CrewAI/LangGraph (Agent frameworks), or a Python script + Cron (The "keep it simple" route).
I chose the simplest, cheapest option at every single fork in the road.
The Architecture
The stack is lean and mean:
Cron (Monday 8:00 CET)
→ Python script
→ SSH to VPS → query SQLite for real analytics
→ Claude Haiku API → generate 5 posts
→ Playwright → render HTML templates to PNG
→ Meta Graph API → publish to Facebook + Instagram
One script. One cron job. No third-party middlemen.
Decision 1: How to Post
The Meta Graph API was the winner. It’s free, official (zero risk of bans), and offers permanent tokens.
The Instagram Gotcha: Instagram requires images to be hosted at a publicly accessible URL. You can't just upload a local file.
I solved this by SCP-ing images to my VPS and serving them via Caddy. I added these 4 lines to my config:
Code snippet
@social path /social/*
handle @social {
root * /opt/app/social-assets
file_server
}
Note: Ensure this handler appears before any catch-all routes like SvelteKit.
Decision 2: Why I Rejected AI Images
Everyone is using DALL-E or Flux right now, but I rejected them for one reason: Text.
AI generators still struggle with reliability, especially with non-Latin text.
Instead, I used HTML templates rendered via Playwright:
Design 5 HTML types (stat cards, item spotlights, etc.).
Use CSS for branding (dark theme, teal accents).
Claude fills the variables; Playwright takes the 1080x1080px screenshot.
The result? Pixel-perfect, brand-consistent, and 100% free.
Decision 3: Brains for $0.01
I use Claude Haiku. It’s the smallest, fastest model from Anthropic. For 5 posts a week, the cost is effectively rounding error.
The magic is in the prompt. I provide:
Real Data: User counts and trending items from my SQLite DB.
Brand Voice: "Write like a colleague, no jargon."
JSON Specs: The exact structure needed for the HTML templates.
The Content Strategy
The agent populates five specific templates every week:
Template | Purpose | Dynamic Data |
Stat Post | Highlighting growth | Numbers, subtitles, context |
Item Spotlight | Featured content | Item title, artist, lyric snippet |
Comparison | Before/After | Split-screen text panels |
Quote/Story | Narrative engagement | Story text, attribution |
CTA | Conversion | Headline, button text |
The Results
The system has been live for a week. On its first autonomous run:
5 posts generated (highlighting 69 new users).
5 branded images rendered in <30 seconds.
Published to FB and IG perfectly.
Total Cost: < $0.01.
What’s Next?
While it works, I’m already looking at improvements:
Engagement Feedback: Feeding likes/comments back into Claude so it learns what "hits."
Stories: Wiring up the Instagram Stories API.
Human-in-the-loop: Adding a 30-minute Slack window to "vet" posts before they go live.
The Takeaway
The "teenager stack" (ChatGPT + Canva + Buffer) is fine if you have time. But if you want true autonomy, you have to go one level deeper. The official APIs are free, and a cron job is still the most reliable scheduler ever built.
Sometimes, the best architecture is the simplest one.
I'm Petar Jovanovic founder of AI-native agency where we build niche SaaS products for underserved markets. If you want to dive into the code or build something similar, feel free to reach out!