Reddit DM automation CLI using Popsy AI for lead generation and outreach
Project description
Reddit DM Automation - Unified API & Browser Integration
What You Need:
- MacBook with macOS 10.15 or newer
- Reddit account
- Popsy API token
- 30 minutes for setup
Step 1: Install Python 3.11.9
Check if you have Python:
python3 --version
If you don't have Python 3.11.9, install it:
# Install Homebrew first (copy and paste this whole line)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python 3.11.9
brew install python@3.11
Step 2: Install Required Software
# Install the required libraries
pip3 install requests "camoufox[geoip]" browserforge
# Download the special browser (this takes a few minutes)
python3 -m camoufox fetch
Step 3: Unzip and go to the folder
# Go to the folder
cd reddit-automation
Step 4: Get Your API Token
- Login to Popsy Dashboard
- Get your API token from settings
- Set environment variable:
export POPSY_API_TOKEN="your-token-here"
Or create a config file:
# Create config.json
{
"token": "your-api-token-here",
"base_url": "https://app.popsy.ai",
"min_relevancy": 10,
"max_threads": 5,
"show_new": false,
"hide_already_dmed": true,
"sort_by": "most_relevant"
}
Step 5: Test the Connection (NEW Unified CLI)
# Test with simulation mode (no actual DMs sent)
python3 main.py --dry-run --verbose --min-relevancy 80
# Test with detailed debugging
python3 main.py --debug --dry-run --show-new
Step 6: Choose Your Automation Mode
๐น API Simulation Mode (Default - Safe Testing)
# Basic simulation - see what would happen
python3 main.py --dry-run --verbose
# Live simulation with API tracking
python3 main.py --min-relevancy 80 --max-threads 3
๐น Live Browser Automation (Real DM Sending)
# Live browser automation with visible browser
python3 main.py --browser --min-relevancy 80 --max-threads 3
# Headless browser automation (background)
python3 main.py --browser --headless --min-relevancy 9 --max-threads 2
๐ New Advanced Features:
Smart Configuration Management
- Precedence: CLI arguments โ config.json โ defaults
- Verbose mode: See exactly what configuration is being used
- Debug mode: Full API request/response logging
# See all configuration details
python3 main.py --verbose --dry-run
# Debug API calls and responses
python3 main.py --debug --dry-run
Flexible Thread Filtering
# Include new threads (default: false)
python3 main.py --show-new --verbose
# Hide threads from already-DMed authors (default: true)
python3 main.py --hide-already-dmed
# Show threads from already-DMed authors
python3 main.py --show-already-dmed
# Sort by relevance or recency
python3 main.py --sort-by most_relevant
python3 main.py --sort-by most_recent
Multiple Processing Modes
# DM mode (default)
python3 main.py --mode dm --browser
# Comment mode (simulation only)
python3 main.py --mode comment --dry-run
Daily Use Examples:
Conservative Automation (Recommended)
# High-quality leads only, visible browser
python3 main.py --browser --min-relevancy 90 --max-threads 3 --verbose
Testing New Filters
# Test different relevancy thresholds
python3 main.py --dry-run --min-relevancy 60 --show-new --verbose
# Test specific subreddit
python3 main.py --subreddit-id 123 --dry-run --debug
Bulk Processing (Advanced Users)
# Background automation with higher volume
python3 main.py --browser --headless --min-relevancy 80 --max-threads 10
๐ Complete Configuration Options:
Core Settings:
--token: Your Popsy API authentication token--base-url: API base URL (default: https://app.popsy.ai)--config: Configuration file path (default: config.json)
Thread Filtering:
--min-relevancy: Minimum relevancy score 1-10 (default: 7)--max-threads: Maximum threads to process (default: 100)--subreddit-id: Filter by specific subreddit ID--page-size: Threads per API page (default: 50)--sort-by: Sort by 'most_relevant' or 'most_recent' (default: most_recent)
Thread Type Filters:
--show-new: Include new threads (default: false)--show-closed: Include closed threads (default: false)--show-deleted: Include deleted threads (default: false)--hide-already-dmed: Hide previously contacted authors (default: true)--show-already-dmed: Override hide setting
Processing Mode:
--mode: Choose 'dm' or 'comment' processing (default: dm)--dry-run: Test without sending actual DMs/comments
Browser Automation:
--browser/--live: Use live browser automation (requires camoufox)--headless: Run browser in background mode--browser-delay: Custom delay between actions (seconds)
Debugging & Logging:
--verbose/-v: Show detailed configuration and processing info--debug: Enable full API request/response logging
File Structure:
reddit-dm-tool/
โโโ main.py # ๐ Unified CLI interface
โโโ api.py # Core API client library
โโโ dm_automation.py # Browser automation library
โโโ config.json # Your configuration
โโโ logs/
โ โโโ api_client_YYYY-MM-DD.log
โ โโโ sent_messages_YYYY-MM-DD.csv
โ โโโ sent_comments_YYYY-MM-DD.csv
โโโ browser_data/ # Persistent browser session
๐ Enhanced Features:
Smart Configuration Display
python3 main.py --verbose --dry-run
Shows:
- โ Command line arguments you used
- โ Configuration file values loaded
- โ Environment variables detected
- โ Effective values after precedence resolution
Robust Error Handling
- โ API response validation (handles different response formats)
- โ Browser dependency checking (graceful fallback if camoufox not installed)
- โ Configuration validation (ensures compatible settings)
Flexible Automation
- โ Simulation mode: Test with API tracking but no actual sends
- โ Browser mode: Live DM sending with real browser
- โ Headless mode: Background automation for scheduled runs
Configuration Examples:
Conservative Setup (config.json)
{
"token": "your-token-here",
"base_url": "https://app.popsy.ai",
"min_relevancy": 90,
"max_threads": 3,
"show_new": false,
"hide_already_dmed": true,
"sort_by": "most_relevant"
}
Testing Setup (config.json)
{
"token": "your-token-here",
"min_relevancy": 60,
"max_threads": 10,
"show_new": true,
"hide_already_dmed": false,
"sort_by": "most_recent"
}
Troubleshooting:
๐ง Browser Issues:
python3 -m camoufox remove
python3 -m camoufox fetch
๐ง Configuration Issues:
# See what configuration is actually being used
python3 main.py --verbose --dry-run
# Debug API communication
python3 main.py --debug --dry-run
๐ง No threads found?
- Check your API token is valid:
--debugshows request details - Lower the
--min-relevancyscore - Try
--show-newto include new threads - Use
--show-already-dmedto see previously contacted authors - Verify you have tracked subreddits in Popsy dashboard
๐ง API connection failed?
- Check internet connection
- Verify
--base-urlis correct with--verbose - Ensure token hasn't expired with
--debug
Migration from Old Version:
If you were using the old separate scripts:
# Old way:
python3 api.py --token TOKEN --dry-run
python3 dm_automation.py --token TOKEN
# New unified way:
python3 main.py --dry-run --verbose # Simulation
python3 main.py --browser --verbose # Browser automation
โ What's New in This Version:
- ๐ Unified CLI: Single
main.pyfor all automation modes - ๐ Smart Configuration: CLI โ config.json โ defaults precedence
- ๐ Verbose & Debug Modes: See exactly what's happening
- ๐ Browser Integration: Seamless switch between simulation and live automation
- ๐ Enhanced Filtering: More control over thread selection
- ๐ Better Error Handling: Graceful failures and helpful error messages
- ๐ Configuration Display: See effective settings before running
- ๐ API Compatibility: Handles different API response formats
The new system provides:
- โ Smart targeting with AI relevancy scoring
- โ Flexible automation modes (simulation vs live browser)
- โ Advanced configuration management with precedence rules
- โ Comprehensive logging and debugging capabilities
- โ Better user experience with verbose feedback
- โ Robust error handling and validation
How to build the package
uv build
uv run twine upload dist/*
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
popsy_ai-0.0.1-py3-none-any.whl
(13.8 kB
view details)
File details
Details for the file popsy_ai-0.0.1-py3-none-any.whl.
File metadata
- Download URL: popsy_ai-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
913213e4095e52e1975dffaba6e4801729927bcd36777e36c91c2b8eef2af8bd
|
|
| MD5 |
c19cc449e50971cbbb6a3b3e77527e07
|
|
| BLAKE2b-256 |
f025ccc447cffe698753cfcbfc87528eea201c134b85da8dc48b1d8628e143ec
|