LinkedIn Connection Agent
Fetches LinkedIn connection request results from a PhantomBuster agent, calculates acceptance metrics, and stores analytics in the database. Runs as a daily cron job via Modal.
What It Does
- Calls PhantomBuster API to get latest LinkedIn connection results
- Downloads structured JSON profile data from S3
- Calculates metrics: total sent, accepted, pending, acceptance rate
- Stores aggregate stats and individual profiles in
linkedin_agent_datatable - Tracks status changes (e.g., "Invitation sent" → "Request accepted")
How to Run
Local
# View analytics only
python3 skills/linkedin-connection-agent/scripts/linkedin_connection_agent.py --analytics
# Store results in database
python3 skills/linkedin-connection-agent/scripts/linkedin_connection_agent.py --analytics --store
Modal Cron (Daily at 6 PM EST / 11 PM UTC)
modal deploy skills/linkedin-connection-agent/scripts/modal_linkedin_connections.py
modal run skills/linkedin-connection-agent/scripts/modal_linkedin_connections.py
Configuration
Environment Variables
PHANTOMBUSTER_API_KEY=xxx
PHANTOMBUSTER_AGENT_ID=685897070795556 # LinkedIn connections agent
DATABASE_URL=postgresql://...
Dependencies
pip install requests psycopg2-binary python-dotenv
Metrics Parsing (Important)
- total_sent = profiles with
invitationDate(we sent them an invite) - total_accepted = profiles with
status = "Request accepted" - pending = profiles with
status = "Invitation sent" - acceptance_rate = total_accepted / total_sent × 100
Do NOT count "Already connected" as accepted — those are pre-existing connections.
Important Notes
- PhantomBuster daily limit: 20 connection requests
- Agent ID
685897070795556is required — it's the specific LinkedIn connections agent - Individual profiles tracked by unique
linkedin_urlfor status updates - Aggregate stats stored daily for trend tracking
Scripts
| File | Purpose |
|---|---|
linkedin_connection_agent.py |
Local analytics script |
modal_linkedin_connections.py |
Modal cron deployment |