Building a Juejin Summarization Bot with the 豆包 MarsCode AI IDE
This article walks through creating a Juejin comment bot that polls for article links, uses the 豆包 MarsCode AI IDE to generate summarization code via its API, and automatically posts the summary back as a comment, covering environment setup, task breakdown, code generation, and deployment.
Overview
The bot reproduces the Bilibili @课代表 comment‑reply pattern in Juejin. When a user posts a Juejin article URL as a comment under the bot’s own article, the bot fetches the target article, generates a summary via the 豆包 AI service, and replies with the summary in the target article’s comment section.
Environment Setup
Development is performed on the 豆包MarsCode cloud platform, which provides a ready‑to‑use Node.js runtime and a plugin for the 豆包 IDE integration. Registration is done through the short link sourl.cn/vKjHKF and login with a Juejin account.
Functional Requirements
Comment list API (to poll recent comments)
Comment posting API (to send the summary)
Comment read API (to mark a comment as processed)
豆包 AI dialogue API (to obtain the summary)
The processing pipeline is:
Poll the comment list.
Identify comments that have not been processed.
Extract Juejin article links from the comment text.
Call the AI summarization service with the article URL.
Post the generated summary as a comment on the target article.
Mark the original comment as read.
Project Initialization
A Node.js project is created on the cloud platform. The environment already includes axios for HTTP requests and supports installing additional npm packages.
Polling Comment List
Using axios and setTimeout, the bot repeatedly requests the comment list endpoint. The returned JSON is stored for further processing.
Detecting Unread Comments
The bot examines each comment object for a flag or timestamp indicating whether it has been processed. Only comments marked as unread proceed to the next step.
Extracting Article URLs
A regular expression extracts the numeric article ID from URLs that match the Juejin pattern https://juejin.cn/post/\d+. The extracted ID is used to construct the target article URL for summarization.
Summarizing Articles via 豆包 AI
The bot invokes the Coze platform’s API (documented at https://www.coze.cn/docs/developer_guides/coze_api_overview) which forwards the request to the 豆包 AI model. The request payload includes the article URL and a prompt asking for a concise summary. The response contains the summary text.
Handling AI Output Issues
During development the AI occasionally regenerated helper functions or omitted the required summary. The developer manually copied the correct portion of the response and inserted it into the workflow.
Posting the Summary
The bot sends the summary text to the comment posting API of the target article. Successful posting is confirmed by the API response.
Marking Comments as Read
After posting, the bot calls the comment read API with the original comment’s ID, ensuring the comment will not be processed again.
Extended Experimentation
Additional prompts were added so that the AI returns a JSON object containing both the summary and the original commenter’s username. The bot parses this JSON and includes the username in the reply comment.
Code Refactoring
The developer used 豆包’s code‑refactor capability to add inline comments, improve variable naming, and extract reusable functions, resulting in cleaner, more maintainable code.
Running the Bot
After configuring the Juejin account cookie in the project settings, the Node.js service is started. When another user comments a Juejin article link under the bot’s article, the bot processes the comment, generates a summary, and posts it after the platform’s moderation delay.
Exporting the Project
The completed project is exported from the cloud IDE and can be deployed on any server for 24‑hour operation.
Potential Extensions
Automatic replies to new followers.
Support for other platforms by describing equivalent API requirements to the AI.
Customizing the AI prompt to enforce multi‑bullet answers.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Full-Stack Cultivation Path
Focused on sharing practical tech content about TypeScript, Vue 3, front-end architecture, and source code analysis.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
