create-feishu-doc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Feishu Document Automation
飞书文档创建自动化
Purpose
用途
Automate the process of creating new documents in Feishu (Lark) workspace by using browser automation to navigate the UI, authenticate, and create documents with specified titles and content.
通过浏览器自动化操作UI界面、完成身份验证并创建带有指定标题和内容的文档,从而实现飞书(Lark)工作区中新文档创建流程的自动化。
When to Use This Skill
何时使用此Skill
Use this skill when:
- User asks to create a new document in Feishu
- User wants to automate document creation in their Feishu workspace
- User needs to quickly create documents without manual UI interaction
在以下场景中使用此Skill:
- 用户要求在飞书中新建文档
- 用户希望自动化其飞书工作区中的文档创建流程
- 用户需要无需手动操作UI即可快速创建文档
Prerequisites
前置条件
- Access to Feishu workspace (https://leiniao-ibg.feishu.cn)
- Valid authentication credentials for the workspace
- Browser automation capability via
agent-browser
- 拥有飞书工作区访问权限(https://leiniao-ibg.feishu.cn)
- 该工作区的有效身份验证凭据
- 可通过实现浏览器自动化的能力
agent-browser
Workflow
工作流程
Step 1: Load Browser Automation Skill
步骤1:加载浏览器自动化Skill
Load the skill using the Skill tool to access browser automation commands.
office:agent-browser使用Skill工具加载Skill,以获取浏览器自动化命令的访问权限。
office:agent-browserStep 2: Navigate to Feishu Drive
步骤2:导航至飞书云文档
Open the Feishu Drive homepage:
bash
agent-browser open https://leiniao-ibg.feishu.cn/drive/home/Wait for page to load:
bash
agent-browser wait --load networkidle打开飞书云文档首页:
bash
agent-browser open https://leiniao-ibg.feishu.cn/drive/home/等待页面加载完成:
bash
agent-browser wait --load networkidleStep 3: Verify Authentication
步骤3:验证身份验证状态
Take a snapshot to check if already logged in:
bash
agent-browser snapshot -iIf login is required, wait for user to complete authentication manually or handle authentication flow based on the page state.
截取快照以检查是否已登录:
bash
agent-browser snapshot -i如果需要登录,请等待用户手动完成身份验证,或根据页面状态处理身份验证流程。
Step 4: Create New Document
步骤4:新建文档
Click the "新建" (New) button (use snapshot to locate the element ref):
bash
agent-browser snapshot -i点击「新建」按钮(使用快照定位元素引用):
bash
agent-browser snapshot -iLocate "新建" button ref (e.g., @e1)
定位「新建」按钮引用(例如:@e1)
agent-browser click @e1
Wait for dropdown menu to appear:
```bash
agent-browser wait 1000Take another snapshot to locate the "文档" (Doc) option:
bash
agent-browser snapshot -iagent-browser click @e1
等待下拉菜单出现:
```bash
agent-browser wait 1000再次截取快照以定位「文档」选项:
bash
agent-browser snapshot -iLocate "文档" button ref (e.g., @e2)
定位「文档」按钮引用(例如:@e2)
agent-browser click @e2
undefinedagent-browser click @e2
undefinedStep 5: Select New Document Type
步骤5:选择新文档类型
Click the "新建空白文档" (New Doc) option from the submenu:
bash
agent-browser wait 1000
agent-browser snapshot -i点击子菜单中的「新建空白文档」选项:
bash
agent-browser wait 1000
agent-browser snapshot -iLocate "新建空白文档" button ref (e.g., @e3)
定位「新建空白文档」按钮引用(例如:@e3)
agent-browser click @e3
undefinedagent-browser click @e3
undefinedStep 6: Wait for New Tab
步骤6:等待新标签页打开
Wait for the new document to open in a new tab:
bash
agent-browser wait --load networkidleCheck tabs to ensure new document page opened:
bash
agent-browser tabIf multiple tabs exist, switch to the newest tab (usually the last one):
bash
agent-browser tab 2 # Adjust index based on tab list等待新文档在新标签页中打开:
bash
agent-browser wait --load networkidle检查标签页以确保新文档页面已打开:
bash
agent-browser tab如果存在多个标签页,切换到最新的标签页(通常是最后一个):
bash
agent-browser tab 2 # 根据标签页列表调整索引Step 7: Enter Document Title
步骤7:输入文档标题
The page should automatically focus on the title input field. If the title field is focused by default, type the title directly:
bash
agent-browser type @e1 "Document Title Here"If not automatically focused, take a snapshot to locate the title input:
bash
agent-browser snapshot -i页面应自动聚焦到标题输入框。如果标题框已默认聚焦,直接输入标题:
bash
agent-browser type @e1 "Document Title Here"如果未自动聚焦,截取快照以定位标题输入框:
bash
agent-browser snapshot -iLocate title input ref (e.g., @e1)
定位标题输入框引用(例如:@e1)
agent-browser fill @e1 "Document Title Here"
undefinedagent-browser fill @e1 "Document Title Here"
undefinedStep 8: Enter Document Content
步骤8:输入文档内容
Press Tab or click to move to the content area:
bash
agent-browser press TabOr locate and click the content editor:
bash
agent-browser snapshot -i按Tab键或点击切换到内容区域:
bash
agent-browser press Tab或者定位并点击内容编辑器:
bash
agent-browser snapshot -iLocate content editor ref (e.g., @e2)
定位内容编辑器引用(例如:@e2)
agent-browser click @e2
Type the document content:
```bash
agent-browser type @e2 "Document content goes here..."For multi-line content, use newlines in the input:
bash
agent-browser type @e2 "First paragraph
Second paragraph
Third paragraph"agent-browser click @e2
输入文档内容:
```bash
agent-browser type @e2 "Document content goes here..."对于多行内容,在输入中使用换行符:
bash
agent-browser type @e2 "First paragraph
Second paragraph
Third paragraph"Step 9: Verify and Save
步骤9:验证并保存
Take a final screenshot to verify the document was created successfully:
bash
agent-browser screenshotFeishu documents auto-save, so no explicit save action is required. The document is now ready to use.
截取最终截图以验证文档是否创建成功:
bash
agent-browser screenshot飞书文档会自动保存,因此无需执行显式的保存操作。文档现已可正常使用。
Step 10: Close Browser (Optional)
步骤10:关闭浏览器(可选)
Close the browser session when done:
bash
agent-browser close完成操作后关闭浏览器会话:
bash
agent-browser closeError Handling
错误处理
Authentication Issues
身份验证问题
If authentication fails or login is required:
- Pause the workflow
- Inform the user that manual login is needed
- Wait for confirmation before proceeding
- Resume workflow after authentication
如果身份验证失败或需要登录:
- 暂停工作流
- 告知用户需要手动登录
- 等待用户确认后再继续
- 身份验证完成后恢复工作流
Element Not Found
元素未找到
If snapshot cannot locate expected UI elements (button refs):
- Take a full snapshot without flag for debugging
-i - Check if UI has changed or language settings differ
- Use semantic locators as fallback:
bash
agent-browser find text "新建" click # Find "新建" (New) button agent-browser find text "文档" click # Find "文档" (Doc) button agent-browser find text "新建空白文档" click # Find "新建空白文档" (New Doc) button
如果快照无法定位到预期的UI元素(按钮引用):
- 不带标志截取完整快照以进行调试
-i - 检查UI是否发生变化或语言设置不同
- 使用语义定位器作为备选方案:
bash
agent-browser find text "新建" click # 查找并点击「新建」按钮 agent-browser find text "文档" click # 查找并点击「文档」按钮 agent-browser find text "新建空白文档" click # 查找并点击「新建空白文档」按钮
Timeout Issues
超时问题
If page loading takes too long:
- Increase wait timeout:
agent-browser wait --load networkidle --timeout 10000 - Check network connectivity
- Verify Feishu service availability
如果页面加载耗时过长:
- 增加等待超时时间:
agent-browser wait --load networkidle --timeout 10000 - 检查网络连接情况
- 验证飞书服务的可用性
Customization
自定义设置
Different Workspace
不同工作区
To use with a different Feishu workspace, replace the URL in Step 2:
bash
agent-browser open https://your-workspace.feishu.cn/drive/home/要在其他飞书工作区中使用,替换步骤2中的URL:
bash
agent-browser open https://your-workspace.feishu.cn/drive/home/Document Templates
文档模板
To use a specific document template instead of blank document:
- Navigate to template gallery after clicking "Doc"
- Locate and click the desired template
- Proceed with title and content entry
要使用特定文档模板而非空白文档:
- 点击「文档」后导航至模板库
- 定位并点击所需模板
- 继续进行标题和内容的输入
Best Practices
最佳实践
- Session Reuse: For multiple document creations, keep the browser session open and reuse authentication state
- Error Screenshots: Take screenshots at each critical step for debugging
- Wait for UI: Always wait for network idle after navigation to ensure UI elements are loaded
- Explicit Waits: Use explicit waits (e.g., ) after clicking dropdown menus
agent-browser wait 1000
- 会话复用:如需创建多个文档,保持浏览器会话打开并复用身份验证状态
- 错误截图:在每个关键步骤截取截图以方便调试
- 等待UI加载:导航后始终等待网络空闲,确保UI元素已加载完成
- 显式等待:点击下拉菜单后使用显式等待(例如:)
agent-browser wait 1000
Additional Resources
额外资源
Browser Automation Reference
浏览器自动化参考
For detailed browser automation commands and patterns:
- Load skill for complete command reference
office:agent-browser - See snapshot and interaction patterns in agent-browser documentation
如需了解详细的浏览器自动化命令和模式:
- 加载Skill以获取完整的命令参考
office:agent-browser - 查看agent-browser文档中的快照和交互模式
Example Usage
使用示例
bash
undefinedbash
undefinedComplete workflow example
完整工作流示例
agent-browser open https://leiniao-ibg.feishu.cn/drive/home/
agent-browser wait --load networkidle
agent-browser snapshot -i
agent-browser click @e1 # 新建 button
agent-browser wait 1000
agent-browser snapshot -i
agent-browser click @e2 # 文档 button
agent-browser wait 1000
agent-browser snapshot -i
agent-browser click @e3 # 新建空白文档 button
agent-browser wait --load networkidle
agent-browser tab
agent-browser tab 2 # Switch to new tab
agent-browser type @e1 "My Document Title"
agent-browser press Tab
agent-browser type @e2 "My document content..."
agent-browser screenshot
undefinedagent-browser open https://leiniao-ibg.feishu.cn/drive/home/
agent-browser wait --load networkidle
agent-browser snapshot -i
agent-browser click @e1 # 新建按钮
agent-browser wait 1000
agent-browser snapshot -i
agent-browser click @e2 # 文档按钮
agent-browser wait 1000
agent-browser snapshot -i
agent-browser click @e3 # 新建空白文档按钮
agent-browser wait --load networkidle
agent-browser tab
agent-browser tab 2 # 切换到新标签页
agent-browser type @e1 "My Document Title"
agent-browser press Tab
agent-browser type @e2 "My document content..."
agent-browser screenshot
undefined