- Content in the gray box = Copy and paste directly into the WorkBuddy dialog boxinstructions for
- Start from step one in order, and proceed to the next step only after completing each one
- Steps 1 and 2 only need to be done once (environment setup); after that, each document generation only requires Step 4
- If you run into problems, see the FAQ at the bottom
Configure once, and after that each document generation only takes one sentence.
Step 1: Register on the Open Platform and get your Client ID and Client Secret
Just as a WeChat Official Account needs an AppID and AppSecret, Tencent Docs also requires a pair of keys to call the API.
1.1 Register as a developer
https://docs.qq.com/open/developers/
| Parameter name | Description | Purpose |
|---|---|---|
Client ID | Unique application identifier | Required for both authorization and API calls |
Client Secret | Application secret (keep confidential!) | Used when exchanging for an Access Token |
http://localhost:8080/callback(this is fine for local development).Step 2: Configure the Python environment
Copy the following message and send it to WorkBuddy, and it will help you set up the entire environment with one click:
帮我配置腾讯文档自动生成环境: Client ID:在这里填你的Client ID Client Secret:在这里填你的Client Secret 回调地址:http://localhost:8080/callback 请帮我: 1. 创建 Python 虚拟环境并安装依赖(requests、flask、python-dotenv) 2. 创建配置文件 .env 保存 Client ID 和 Client Secret 3. 创建授权脚本 auth_server.py(启动本地 Flask 服务完成 OAuth 授权) 4. 创建文档生成脚本 tencent_docs.py(支持创建文档 + 写入内容) 5. 测试配置是否正常
2.1 Complete OAuth authorization
On first use, you need to authorize manually once to obtain Access Token(valid for 30 days). After that, WorkBuddy will automatically refresh the Token, so no repeated action is needed.
启动腾讯文档 OAuth 授权流程,获取 Access Token。
2.2 Verify the environment
测试腾讯文档 API 连接是否正常,验证 Access Token 是否有效。
Step 3: Customize document content and format
Tell WorkBuddy what you want to write, and it will generate the content and write it into Tencent Docs via API.
Option 1: Let AI write the full content
帮我写一篇文章,并自动创建为腾讯文档: 主题:在这里写主题(比如:2024年AI行业年度总结) 风格:专业、简洁,适合内部汇报 字数:不少于2000字 结构要求: - 开篇摘要 - 3-5个章节,每章有明确标题 - 关键数据用加粗标注 - 结尾附总结与展望 文档标题:在这里写文档标题
Option 2: You already have content and only need to write it into Tencent Docs
帮我把下面这段内容写入腾讯文档: 文档标题:在这里填标题 正文: (在这里粘贴你的文章内容) 格式要求: - 标题用二号、加粗 - 正文用四号 - 重要内容用蓝色背景高亮 - 段落间保留间距
Option 3: Import a Markdown file directly
帮我把下面这个 Markdown 文件导入到腾讯文档: C:\Users\你的用户名\Desktop\我的文章.md 文档标题:在这里填标题
Step 4: One-click generation of Tencent Docs (most commonly used!)
Once the environment is set up, you only need to say this sentence each time:
帮我写一篇文章,自动创建为腾讯文档。
After successful execution, WorkBuddy will return the document link, like this:
# 生成成功示例输出
✓ 文档创建成功!
文档ID: DQWxxxxxxx
链接: https://docs.qq.com/doc/DQWxxxxxxx
✓ 已写入 2150 字,共 5 个章节
✓ 格式设置完成(标题加粗、段落缩进、关键内容高亮)
Where to view it after generation?
Open docs.qq.com, log in to the same account, and you will see the document just generated in "My Documents".
Step 5: Set up scheduled automatic document generation
帮我创建一个每天自动写文章并生成腾讯文档的定时任务: 执行时间:每天上午9点 内容主题:每日科技资讯汇总,每次不重复 文章风格:简洁专业,适合团队周报 输出位置:腾讯文档(默认目录)
Common Commands Quick Reference
| What you want to do | Copy this text |
|---|---|
| Write an article and generate Tencent Docs | 帮我写一篇关于"xxx"的文章,创建为腾讯文档。 |
| Import Markdown into Tencent Docs | 把"xxx.md"导入为腾讯文档。 |
| Batch generate multiple documents | 帮我写3篇关于"xxx"不同角度的文章,分别创建为腾讯文档。 |
| Update existing document content | 更新腾讯文档 xxx 的内容,把第二章改成"xxx"。 |
| List my documents | 列出我腾讯文档账号里的最近10个文档。 |
| Copy document | 把腾讯文档 xxx 复制一份。 |
| Test API connection | 测试腾讯文档 API 连接是否正常。 |
| Refresh Token | 检查并刷新腾讯文档 Access Token。 |
| Modify default format | 修改腾讯文档生成脚本,默认字体改为"微软雅黑",字号14px。 |
| View scheduled tasks | 查看当前有哪些自动化任务在运行。 |
FAQ
❓ What to do if "invalid_client" error occurs?
The Client ID or Client Secret is incorrect. Check that you copied them completely and watch out for extra spaces. If you're sure they're correct, go to the open platform to reset the Client Secret and try again:
更新腾讯文档 Client Secret:在这里填新的Secret
❓ What to do if the Access Token expires?
The Access Token is valid for 30 days. WorkBuddy automatically refreshes it using the Refresh Token, so manual action is usually unnecessary. If it does expire:
刷新腾讯文档 Access Token。
❓ What to do if the user cancels authorization?
If the user cancels third-party authorization in Tencent Docs settings, re-authorization is required:
重新执行腾讯文档 OAuth 授权流程。
❓ Document generated successfully but the content format is wrong?
The Tencent Docs v3 API uses JSON format to describe document structure (paragraphs, text, styles). If you find the format is wrong, you can ask WorkBuddy to adjust it:
调整腾讯文档生成格式: - 标题改为"一号、加粗、蓝色" - 正文改为"四号、宋体" - 段落首行缩进2字符 - 代码块用灰色背景
❓ Is there a limit on the number of documents?
Tencent Docs Open API provides each app with 20,000 free API calls(starting July 2025), which is enough for daily use. Contact the official team if you need more capacity.
❓ How to generate to a specified folder?
帮我写一篇关于"xxx"的文章,创建到腾讯文档的"周报"文件夹里。
❓ Scheduled task didn't run?
- Check whether WorkBuddy is kept running
- Check whether the Access Token has expired (refresh it with the command above)
- Copy the following command to check the task status:
检查每日腾讯文档生成定时任务状态,查看上次执行时间和下次执行时间。
| Configuration item | Description | Where to find it |
|---|---|---|
| Client ID | Unique application identifier | Open Platform → App Details |
| Client Secret | Application secret (keep confidential!) | Same as above, generated when creating the app |
| Callback URL | OAuth callback URL | http://localhost:8080/callback |
| Access Token | API call credential (30 days) | Automatically obtained after OAuth authorization |
| Refresh Token | Refresh credential (1 year) | Obtained together with the Access Token |
| API documentation | API reference | docs.qq.com/open/document/app |