AI social media automation agent
A free, local-first AI social media agent** that researches a topic, drafts a post, critiques it, and delivers a polished, ready-to-publish caption.
- Tech: Python, LangGraph, LangChain (Gemini), DuckDuckGo Search
- Use‑case: Quickly generate high‑quality social posts with an agentic workflow
- Cost: You only pay for your own Gemini API usage (no extra SaaS)
- Agentic workflow –
Search → Draft → Review → Finalize - Web research – pulls fresh context from DuckDuckGo
- LLM-powered writin
g – uses Gemini Flash via langchain-google-genai
- Automatic critique + rewrite – improves tone, clarity, engagement, and hashtags
- Portfolio-friendly – saves the final caption to
final_post.mdfor easy sharing
-
Search
Uses
duckduckgo-searchto gather short snippets about your topic. -
Draft
Calls Gemini (via
ChatGoogleGenerativeAI) to generate the first version of the post. -
Review
Asks Gemini to critique the draft for engagement, clarity, and hashtag usage.
-
Finalize
Rewrites the post using the critique and writes the result to
final_post.md.
You interact with it from the terminal by providing just one input: the topic.
git clone https://github.com/Aaryankansari/ai-social-media-agent.git
cd ai-social-media-agentCreate a .env file in the project root:
GOOGLE_API_KEY=your-google-api-key-hereMake sure this API key has access to the Gemini models.
pip install -r requirements.txtFrom the project root:
python main.pyYou’ll be prompted for a topic, for example:
Enter a topic for the social media post: agentic AI for creators
The script will:
- Research the topic
- Write an initial draft
- Critique and improve it
- Print the result in the terminal and save it to
final_post.md
final_post.md is ignored by git so generated content doesn’t clutter your commits.
Python 3.10+langgraphlangchain-google-genaiduckduckgo-searchpython-dotenv
- Add platform-specific styles (X, LinkedIn, Instagram, TikTok)
- Schedule posts or send them to a social media API
- Store past posts and topics in a database for reuse and analytics
Feel free to fork this, experiment with prompts, or open issues/PRs with suggestions.