📝 Introduction
Enter a Douyin work link to retrieve first-level comment data, 20 per page, with pagination support. Display all comments on the current page and AI summary analysis in the conversation, while generating an interactive HTML report containing the current page data and summary.
✨ Features
| Feature Module | Capability Description | Core Value |
|---|---|---|
| Comment Retrieval | Paste a work link to retrieve comments | Pull the latest data from the work's comment section |
| Paginated Browsing | 20 per page, with pagination support | Browse large numbers of comments page by page |
| AI Summary | Four-dimensional sentiment analysis (positive/negative/demand/competitor) | Quickly understand the full picture of comment public opinion |
| Pinned Marking | Special marking for pinned comments | Identify important comments at a glance |
| HTML Report | Dark-themed interactive report | Save/share analysis results offline |
🔑 Authentication
- Get API Key: Go to Red Fox hub
- Configuration method 1: Write to
~/.openclaw/openclaw.json→{ "env": { "REDFOX_API_KEY": "ak_xxxx..." } } - Configuration method 2: Execute in terminal
export REDFOX_API_KEY="ak_xxxx..."
🔄 Workflow
Step 1: Understand user intent, extract videoId
⚠️ Core rule: videoId must be extracted from user input.
- The user may provide the videoId directly (pure digits)
- The user may provide a work link (such as
https://www.douyin.com/video/7131700643076623629), extract the videoId from the link - If the user does not provide a work link, proactively ask: "Please provide the Douyin work link"
- If the user queried data for a certain work in the previous round of conversation, and the current input is ambiguous (such as "next page", "comment analysis"), use the videoId from the previous round
Step 2: Call the comment retrieval script (automatically generates HTML)
⚠️ Each call requests only one page of data (one API request); do not initiate multiple calls to pull multiple pages without authorization.
The script automatically generates an HTML report on each call(including {{PLACEHOLDER}} placeholders, with analysis data not yet filled in). The terminal display and HTML are based onthe same API call, ensuring data consistency.
python3 ~/.agents/skills/douyin-comment-search/scripts/douyin_comment_search.py "<videoId>" [--offset <offset>]
Parameter description:
| Parameter | Description | Default Value |
|---|---|---|
videoId |
Douyin work ID (required) | — |
--offset |
Offset, 20 per page | 0 |
--output-dir |
HTML output directory | ~/Downloads/QoderReports |
Correspondence between offset and page number:
| Page Number | offset |
|---|---|
| Page 1 | 0 |
| Page 2 | 20 |
| Page 3 | 40 |
| ... | offset = (page - 1) × 20 |
Script returns JSON:
| Field | Description |
|---|---|
video_id |
Work ID |
current_page |
Current page number |
total_fetched |
Number of comments retrieved this time |
has_next |
Whether there is a next page (true/false) |
comments |
Comment list |
html_path |
Path of the generated HTML report (contains placeholders, to be filled in later) |
Fields for each comment:
| Field | Description |
|---|---|
comment_id |
Comment ID |
content |
Comment content |
like_count |
Like count |
reply_count |
Reply count |
create_time |
Comment time |
ip_location |
IP location |
user_name |
User nickname |
user_avatar |
User avatar URL |
user_id |
User ID (used to generate profile link) |
user_url |
User profile link |
is_top |
Whether pinned (true/false) |
Note: The HTML report currently contains only the raw comment data; the analysis placeholders (
{{PLACEHOLDER}}) will be filled in after user confirmation.
Step 3: Display comment data + AI summary in the conversation
⚠️ Each operation calls the API only once to retrieve one page of data. The conversation display and the HTML report are based on the same page of data.
A1. State the query scope
📊 Work「{videoId}」retrieved Ncomments (page {page}), the detailed data is as follows:
A2. Render the comment table (display all comments on the current page)
| # | 评论人 | 评论内容 | 👍 | 💬 | 时间 | IP |
|---|--------|---------|----|----|------|-----|
| 1 | [昵称](主页链接) | 评论内容... | 1223 | 213 | 02-12 15:30 | 广东 |
| 2 | [昵称](主页链接) | 评论内容... | 856 | 45 | 02-12 14:20 | 北京 |
| ... | ... | ... | ... | ... | ... | ... |
Formatting rules:
- The commenter column uses
[昵称](user_url)Markdown format, no need to set image dimensions - Comment content exceeding 40 characters is truncated with
... - Time is formatted as
MM-DD HH:MM - Pinned comments add
📌after the nickname (the entire comment row uses bold style) like_count/reply_countNumbers ≥ 10000 usex.xwformat- ⚠️ Maximum 20 per page, all displayed in the conversation, must not be truncated
A3. AI comment summary (⚠️ must be output for every query (including pagination))
Based on all comments retrieved on the current page, perform four-dimensional sentiment analysis.Before analysis, it is necessary to understand Douyin meme culture(popular slang, abbreviations, emoji semantics, trending topic background).
📈 Comment summary analysis (based on {total} comments)
✅ Positive reviews ({positive_ratio}%)
- {point 1}
- {point 2}
- ...
⚠️ Negative reviews ({negative_ratio}%)
- {point 1}
- {point 2}
- ...
💡 User needs ({demand_ratio}%)
- {point 1}
- {point 2}
- ...
🔍 Competitor comparison public opinion ({competitor_ratio}%)
- {Output only when competitors are mentioned in the comments, otherwise output "No competitors mentioned"}
- {competitor name}: {public opinion point}
Analysis requirements:
- Each point must cite a representative comment (extract keywords/phrases)
- The percentage is the proportion of comments mentioning that type to the total number of comments
- The sum of the proportions of the four categories (positive/negative/demand/competitor) may exceed 100% (a single comment may contain multiple types of information)
- Must understand Douyin meme culture: recognize popular slang (such as "绝绝子", "yyds", "破防", "入典", etc.), emoji semantics, abbreviations (such as "xswl", "awsl"), and the contextual meaning of memes
A4. Pagination prompt (⚠️ immediately after A3, must be output every time)
- If
has_nextis true:
📄 Current page {page} ({total_fetched} items total). Reply "Next Page" to continue viewing.
- If
has_nextis false:
📄 Current page {page} , no more data available.
⚠️ A1~A4 must be completed consecutively in the same round of output, no step may be omitted.
After A4 output is complete,ask the user whether they need an HTML visualization report generated:
📊 Do you need an HTML visualization report generated?
If the user replies with confirmation words such as "Yes", "Need", "Generate", "html", etc., then execute the following steps (no need to call the script again, the HTML file has already been generated in Step 2):
① Backfill AI analysis results into the HTML
Call backfill_html.py to backfill the AI analysis results into the {{PLACEHOLDER}} placeholder in the HTML:
python3 ~/.agents/skills/douyin-comment-search/scripts/backfill_html.py "<html_path>" --analysis-json '{
"positive_ratio": <正整数>,
"negative_ratio": <正整数>,
"demand_ratio": <正整数>,
"competitor_ratio": <正整数>,
"positive_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"negative_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"demand_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>",
"competitor_summary": "<ul><li>要点1</li><li>要点2</li>...</ul>"
}'
JSON field description:
| Field | Type | Description | Example |
|---|---|---|---|
positive_ratio |
int | Positive review percentage (plain number, excluding %) | 45 |
negative_ratio |
int | Negative review percentage | 30 |
demand_ratio |
int | User demand percentage | 15 |
competitor_ratio |
int | Competitor comparison percentage | 15 |
positive_summary |
string | Positive review summary (HTML format <ul><li>...</li></ul>) |
see example |
negative_summary |
string | Negative review summary | Same as above |
demand_summary |
string | User demand summary | Same as above |
competitor_summary |
string | Competitor comparison summary | Same as above |
Note: The JSON string parameter contains double quotes, wrap it in single quotes in Bash, internal double quotes need to be escaped \". If the content contains single quotes, pass it via stdin:echo '...' | python3 backfill_html.py "<html_path>"
② Open the HTML report:
open "<html_path>"
Step 4: Pagination handling (when the user replies "Next Page", etc.)
When the user replies "Next Page", "Previous Page", "Page N", etc.:
- Reuse the videoId extracted in Step 1
- Calculate the new offset:
(page - 1) × 20 - Call the script again (consistent with Step 2, HTML is generated automatically):
python3 .../douyin_comment_search.py "<videoId>" --offset <offset> - Fully execute A1~A4 of Step 3(independent display per page + AI analysis)
- After A4, ask the user whether they need an HTML report for the current page generated (same as the end-of-Step-3 process,no need to call the script again)
Pagination rules:
has_nextis true → the current page has exactly 20 items, a next page existshas_nextis false → the current page has fewer than 20 items, it is the last page
Step 5: Error handling
| Error type | Handling method |
|---|---|
| No API Key | Prompt to configure REDFOX_API_KEY, provide configuration guidance |
| Invalid work link | Prompt "No comments found for this work, please check whether the work link is correct" |
| API returned an error | Display error code and error message |
| Retrieved 0 comments | Prompt "This work has no comments yet" and suggest checking whether the work exists or has been deleted |
| Network request timeout | Prompt "Network request timed out, please try again later" |
📋 Dependencies
# 脚本使用 urllib(Python 标准库),无需额外安装依赖
🎯 Usage Examples
Example 1: View comments on a specified work
用户:查看抖音作品 7131700643076623629 的评论
助手:调用脚本(自动生成HTML) → 展示全部20条 + AI总结 → 询问是否需要HTML → 用户确认 → backfill → open
Example 2: Query via link
用户:https://www.douyin.com/video/7131700643076623629 这篇的评论怎么样
助手:提取 videoId → 调用脚本 → 展示分析 → 询问是否需要HTML
Example 3: Turn the page
用户:下一页
助手:调用脚本 offset=20 → 展示第2页 + AI分析 → 询问是否需要当前页HTML