Skip to content

An intelligent social media automation tool that generates, validates, and publishes engaging content to LinkedIn and Twitter using AI. Built with LangGraph for workflow orchestration and powered by Google's Gemini AI.

Notifications You must be signed in to change notification settings

connect-abdullah/Automated-Post-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– Automated Social Media Post Bot

An intelligent social media automation tool that generates, validates, and publishes engaging content to LinkedIn and Twitter using AI. Built with LangGraph for workflow orchestration and powered by Google's Gemini AI.

๐ŸŒŸ Features

  • AI-Powered Content Generation: Creates engaging LinkedIn posts and Twitter threads
  • Smart Topic Generation: Generates diverse, thought-provoking tech topics
  • Content Validation: Automatically validates posts against platform-specific rules
  • Multi-Platform Publishing: Posts to both LinkedIn and Twitter simultaneously
  • Community Support: Posts to Twitter communities with follower sharing
  • Retry Logic: Automatically regenerates content if validation fails
  • Interactive Topic Selection: Human approval for generated topics

๐Ÿ”ง Tech Stack

  • Framework: LangGraph for workflow orchestration
  • AI Model: Google Gemini 2.0 Flash Lite
  • Language: Python 3.13+
  • APIs: LinkedIn API, Twitter API v2
  • Authentication: OAuth 1.0 (Twitter), Bearer Token (LinkedIn)

๐Ÿ“‹ Prerequisites

Required API Keys & Tokens

Create a .env file in the root directory with the following variables:

# Google Gemini API
GEMINI_API_KEY=your_gemini_api_key_here

# Twitter API Credentials
twitter_consumer_key=your_twitter_consumer_key
twitter_consumer_secret=your_twitter_consumer_secret
twitter_access_token=your_twitter_access_token
twitter_access_token_secret=your_twitter_access_token_secret
twitter_community=your_twitter_community_id (optional)

# LinkedIn API Credentials
linkedin_access_token=your_linkedin_access_token
linkedin_unv=your_linkedin_user_id

API Setup Instructions

1. Google Gemini API

  1. Go to Google AI Studio
  2. Create a new API key
  3. Add it to your .env file as GEMINI_API_KEY

2. Twitter API v2

  1. Apply for Twitter Developer Account at developer.twitter.com
  2. Create a new App with Read and Write permissions
  3. Generate API Keys and Access Tokens
  4. Add all credentials to your .env file
  5. (Optional) Get your community ID for community posting

3. LinkedIn API

  1. Create a LinkedIn App at LinkedIn Developers
  2. Request access to LinkedIn API
  3. Generate access token with w_member_social scope
  4. Get your LinkedIn User ID (URN format)
  5. Add credentials to your .env file

๐Ÿš€ Installation

  1. Clone the repository

    git clone <repository-url>
    cd ChatBot-LangGraph
  2. Create virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp .env.example .env
    # Edit .env with your API credentials

๐ŸŽฏ How It Works

Workflow Overview

Workflow Diagram

The bot follows a sophisticated workflow built with LangGraph that handles content generation, validation, and publishing across multiple platforms

Detailed Flow

  1. Topic Generation

    • AI generates unique, discussion-worthy tech topics
    • Human reviews and approves/rejects topics
    • Covers areas: Python, AI, Frontend, Backend, Automation, etc.
  2. Content Creation (Parallel)

    • LinkedIn: Professional, detailed posts with Unicode formatting
    • Twitter: Concise, engaging tweets (โ‰ค260 characters)
  3. Content Validation

    • LinkedIn Validator: Checks formatting, length, completeness
    • Twitter Validator: Verifies character limit, tone, engagement
  4. Publishing

    • LinkedIn: Posts to user's professional network
    • Twitter: Posts to timeline and optionally to communities
    • Fallback Logic: Attempts community + followers, falls back to community-only
  5. Confirmation

    • Reports success/failure status for both platforms
    • Provides final confirmation message

๐ŸŽฎ Usage

Basic Usage

# Activate virtual environment
source venv/bin/activate

# Run the bot
python main.py

Interactive Process

  1. Topic Selection: Review AI-generated topic and approve/reject
  2. Automatic Processing: Bot generates, validates, and posts content
  3. Results: See confirmation of successful posts

Example Output

----------
Topic: The "Frontend Fatigue" Paradox: Is the constant churn in JavaScript frameworks actually slowing down development velocity?

Do You Want To Select This Topic (Yes/No): yes

----------Topic Selected----------

๐Ÿ“ Trying to post to community: 1493446837214187523 (with followers)
โœ… Twitter Post created successfully!
โœ… LinkedIn Post created successfully!

Both posts successfully published ๐Ÿš€

๐Ÿ“ Content Guidelines

LinkedIn Posts

  • Professional tone with engaging headlines
  • Unicode bold formatting (๐—ฏ๐—ผ๐—น๐—ฑ ๐˜๐—ฒ๐˜…๐˜)
  • Bullet points with "->" format
  • โ‰ค600 tokens
  • Discussion-worthy insights

Twitter Posts

  • Concise and engaging (โ‰ค260 characters)
  • Sarcastic, educational, or thought-provoking styles
  • Bullet points with "->" format
  • Relevant emojis only
  • Max 1 hashtag

๐Ÿ”ง Configuration

Customization Options

  • Iteration Limits: Modify total_linkedin_iterations and total_twitter_iterations
  • Temperature: Adjust AI creativity in topic generation
  • Specialties: Update the specialties list in gen_topic()
  • Validation Rules: Modify validation criteria in respective functions

File Structure

ChatBot-LangGraph/
โ”œโ”€โ”€ main.py              # Main workflow orchestration
โ”œโ”€โ”€ linkedin.py          # LinkedIn API integration
โ”œโ”€โ”€ twitter.py           # Twitter API integration
โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”œโ”€โ”€ .env                # Environment variables (create this)
โ”œโ”€โ”€ .gitignore          # Git ignore patterns
โ””โ”€โ”€ README.md           # This file

๐Ÿ› Troubleshooting

Common Issues

  1. 403 Forbidden Errors

    • Check API permissions and scopes
    • Verify access tokens are valid
    • Ensure app has read/write permissions
  2. 429 Rate Limit Errors

    • Twitter API has posting limits (300 tweets per 15 minutes)
    • Wait 15 minutes before trying again
    • Consider upgrading to higher API tier for increased limits
  3. Topic Repetition

    • AI generates similar topics due to low temperature
    • Restart the script for fresh context
  4. Validation Failures

    • Content doesn't meet platform guidelines
    • Bot will retry up to 5 times per platform
  5. Module Not Found

    • Ensure virtual environment is activated
    • Run pip install -r requirements.txt

Debug Mode

Enable detailed logging by uncommenting debug print statements in twitter.py and linkedin.py.

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

โš ๏ธ Disclaimer

  • Ensure compliance with platform terms of service
  • Monitor API usage to avoid rate limits
  • Review generated content before publishing
  • Use responsibly and ethically

๐Ÿ†˜ Support

If you encounter issues:

  1. Check the troubleshooting section
  2. Verify your API credentials
  3. Review the logs for error messages
  4. Open an issue with detailed error information

Happy Posting! ๐Ÿš€

About

An intelligent social media automation tool that generates, validates, and publishes engaging content to LinkedIn and Twitter using AI. Built with LangGraph for workflow orchestration and powered by Google's Gemini AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages