Install social-cli
social-cli is the open-source engine that talks to the Meta Marketing API.Verify it’s installed:
social-cli is built by @vishalgojha and handles Meta API authentication and data fetching for you.
Authenticate with Meta
Run the login command to connect your Facebook ad account:This opens your browser to authorize with Meta. You need:
- A Facebook account with access to your ad account
- Permission to read ad insights (most ad account admins have this)
The authentication flow stores your access token locally. No API keys are required in your
.env file.Advanced: Using a Meta App
If you have a Meta developer app with custom permissions:Set your ad account
List your available ad accounts:You’ll see output like:Set the default account you want to monitor:Alternatively, set it via environment variable:
The account ID always starts with
act_. You can switch accounts anytime by running the set-default-account command again.Configure benchmarks
Clone the repository and set up your configuration:Edit
ad-config.json with your performance targets:ad-config.json
Don’t know your benchmarks yet? Leave the defaults. The agent will learn from your actual performance data over time.
What the benchmarks mean
| Benchmark | What it does |
|---|---|
target_cpa | Cost per action target — flags campaigns above this |
target_roas | Return on ad spend target (3.0 = 1 spent) |
max_frequency | Creative fatigue threshold (3.5 = ad shown to same person 3.5 times on average) |
min_ctr | Minimum acceptable click-through rate as a percentage |
max_cpc | Maximum cost per click — alerts when exceeded |
bleeder_ctr_threshold | CTR below this flags an ad as a “bleeder” |
fatigue_ctr_drop_pct | CTR decline percentage that signals creative fatigue |
Permissions needed
The Meta API scopes required depend on what you want to do:| Permission | Required for |
|---|---|
ads_read | Reading campaign data, insights |
ads_management | Pausing/resuming ads, budget changes |
read_insights | Performance metrics |
ads_read + read_insights are enough for monitoring only. Add ads_management if you want the agent to take action on your behalf.Troubleshooting
| Problem | Fix |
|---|---|
social: command not found | Run npm install -g @vishalgojha/social-cli again. You may need to restart your terminal. |
| Authentication fails | Try social auth login again. Check that the browser popup isn’t blocked. |
| ”No ad accounts found” | Make sure your Facebook user has ad account access. Check at business.facebook.com. |
| No data returned | Check that campaigns have been running in the selected time period. Try --preset last_30d for a wider range. |
| Rate limited | Meta API has rate limits. Wait a few minutes and retry. |
Check everything
Run the built-in diagnostics:Optional: Run with OpenClaw
For a conversational AI interface, install OpenClaw:- “How are my ads doing?”
- “Any bleeders?”
- “Daily check”