Install
openclaw skills install youtube-comment-moderatorClawHub Security found sensitive or high-impact capabilities. Review the scan results before using.
AI-powered YouTube comment moderation. Fetches comments, classifies them (spam, question, praise, hate, neutral, constructive), drafts replies, and deletes spam. Works with any YouTube channel via OAuth. Use when moderating YouTube comments, setting up auto-replies, analyzing comment sentiment, managing spam, or building a comment moderation pipeline.
openclaw skills install youtube-comment-moderatorClassify, reply to, and delete YouTube comments automatically using Gemini Flash + YouTube Data API v3.
When a user wants to set up YouTube moderation, walk them through this conversationally. Do not tell them to run shell commands.
Ask: "What's your YouTube channel URL or channel ID?"
Resolve it:
source .env
python3 scripts/fetch_comments.py --channel-id <ID> --max-videos 1 --max-comments 0
This validates the channel exists. If they give a URL like youtube.com/@handle, extract the handle and look up the channel ID via the API.
Four keys are needed. Check which are missing:
echo "YOUTUBE_API_KEY=${YOUTUBE_API_KEY:+SET}"
echo "GEMINI_API_KEY=${GEMINI_API_KEY:+SET}"
echo "YT_MOD_CLIENT_ID=${YT_MOD_CLIENT_ID:+SET}"
echo "YT_MOD_CLIENT_SECRET=${YT_MOD_CLIENT_SECRET:+SET}"
For any missing keys, tell the user what to do (not how to run scripts):
YOUTUBE_API_KEY=... to your .env file."GEMINI_API_KEY=... to your .env file."references/oauth-setup.md conversationally, or summarize: "In Google Cloud Console, enable YouTube Data API, create an OAuth consent screen (External, Testing mode), add yourself as test user, create a Web Application OAuth client with redirect URI http://127.0.0.1:8976/callback, then add the Client ID and Client Secret to your .env."After they confirm keys are added, restart the gateway so env vars reload.
Generate the auth URL and send it to the user:
source .env && python3 scripts/setup.py --auth-url
Tell them: "Open this link, sign in with the Google account that owns your YouTube channel, and click Allow."
If user has a local browser (desktop): The script automatically catches the callback on http://127.0.0.1:8976/callback and saves the token. Tell them: "After clicking Allow, the browser should show a success page. You're done — I'll verify the token was saved."
If user is headless/remote (VPS, Telegram): Tell them: "After clicking Allow, your browser will redirect to a URL starting with http://127.0.0.1:8976/callback?code=.... That page won't load — that's expected. Copy ONLY the code parameter value from the URL (the part between code= and the next &), and paste just that code here. Do NOT paste the full URL — it contains sensitive auth data."
When they provide the code:
source .env && python3 scripts/setup.py --exchange-code "http://127.0.0.1:8976/callback?code=<CODE>"
⚠️ Security note: The OAuth code is single-use and expires in minutes, but avoid logging or echoing the full callback URL. If the user accidentally pastes a full URL in chat, exchange it immediately, then advise them the code is already consumed and useless.
Ask them conversationally:
Then create the config:
python3 scripts/setup.py --create-config \
--channel-id <ID> \
--channel-name "<NAME>" \
--mode <approval|auto|monitor> \
--voice "<VOICE_STYLE>"
Run a dry run and show them the results:
source .env && python3 scripts/moderate.py --all-videos --dry-run
Summarize: "Found X videos, Y new comments. Here's what I'd do: Z spam deleted, W questions answered, etc." Show a few examples.
Once they approve:
source .env && python3 scripts/moderate.py --all-videos
Optionally set up a cron job to run every 15-30 minutes for ongoing moderation.
| Script | Purpose |
|---|---|
setup.py | Setup wizard (interactive or --auth-url / --exchange-code / --create-config) |
moderate.py | Main pipeline: fetch → classify → act. Also: --stats, --queue, --approve, --all-videos |
fetch_comments.py | Standalone comment fetcher (API key only) |
classify_comments.py | Standalone classifier (JSON in → JSON out) |
db.py | SQLite persistence layer |
--queue to see, --approve to execute)| Category | Auto Action | Description |
|---|---|---|
| spam | delete | Promotional links, scam offers, bot text, self-promo |
| question | reply | Genuine question about video/creator/topic |
| praise | thank | Positive feedback, compliments |
| hate | delete | Hateful, abusive, harassing content |
| neutral | skip | Generic reactions, timestamps |
| constructive | flag | Thoughtful criticism, suggestions |
data/youtube-comment-moderator/moderator.db)Required:
YOUTUBE_API_KEY — YouTube Data API v3 key (free, 10K units/day)GEMINI_API_KEY — Gemini Flash for classificationFor write operations (reply/delete):
YT_MOD_CLIENT_ID — Google OAuth client IDYT_MOD_CLIENT_SECRET — Google OAuth client secretOptional overrides:
YT_MOD_DB — SQLite DB path (default: data/youtube-comment-moderator/moderator.db)YT_MOD_OAUTH — OAuth token path (default: skills/youtube-comment-moderator/oauth.json)YT_MOD_CONFIG — Config path (default: skills/youtube-comment-moderator/config.json)See references/oauth-setup.md for the full step-by-step Google Cloud setup guide with screenshots-level detail and troubleshooting.