Sentiment Analysis Monitor
AI-powered social media sentiment monitoring and analysis tool for Chinese platforms. Monitor keyword mentions across Xiaohongshu, Douyin, Weibo, and WeChat Official Accounts in real time.
Features Overview
| Feature | Description |
|---|
| Platform Monitoring | Xiaohongshu, Douyin, Weibo, WeChat Official Account keyword search |
| AI Sentiment Analysis | Positive / Neutral / Negative + reason summary |
| Sentiment Reports | Total mentions, sentiment ratio, trending charts, top posts |
| Auto Alerts | Feishu/email push when negative mentions exceed threshold |
| Scheduled Crawling | OpenClaw Cron for periodic scraping |
| Storage | Local SQLite + JSON |
Key: No official platform APIs required — pure Playwright scraping of public content.
Quick Start
Add Keyword Monitoring
User: Monitor keyword "brand_name" on Xiaohongshu and Douyin
User: Add sentiment monitoring for "product_name", platforms: Weibo + WeChat Official Account
→ Parse keyword and platforms → Create monitoring task → Execute first crawl → Return result summary
View Sentiment Report
User: Show sentiment report for "brand_name"
User: How is "competitor_name" trending in the last 7 days?
→ Return structured report: total mentions, positive/neutral/negative ratios, trending charts, top post list
Set Alert Rules
User: Set negative alert for "brand_name", threshold 10 posts/day, notify me when exceeded
User: Configure Feishu alert, push to "Operations Group"
→ Configure negative threshold and push channel → Auto-judge after each crawl
Manage Monitoring Tasks
User: List my sentiment monitoring tasks
User: Delete monitoring for "brand_name"
User: Pause monitoring for "competitor_name"
Tiered Features
| Feature | FREE | PRO |
|---|
| Keywords | 1 | Unlimited |
| Platforms | Xiaohongshu | All 4 platforms |
| Daily limit | 50 | Unlimited |
| Data history | 7 days | Unlimited |
| Sentiment reports | — | Yes |
| Priority monitoring | — | Yes |
Platform Monitoring Details
Xiaohongshu (XHS)
- Search URL:
https://www.xiaohongshu.com/search_result?keyword={keyword}&source=web_explore_search
- Anti-detection: Playwright headless, UA rotation, random delay 3~8s
- Content extracted: Note title, body, author, likes/bookmarks/comments count, publish time
Douyin
- Search URL:
https://www.douyin.com/search/{keyword}
- Anti-detection: Playwright headless, scroll simulation, lazy-load handling
- Content extracted: Video title, author, likes/comments/shares count, publish time
Weibo
- Search URL:
https://s.weibo.com/weibo?q={keyword}&typeall=1
- Anti-detection: Playwright headless, UA rotation
- Content extracted: Post body, author, reposts/comments/likes count, publish time
WeChat Official Accounts
- Search URL:
https://weixin.sogou.com/weixin?type=2&query={keyword}
- Anti-detection: Playwright headless
- Content extracted: Article title, abstract, account name, read count, publish time
Sentiment Analysis
Chinese semantic sentiment analysis via GLM-4 API:
Input: Post body / comment content
Output:
sentiment: "positive" | "neutral" | "negative"
score: -1.0 ~ 1.0 (negative to positive)
reason: Brief reason summary
Classification rules:
- Positive: score > 0.1
- Neutral: -0.1 <= score <= 0.1
- Negative: score < -0.1
Alert Rules
| Rule | Description |
|---|
| Negative threshold | Trigger when daily negative mentions exceed N (default: 5) |
| Trend alert | Trigger when negative rate increases > 20% week-over-week |
| Push channels | Feishu group bot / Email (SMTP) |
Feishu Alert Message Template
Sentiment Alert | {keyword}
Time: {time}
Today's Negatives: {negative_count} (threshold: {threshold})
Negative Rate: {negative_rate}%
Latest Negative Posts:
- {title} — {platform} @{author}
Usage Examples
Example 1: Brand Sentiment Monitoring
User: Monitor "coffee brand" on Xiaohongshu and Douyin, crawl every day at 9am
→ Create task → Return confirmation → Next Cron trigger executes first crawl
Example 2: Competitor Negative Alert
User: Alert me via Feishu when negative posts appear for "competitor"
→ Set negative threshold alert → Configure Feishu group bot → Auto-push when threshold exceeded
Example 3: Sentiment Report
User: Generate this week's sentiment report for "brand_name"
→ Query local SQLite for this week's data → AI generate summary → Return Markdown report
Core Scripts
See scripts/sentiment.py for full implementation:
from scripts.sentiment import SentimentCompass
compass = SentimentCompass(tier="PRO")
# ─── Add keyword monitoring ──────────────
compass.add_keyword(
keyword="brand_name",
platforms=["xhs", "douyin", "weibo", "wechat"],
frequency="daily", # 6h/12h/daily/weekly
priority=1, # 1=high priority (Pro only)
)
# ─── Execute crawl (manual) ──────────────
results = compass.crawl_keyword("brand_name")
# ─── Sentiment analysis (single) ─────────
analysis = compass.analyze_sentiment("This product is really great, highly recommended!")
# → {"sentiment": "positive", "score": 0.85, "reason": "Contains positive words like 'great' and 'highly recommended'"}
# ─── Batch analysis (save API calls) ─────
batch = compass.batch_analyze([
"Product is great, worth buying",
"Quality is terrible, not worth the price at all",
"It's okay, just average",
])
for item in batch:
print(f"[{item['sentiment']}] {item['text'][:30]}")
# ─── Generate report ─────────────────────
report = compass.generate_report(keyword="brand_name", days=7)
print(report["summary"]) # AI-generated text summary
print(report["stats"]) # Statistical data
# ─── Check alerts ───────────────────────
alerts = compass.check_alerts(keyword="brand_name")
if alerts:
compass.send_feishu_alert(alerts)
# ─── List tasks ─────────────────────────
tasks = compass.list_tasks()
for t in tasks:
print(f" {t['keyword']} — {t['platforms']} — {t['status']}")
Technical Implementation
- Crawler: Playwright (headless) for dynamic pages, UA rotation, random delay 3~8s
- AI Analysis: GLM-4 API (
open.bigmodel.cn), batch analysis to save tokens
- Storage: SQLite (
~/.sentiment-compass/data.db) + JSON config
- Scheduling: OpenClaw Cron, supports 6h/12h/daily/weekly frequency
- Push: Feishu group bot Webhook / Email SMTP
Data Model
-- Monitoring tasks
CREATE TABLE tasks (
id INTEGER PRIMARY KEY,
keyword TEXT UNIQUE,
platforms TEXT, -- comma-separated: xhs,douyin,weibo,wechat
frequency TEXT DEFAULT 'daily',
priority INTEGER DEFAULT 0,
status TEXT DEFAULT 'active',
created_at TEXT,
last_crawl_at TEXT
);
-- Post data
CREATE TABLE posts (
id INTEGER PRIMARY KEY,
keyword TEXT,
platform TEXT, -- xhs/douyin/weibo/wechat
post_id TEXT,
title TEXT,
content TEXT,
author TEXT,
author_id TEXT,
likes INTEGER DEFAULT 0,
comments INTEGER DEFAULT 0,
shares INTEGER DEFAULT 0,
published_at TEXT,
fetched_at TEXT,
url TEXT UNIQUE
);
-- Sentiment analysis results
CREATE TABLE analyses (
id INTEGER PRIMARY KEY,
post_id INTEGER REFERENCES posts(id),
sentiment TEXT, -- positive/neutral/negative
score REAL, -- -1.0 ~ 1.0
reason TEXT,
analyzed_at TEXT
);
-- Alert records
CREATE TABLE alerts (
id INTEGER PRIMARY KEY,
keyword TEXT,
alert_type TEXT, -- threshold/trend
threshold INTEGER,
negative_count INTEGER,
negative_rate REAL,
triggered_at TEXT,
notification_sent INTEGER DEFAULT 0
);
FAQ
| Question | Answer |
|---|
| Will accounts get blocked? | Pure public content scraping with 3~8s random delay between requests, 3 retries on failure |
| Does it support login-gated content? | Current version does not support login-required pages |
| How accurate is sentiment analysis? | Based on GLM-4 Chinese semantic understanding; accuracy depends on text length and context |
| How many keywords can I monitor? | FREE=1, PRO=unlimited |
| How long is data retained? | FREE=7 days, Pro+=unlimited |
| How to configure Feishu alerts? | Provide group bot Webhook URL — no app permissions needed |
Tier Limits
TIER_LIMITS = {
"FREE": {"max_keywords": 1, "platforms": ["xhs"], "daily_limit": 50, "history_days": 7},
"PRO": {"max_keywords": -1, "platforms": ["xhs","douyin","weibo","wechat"], "daily_limit": -1, "history_days": -1, "report": True, "priority": True},
}
Billing
- Pay-per-call: $0.0100 USDT per execution via SkillPay.me
- Balance insufficient: Payment URL returned — user tops up at
https://skillpay.me/sentiment-analysis-monitor
- External data flow:
FEISHU_USER_ID transmitted to skillpay.me/api/v1/billing for balance charging
Required Environment Variables
| Variable | Description |
|---|
FEISHU_USER_ID | User open_id for billing (passed by Feishu runtime) |
SKILL_BILLING_API_KEY | SkillPay Builder API Key |
SKILL_BILLING_SKILL_ID | SkillPay Skill ID (defaults to sentiment-analysis-monitor) |