Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn AI Agent

Semi-automated LinkedIn growth OS — human-in-the-loop, zero ban risk, 100% free.

What It Does

Feature How It Works Ban Risk
Smart Posting Raw idea → AI polishes + generates Forbes-style image → You approve → Posted at peak times ✅ Zero
Trending Comments Discovers trending posts → AI drafts comment → You approve → Posted via official API ✅ Zero
Auto Reply Drafts New comments on your posts → AI drafts replies → You approve via Telegram ✅ Zero
Networking Intelligence Tracks every interaction → scores leads → suggests personalized connection requests ✅ Zero
Autonomous Growth Loop 11 agents run 24/7 discovering trends, opportunities, and content gaps ✅ Zero

Everything uses the official LinkedIn API. No scraping, no browser automation.


Architecture

You (Telegram)
      │
      ▼
Telegram Bot (main.py)
      │
      ├── Ollama (local LLM) ─────── post enhancement, comments, replies
      ├── Dreamshaper 8 ──────────── Forbes-style image generation (~35s)
      ├── Trending Discovery ─────── web search for LinkedIn posts
      ├── Scheduler ──────────────── peak-time post publishing
      │
      └── Growth OS (main_v2.py)
           ├── PostgreSQL ─── persistent data
           ├── Redis ──────── event bus
           ├── Neo4j ──────── relationship graph
           ├── Qdrant ─────── vector memory
           └── 11 Agents ──── Trend, Prediction, Content, Comment,
                              Network, Founder, Research, Analytics,
                              Learning, Opportunity, Connection

Complete Setup Guide

Prerequisites

Tool Purpose Install
Python 3.11+ Runtime python.org
Docker Desktop PostgreSQL, Redis, Neo4j, Qdrant docker.com
Ollama Local AI model ollama.com
Telegram Bot Token Chat interface Free via @BotFather
LinkedIn Developer App Official API access developer.linkedin.com

Step 1 — Clone & Create Virtual Environment

cd linkedin-ai-agent
python3.11 -m venv venv
source venv/bin/activate          # macOS/Linux
# venv\Scripts\activate           # Windows

Step 2 — Install Dependencies

pip install -r requirements.txt
pip install asyncpg "redis[asyncio]" neo4j qdrant-client openai anthropic

Step 3 — Start Docker Services

Make sure Docker Desktop is running, then:

docker compose up -d

This starts:

Service Port Purpose
PostgreSQL 5433 Main database
Redis 6379 Event bus & cache
Neo4j 7474 / 7687 Relationship graph
Qdrant 6333 Vector memory

Verify all are healthy:

docker compose ps

All 4 services should show healthy.

Note: PostgreSQL runs on port 5433 (not 5432) to avoid conflicts with any local PostgreSQL installation.


Step 4 — Start Ollama & Pull Model

# macOS
brew install ollama

# Linux
curl -fsSL https://ollama.com/install.sh | sh

# Start and pull model
ollama serve
ollama pull llama3.1:8b

Step 5 — Create a Telegram Bot

  1. Open Telegram → search @BotFather
  2. Send /newbot → choose a name and username
  3. Copy the Bot Token you receive
  4. Open a chat with your new bot → send /start
  5. Visit https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  6. Look for "chat":{"id": — that number is your Chat ID

Step 6 — Create a LinkedIn Developer App

  1. Go to linkedin.com/developers/apps → Create App
  2. Fill in app name, LinkedIn Page, Privacy Policy URL (http://localhost:8080/privacy), logo
  3. In the Auth tab:
    • Add redirect URL: http://localhost:8080/callback
    • Copy Client ID and Client Secret
  4. In the Products tab, request access to:
    • Share on LinkedIn
    • Sign In with LinkedIn using OpenID Connect

Step 7 — Configure .env

Copy the template and fill in your values:

cp env.example .env

Edit .env with your actual values:

# ── Required ──────────────────────────────────────────────
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_telegram_chat_id
LINKEDIN_CLIENT_ID=your_linkedin_client_id
LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret
LINKEDIN_REDIRECT_URI=http://localhost:8080/callback

# ── Ollama ────────────────────────────────────────────────
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b

# ── Your niche (used for trending discovery) ──────────────
TRENDING_NICHE=AI, technology, startups, career growth

# ── Scheduling (your timezone peak times) ─────────────────
PEAK_TIMES_UTC=08:15,12:00,17:30
TIMEZONE=Asia/Calcutta

# ── Growth OS (full stack) ────────────────────────────────
MODE=growth_os
POSTGRES_URL=postgresql://growth_os:password@localhost:5433/linkedin_growth_os
REDIS_URL=redis://:password@localhost:6379/0
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
QDRANT_URL=http://localhost:6333

# ── Optional cloud LLMs (leave blank to use Ollama only) ──
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GEMINI_API_KEY=

Step 8 — LinkedIn OAuth (run once)

source venv/bin/activate
python main.py auth

This will:

  1. Open your browser to the LinkedIn authorization page
  2. After you approve, automatically save your access token and Person URN to .env

Tokens expire after ~60 days. Re-run python main.py auth when you get a 401 error.


Step 9 — Run the Project

Open two separate terminal tabs.

Terminal 1 — Telegram Bot:

cd linkedin-ai-agent
source venv/bin/activate
python main.py

Wait until you see:

LIVE! Open Telegram and talk to your bot.

Terminal 2 — Growth OS Agents (after Terminal 1 is fully started):

cd linkedin-ai-agent
source venv/bin/activate
python main_v2.py

Wait until you see:

Growth OS LIVE — 11 agents running autonomously.

Step 10 — Open Telegram

Send /start to your bot. You'll see the full command menu.


All Telegram Commands

Command What It Does
/post Create a LinkedIn post with AI enhancement + image
/trending Discover trending posts + draft comments
/replies Review & reply to comments on your posts
/manualreply Paste any comment → AI drafts reply
/schedule View scheduled posts
/connections Your network by tier (Inner Circle / High Value / Influencers)
/leads Top targets ranked by score + draft connection requests
/watchlist [Name] Monitor specific people
/network Overall networking growth stats
/brandmemory Your personal brand: mission, values, writing style
/opportunities Podcasts, hackathons & speaking gigs
/competitors Competitor analysis + content gaps
/insights Learning loop: best comment modes
/addnote Topic | Content Save insight for AI to use in comments
/clearmemory Reset seen-post history
/status Today's action counts
/config Show current configuration

Stopping the Project

# Stop both Python processes
Ctrl+C in each terminal

# Stop Docker services (keeps data)
docker compose stop

# Stop Docker and remove all data (full reset)
docker compose down -v

Important: Always use Ctrl+C to stop main.py and wait for it to fully exit before restarting. Starting a second instance while one is running causes a Telegram 409 Conflict error.


Troubleshooting

Error Fix
Ollama not running Run ollama serve
Model not found Run ollama pull llama3.1:8b
LinkedIn API 401 Run python main.py auth
Telegram 409 Conflict Another bot instance is running. Run pkill -9 -f "python main.py", wait 5s, restart
PostgreSQL: role does not exist Check POSTGRES_URL uses port 5433, run docker compose ps
asyncpg not found Run pip install asyncpg inside the activated venv
No posts in /trending Run /clearmemory then /trending again
Image generation slow (~35s) Normal on Apple Silicon MPS — cached after first load
Neo4j browser UI Open localhost:7474 — user: neo4j, password: password
docker compose ps shows unhealthy Run docker compose logs <service> to see the error

Project Structure

linkedin-ai-agent/
│
├── main.py                    # Telegram bot + LinkedIn OAuth
├── main_v2.py                 # Growth OS autonomous agents
│
├── telegram_bot.py            # All commands and button handlers
├── scheduler.py               # Peak-time post publisher
├── comment_manager.py         # Auto-reply to comments
├── trending_discovery.py      # Trending post discovery
├── image_generator_local.py   # Dreamshaper 8 + Forbes text overlay
├── linkedin_client.py         # Official LinkedIn API
├── ollama_client.py           # Local LLM inference
├── database.py                # SQLite (legacy/fallback)
├── config.py                  # All settings from .env
│
├── core/                      # Growth OS infrastructure
│   ├── database_v2.py         # PostgreSQL async layer
│   ├── redis_client.py        # Redis async client
│   ├── event_bus.py           # Redis PubSub event bus
│   ├── llm_router.py          # Multi-LLM router
│   ├── master_coordinator.py  # Agent orchestrator
│   └── growth_loop.py         # 24/7 autonomous loop
│
├── agents/                    # 11 specialized agents
│   ├── trend_agent.py
│   ├── prediction_agent.py
│   ├── content_agent.py
│   ├── comment_agent.py
│   ├── network_agent.py
│   ├── founder_agent.py
│   ├── research_agent.py
│   ├── analytics_agent.py
│   ├── learning_agent.py
│   ├── opportunity_agent.py
│   └── connection_agent.py
│
├── docker-compose.yml         # PostgreSQL, Redis, Neo4j, Qdrant
├── requirements.txt
├── env.example                # Config template → copy to .env
└── .gitignore

Cost Breakdown

Service Cost
Ollama (local LLM) Free
Dreamshaper 8 (local image gen) Free
Telegram Bot API Free
LinkedIn Developer API Free
PostgreSQL / Redis / Neo4j / Qdrant (Docker) Free
Total $0/month

License

MIT — Use freely, modify as needed, no warranty implied.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages