{"skill":{"slug":"youtube-comment-moderator","displayName":"YouTube Comment Moderator","summary":"AI-powered YouTube comment moderation. Fetches comments, classifies them (spam, question, praise, hate, neutral, constructive), drafts replies, and deletes s...","description":"---\nname: youtube-comment-moderator\ndescription: >\n  AI-powered YouTube comment moderation. Fetches comments, classifies them\n  (spam, question, praise, hate, neutral, constructive), drafts replies,\n  and deletes spam. Works with any YouTube channel via OAuth.\n  Use when moderating YouTube comments, setting up auto-replies, analyzing\n  comment sentiment, managing spam, or building a comment moderation pipeline.\nenv:\n  - name: YOUTUBE_API_KEY\n    required: true\n    description: YouTube Data API v3 key (free, 10K units/day)\n  - name: GEMINI_API_KEY\n    required: true\n    description: Gemini API key for comment classification\n  - name: YT_MOD_CLIENT_ID\n    required: true\n    description: Google OAuth client ID (for reply/delete operations)\n  - name: YT_MOD_CLIENT_SECRET\n    required: true\n    description: Google OAuth client secret (for reply/delete operations)\n---\n\n# YouTube Comment Moderator\n\nClassify, reply to, and delete YouTube comments automatically using Gemini Flash + YouTube Data API v3.\n\n## Setup (Agent-Driven)\n\nWhen a user wants to set up YouTube moderation, walk them through this conversationally. Do not tell them to run shell commands.\n\n### 1. Collect Channel Info\n\nAsk: \"What's your YouTube channel URL or channel ID?\"\n\nResolve it:\n```bash\nsource .env\npython3 scripts/fetch_comments.py --channel-id <ID> --max-videos 1 --max-comments 0\n```\nThis 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.\n\n### 2. Check Environment Keys\n\nFour keys are needed. Check which are missing:\n```bash\necho \"YOUTUBE_API_KEY=${YOUTUBE_API_KEY:+SET}\" \necho \"GEMINI_API_KEY=${GEMINI_API_KEY:+SET}\"\necho \"YT_MOD_CLIENT_ID=${YT_MOD_CLIENT_ID:+SET}\"\necho \"YT_MOD_CLIENT_SECRET=${YT_MOD_CLIENT_SECRET:+SET}\"\n```\n\nFor any missing keys, tell the user what to do (not how to run scripts):\n\n- **YOUTUBE_API_KEY**: \"Go to [Google Cloud Console → Credentials](https://console.cloud.google.com/apis/credentials), create an API key, and add `YOUTUBE_API_KEY=...` to your `.env` file.\"\n- **GEMINI_API_KEY**: \"Go to [Google AI Studio](https://aistudio.google.com/apikey), create a key, and add `GEMINI_API_KEY=...` to your `.env` file.\"\n- **YT_MOD_CLIENT_ID + YT_MOD_CLIENT_SECRET**: These require OAuth setup. Walk them through `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`.\"\n\nAfter they confirm keys are added, restart the gateway so env vars reload.\n\n### 3. OAuth Authorization\n\nGenerate the auth URL and send it to the user:\n```bash\nsource .env && python3 scripts/setup.py --auth-url\n```\n\nTell them: \"Open this link, sign in with the Google account that owns your YouTube channel, and click Allow.\"\n\n**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.\"\n\n**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.\"\n\nWhen they provide the code:\n```bash\nsource .env && python3 scripts/setup.py --exchange-code \"http://127.0.0.1:8976/callback?code=<CODE>\"\n```\n\n⚠️ **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.\n\n### 4. Configure\n\nAsk them conversationally:\n- \"What moderation mode? **Auto** (replies and deletes automatically), **Approval** (drafts everything for your review), or **Monitor** (classify and report only)?\"\n- \"How do you typically talk to your audience? Casual? Professional? Funny?\" (this sets voice_style)\n- \"Any common questions you get? I can pre-load answers so replies are accurate.\" (optional FAQ)\n\nThen create the config:\n```bash\npython3 scripts/setup.py --create-config \\\n  --channel-id <ID> \\\n  --channel-name \"<NAME>\" \\\n  --mode <approval|auto|monitor> \\\n  --voice \"<VOICE_STYLE>\"\n```\n\n### 5. Test\n\nRun a dry run and show them the results:\n```bash\nsource .env && python3 scripts/moderate.py --all-videos --dry-run\n```\n\nSummarize: \"Found X videos, Y new comments. Here's what I'd do: Z spam deleted, W questions answered, etc.\" Show a few examples.\n\n### 6. Go Live\n\nOnce they approve:\n```bash\nsource .env && python3 scripts/moderate.py --all-videos\n```\n\nOptionally set up a cron job to run every 15-30 minutes for ongoing moderation.\n\n## Scripts Reference\n\n| Script | Purpose |\n|--------|---------|\n| `setup.py` | Setup wizard (interactive or `--auth-url` / `--exchange-code` / `--create-config`) |\n| `moderate.py` | Main pipeline: fetch → classify → act. Also: `--stats`, `--queue`, `--approve`, `--all-videos` |\n| `fetch_comments.py` | Standalone comment fetcher (API key only) |\n| `classify_comments.py` | Standalone classifier (JSON in → JSON out) |\n| `db.py` | SQLite persistence layer |\n\n## Moderation Modes\n\n- **monitor** — classify + report only (no OAuth needed)\n- **approval** — drafts replies and queues deletions for review (`--queue` to see, `--approve` to execute)\n- **auto** — auto-replies to questions, auto-deletes spam/hate\n\n## Classification Categories\n\n| Category | Auto Action | Description |\n|----------|-------------|-------------|\n| spam | delete | Promotional links, scam offers, bot text, self-promo |\n| question | reply | Genuine question about video/creator/topic |\n| praise | thank | Positive feedback, compliments |\n| hate | delete | Hateful, abusive, harassing content |\n| neutral | skip | Generic reactions, timestamps |\n| constructive | flag | Thoughtful criticism, suggestions |\n\n## Architecture\n\n- **State:** SQLite (`data/youtube-comment-moderator/moderator.db`)\n- **Classification:** Gemini 2.0 Flash (~$0.001/comment)\n- **Read:** YouTube Data API v3 (API key)\n- **Write:** YouTube Data API v3 (OAuth)\n- **Deduplication:** comment_id primary key, already-processed comments skipped\n\n## Environment Variables\n\nRequired:\n- `YOUTUBE_API_KEY` — YouTube Data API v3 key (free, 10K units/day)\n- `GEMINI_API_KEY` — Gemini Flash for classification\n\nFor write operations (reply/delete):\n- `YT_MOD_CLIENT_ID` — Google OAuth client ID\n- `YT_MOD_CLIENT_SECRET` — Google OAuth client secret\n\nOptional overrides:\n- `YT_MOD_DB` — SQLite DB path (default: `data/youtube-comment-moderator/moderator.db`)\n- `YT_MOD_OAUTH` — OAuth token path (default: `skills/youtube-comment-moderator/oauth.json`)\n- `YT_MOD_CONFIG` — Config path (default: `skills/youtube-comment-moderator/config.json`)\n\n## OAuth Setup Details\n\nSee [references/oauth-setup.md](references/oauth-setup.md) for the full step-by-step Google Cloud setup guide with screenshots-level detail and troubleshooting.\n","topics":["Pipeline"],"tags":{"latest":"1.0.1"},"stats":{"comments":0,"downloads":722,"installsAllTime":27,"installsCurrent":0,"stars":1,"versions":2},"createdAt":1773300220191,"updatedAt":1779078127932},"latestVersion":{"version":"1.0.1","createdAt":1773355245022,"changelog":"- Initial public release with agent-driven, conversational setup guide for YouTube comment moderation.\n- Added full scripts for fetching, classifying, moderating, and storing YouTube comments.\n- Includes detailed OAuth setup instructions and environment variable documentation.\n- Moderation supports monitor, approval, and auto modes with AI-powered comment classification.\n- All major pipeline scripts (setup, fetch, classify, moderate, db) included.","license":"MIT-0"},"metadata":{"setup":[{"key":"YOUTUBE_API_KEY","required":true},{"key":"GEMINI_API_KEY","required":true},{"key":"YT_MOD_CLIENT_ID","required":true},{"key":"YT_MOD_CLIENT_SECRET","required":true}],"os":null,"systems":null},"owner":{"handle":"dhruvkar","userId":"s17anp6wbzvs2kt7kw5wvnaymx83qka9","displayName":"Dhruv Kar","image":"https://avatars.githubusercontent.com/u/680783?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089861974}}