Skip to content

Latest commit

Β 

History

20 Commits

Folders and files

Repository files navigation

LinkedIn AI Post Automation

GitHub stars GitHub forks License Python Status

A polished AI-powered automation system that discovers fresh tech and AI trends, writes engaging LinkedIn posts, generates matching visuals, publishes them automatically, and tracks the workflow with logs and notifications.

Table of Contents

Overview

This project combines modern AI APIs, automation workflows, and social media publishing into a single, practical solution for building a daily LinkedIn presence without manual effort. It is designed for developers, creators, and professionals who want to share thought leadership content consistently.

What it does

  • Finds current AI and technology topics from live web sources
  • Writes a concise, high-quality LinkedIn post
  • Generates a matching image prompt and visual
  • Publishes the content to LinkedIn
  • Logs the activity and notifies the owner by email

Why This Project Exists

Creating consistent content on LinkedIn can be time-consuming, especially when balancing research, writing, ideation, and publishing. This project removes that friction by automating the end-to-end workflow so users can focus on strategy while the system handles execution.

It is also a strong portfolio project because it brings together:

  • API integrations
  • automation and scheduling
  • secure environment configuration
  • external service orchestration
  • practical deployment readiness

Features

  • πŸ€– Smart topic discovery using real-time search data
  • ✍️ AI-generated LinkedIn post content with quality checks
  • πŸ–ΌοΈ Visual asset generation for more engaging posts
  • πŸ” Duplicate prevention through Google Sheets tracking
  • πŸ“§ Email alerts for success or failure cases
  • βš™οΈ Scheduled execution using local automation or GitHub Actions
  • πŸ” Secure configuration via environment variables

Tech Stack

  • 🐍 Python 3.13+
  • πŸ€– Groq Cloud API for post generation and scoring
  • πŸ”Ž Tavily API for live topic discovery and research
  • 🎨 Pollinations.AI for image generation
  • πŸ’Ό LinkedIn API for publishing posts
  • πŸ“Š Google Sheets API for logging and duplicate detection
  • βœ‰οΈ Gmail SMTP for email notifications
  • 🧰 GitHub Actions for automation workflows
  • πŸ“¦ python-dotenv, requests, schedule, gspread, google-auth

Architecture

graph TD
    subgraph Trigger
        Cron[GitHub Actions Cron / Local Daemon]
    end

    subgraph Config & Environment
        Env[".env File (Secrets & Config)"] --> Config[config.py Loader & Validator]
    end

    subgraph Core Automation Flow [main.py]
        Start([Start Daily Workflow])
        Discovery[1. Topic Discovery<br/>Tavily News Search]
        DupCheck[2. Duplicate Check<br/>Read Column A]
        Research[3. Deep Research<br/>Tavily Advanced Search]
        GenPost[4. Post Generation<br/>Groq Llama-3.3-70B]
        QualityCheck[5. Quality Evaluator<br/>Groq low-temp scoring]
        GenPrompt[6. Custom Image Prompt<br/>Groq context generation]
        GenImage[7. Image Generation<br/>Pollinations.AI Flux API]
        UploadImage[8. Initialize & Upload Image<br/>LinkedIn Images API]
        PublishPost[9. Publish Post with Image<br/>LinkedIn Posts API]
        LogRun[10. Append Log Row<br/>Google Sheets]
        Notify[11. Email Alert<br/>Gmail SMTP SSL]
    end

    subgraph External APIs & Services
        TavilyAPI[(Tavily AI API)]
        SheetsAPI[(Google Sheets API)]
        GroqAPI[(Groq Cloud API)]
        PollinationsAPI[(Pollinations.AI)]
        LinkedinAPI[(LinkedIn API)]
        GmailSMTP[(Gmail SMTP Server)]
    end

    Cron --> Start
    Config -.-> Start

    Start --> Discovery
    Discovery <-->|Fetch random trending news| TavilyAPI

    Discovery --> DupCheck
    DupCheck <-->|Query check dates| SheetsAPI

    DupCheck -->|Already Posted| Skip[Skip & Exit]
    DupCheck -->|Not Posted| Research

    Research <-->|Fetch deep article summary| TavilyAPI

    Research --> GenPost
    GenPost <-->|Prompt with research| GroqAPI

    GenPost --> QualityCheck
    QualityCheck <-->|Grade 1-10| GroqAPI

    QualityCheck -->|Score < Min Score| GenPost
    QualityCheck -->|Score >= Min Score| GenPrompt

    GenPrompt <-->|Generate visual prompt| GroqAPI

    GenPrompt --> GenImage
    GenImage <-->|Fetch Flux image bytes| PollinationsAPI

    GenImage --> UploadImage
    UploadImage <-->|Upload image bytes| LinkedinAPI

    UploadImage --> PublishPost
    PublishPost <-->|Post commentary & image asset| LinkedinAPI

    PublishPost --> LogRun
    LogRun --->|Log Success Status| SheetsAPI

    LogRun --> Notify
    Notify --->|Send Status Report| GmailSMTP

    Notify --> End([End Workflow])
Loading

Project Structure

linkedin-automation/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── linkedin-post.yml
β”œβ”€β”€ credentials/
β”œβ”€β”€ logs/
β”œβ”€β”€ config.py
β”œβ”€β”€ get_linkedin_token.py
β”œβ”€β”€ main.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
β”œβ”€β”€ LICENSE
└── README.md

Installation

1. Clone the repository

git clone https://github.com/your-username/linkedin-automation.git
cd linkedin-automation

2. Create a virtual environment

python -m venv .venv
source .venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

cp .env.example .env

Then fill in the required values in the .env file.

5. Add your Google credentials

Place your Google Service Account JSON file inside the credentials/ folder and point GOOGLE_CREDENTIALS_FILE to it.

Environment Variables

Example configuration:

GROQ_API_KEY=your_groq_key
TAVILY_API_KEY=your_tavily_key
POLLINATIONS_API_KEY=your_pollinations_key
LINKEDIN_ACCESS_TOKEN=your_linkedin_token
LINKEDIN_PERSON_URN=your_linkedin_person_urn
LINKEDIN_CLIENT_ID=your_client_id
LINKEDIN_CLIENT_SECRET=your_client_secret
GOOGLE_SHEET_ID=your_google_sheet_id
GOOGLE_CREDENTIALS_FILE=credentials/your-service-account.json
SHEET_NAME=Posts
GMAIL_SENDER=you@example.com
GMAIL_RECEIVER=you@example.com
GMAIL_APP_PASSWORD=your_app_password
POST_TIME=10:00
MAX_RETRIES=3
QUALITY_MIN_SCORE=6

Usage

Run once immediately

python main.py --now

Run on a schedule

python main.py

Generate a LinkedIn access token

python get_linkedin_token.py

This project does not expose a public REST API. It runs as an automation script locally or via GitHub Actions.

Suggested demo items:

  • Workflow execution logs
  • Sample generated LinkedIn post
  • Example image output
  • Google Sheets tracking view

Roadmap

Planned improvements include:

  • 🧠 Better post personalization based on user profile or niche
  • πŸ“ˆ Analytics dashboard for post performance
  • πŸ—‚οΈ Support for multiple social platforms
  • πŸ§ͺ Automated tests and CI validation
  • ☁️ Dockerized deployment for easier hosting

Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Open a pull request

Please keep the code clean, document new features clearly, and follow the existing project style.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

Special thanks to the teams and services behind:

  • Groq
  • Tavily
  • Pollinations.AI
  • Google Sheets API
  • LinkedIn API
  • GitHub Actions

Built with the goal of making AI-driven content automation practical, professional, and accessible.

About

A fully automated Python system that researches trending topics daily, generates high-quality LinkedIn posts with matching AI-generated images, publishes them directly to LinkedIn, logs actions to Google Sheets, and sends email notifications upon completion.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages