Communitygithub.com

vercel-labs/slack

通过浏览器自动化与 Slack 工作区交互。用于检查未读频道、导航 Slack、发送消息、提取数据、查找信息、搜索对话或自动化任何 Slack 任务。触发词包括“检查我的 Slack”、“哪些频道有未读”、“发送消息到”、“在 Slack 中搜索”、“从 Slack 提取”、“查找谁说了”或任何需要程序化 Slack 交互的任务。

slack 是什么?

该技能利用 agent-browser 工具通过浏览器自动化与 Slack 交互,无需 Slack API、OAuth 或 bot token。其核心工作流包括连接或打开 Slack 会话、快照获取交互元素引用、导航频道并提取数据。技能详细展示了如何检查未读消息、跳转到特定频道、搜索关键字、提取频道信息和文档截图。支持 Linux、macOS、Windows 等平台(依赖 agent-browser),特别适合需要自动化 Slack 任务但无法使用 API 的场景。技能强调先快照后交互的最佳实践,并提供 wait 函数确保页面加载完成。其局限性是依赖当前浏览器会话,可能会受到 Slack 限速影响。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/vercel-labs/agent-browser/tree/main/skill-data/slack

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Slack 自动化

与 Slack 工作区交互,检查消息、提取数据并自动化常见任务。

快速开始

连接到现有的 Slack 浏览器会话或打开 Slack:

# 连接到现有会话(端口 9222,通常用于已打开的 Slack)
agent-browser connect 9222

# 如果 Slack 尚未运行,则打开它
agent-browser open https://app.slack.com

然后进行快照以查看可用的内容:

agent-browser snapshot -i

核心工作流

  1. 连接/导航:打开或连接到 Slack
  2. 快照:获取包含引用(@e1、@e2 等)的交互式元素
  3. 导航:点击标签、展开部分或导航到特定频道
  4. 提取/交互:读取数据或执行操作
  5. 截图:捕获结果的证据
# 示例:检查未读频道
agent-browser connect 9222
agent-browser snapshot -i
# 查找“更多未读”按钮
agent-browser click @e21  # “更多未读”按钮的引用
agent-browser screenshot slack-unreads.png

常见任务

检查未读消息

# 连接到 Slack
agent-browser connect 9222

# 进行快照以定位未读按钮
agent-browser snapshot -i

# 查找:
# - “更多未读”按钮(通常在侧边栏顶部附近)
# - “活动”标签中的“未读”切换(显示未读计数)
# - 带有徽章/粗体文本指示未读的频道名称

# 导航到“活动”标签以统一查看所有未读
agent-browser click @e14  # 活动标签(引用可能不同)
agent-browser wait 1000
agent-browser screenshot activity-unreads.png

# 或检查 DM 标签
agent-browser click @e13  # DM 标签
agent-browser screenshot dms.png

# 或展开侧边栏中的“更多未读”
agent-browser click @e21  # 更多未读按钮
agent-browser wait 500
agent-browser screenshot expanded-unreads.png

导航到频道

# 搜索侧边栏或名称中的频道
agent-browser snapshot -i

# 在列表中查找频道名称(例如,“engineering”、“product-design”)
# 点击频道 treeitem 引用
agent-browser click @e94  # 示例:engineering 频道引用
# 将 `engineering` 替换为点击的频道名称,以便旧频道头无法满足等待条件,而新频道仍在渲染。
agent-browser wait --fn "document.querySelector('[data-qa="channel_header"]')?.innerText.includes('engineering')"
agent-browser screenshot channel.png

查找消息/线程

# 使用 Slack 搜索
agent-browser snapshot -i
agent-browser click @e5  # 搜索按钮(典型引用)
agent-browser fill @e_search "keyword"
agent-browser press Enter
# 匹配提交的查询,以便重复搜索无法重用旧路由。
agent-browser wait --fn "location.pathname.includes('/search') && new URL(location.href).searchParams.get('q') === 'keyword'"
agent-browser screenshot search-results.png

提取频道信息

# 获取所有可见频道列表
agent-browser snapshot --json > slack-snapshot.json

# 解析频道名称和元数据
# 查找 level=2 的 treeitem 元素(各部分下的子频道)

检查频道详情

# 打开一个频道
agent-browser click @e_channel_ref
agent-browser wait 1000

# 获取频道信息(成员、描述等)
agent-browser snapshot -i
agent-browser screenshot channel-details.png

# 滚动查看消息
agent-browser scroll down 500
agent-browser screenshot channel-messages.png

记录笔记/捕获状态

当需要记录 Slack 中的发现时:

# 标注截图(显示元素编号)
agent-browser screenshot --annotate slack-state.png

# 全页截图
agent-browser screenshot --full slack-full.png

# 获取当前 URL 以供参考
agent-browser get url

# 获取页面标题
agent-browser get title

侧边栏结构

了解 Slack 的侧边栏有助于高效导航:

- 线程
- 群组通话
- 草稿和已发送
- 目录
- [节标题 – 外部连接、星标项、频道等]
  - [频道列为 treeitem]
- 直接消息
  - [DM 列出]
- 应用
  - [应用快捷方式]
- [更多未读] 按钮(切换未读频道列表)

要查找的关键引用:

  • @e12 – 首页标签(通常)
  • @e13 – DM 标签
  • @e14 – 活动标签
  • @e5 – 搜索按钮
  • @e21 – 更多未读按钮(因会话而异)

Slack 中的标签

点击频道后,您会看到标签:

  • 消息 – 频道对话
  • 文件 – 共享文件
  • 固定项 – 固定消息
  • 添加画布 – 协作画布
  • 其他标签(取决于工作区设置)

点击标签引用以切换视图并获取不同信息。

从 Slack 提取数据

获取文本内容

# 获取消息或元素的文本
agent-browser get text @e_message_ref

解析可访问性树

# 以 JSON 格式获取完整快照以进行程序化解析
agent-browser snapshot --json > output.json

# 查找:
# - 频道名称(treeitem 中的 name 字段)
# - 消息内容(在 listitem/document 元素中)
# - 用户名(带有用户信息的 button 元素)
# - 时间戳(带有时间信息的 link 元素)

计算未读数量

# 展开未读部分后:
agent-browser snapshot -i | grep -c "treeitem"
# 未读部分中的每个带有频道名称的 treeitem 都算作一个未读

最佳实践

  • 连接到现有会话:如果 Slack 已打开,请使用 agent-browser connect 9222。这比打开新浏览器更快。
  • 在点击前进行快照:始终先执行 snapshot -i 以识别引用,然后再点击按钮。
  • 导航后重新快照:导航到新频道或部分后,进行全新快照以找到新的引用。
  • 使用 JSON 快照进行解析:当需要提取结构化数据时,使用 snapshot --json 获得机器可读的输出。
  • 控制交互节奏:在快速交互之间添加 sleep 1 以允许 UI 更新。
  • 检查可访问性树:可访问性树显示屏幕阅读器(和您的自动化)能看到的内容。如果元素不在快照中,它可能已隐藏或需要滚动。
  • 在侧边栏中滚动:如果频道列表很长,使用 agent-browser scroll down 300 --selector ".p-sidebar" 在 Slack 侧边栏中滚动。

局限性

  • 无法访问 Slack API:这使用浏览器自动化,而非 Slack API。不需要 OAuth、webhook 或 bot token。
  • 会话特定:截图和快照绑定到当前浏览器会话。
  • 速率限制:Slack 可能会限制快速交互。如有必要,请在命令之间添加延迟。
  • 工作区特定:您只能交互自己的工作区——不支持跨工作区自动化。

调试

检查控制台错误

agent-browser console
agent-browser errors

获取当前页面状态

agent-browser get url
agent-browser get title
agent-browser screenshot page-state.png

示例:完整未读检查

#!/bin/bash

# 连接到 Slack
agent-browser connect 9222

# 进行初始快照
echo "=== 检查 Slack 未读 ==="
agent-browser snapshot -i > snapshot.txt

# 检查“活动”标签中的未读
agent-browser click @e14  # 活动标签
agent-browser wait 1000
agent-browser screenshot activity.png
ACTIVITY_RESULT=$(agent-browser get text @e_main_area)
echo "活动:$ACTIVITY_RESULT"

# 检查 DM
agent-browser click @e13  # DM 标签
agent-browser wait 1000
agent-browser screenshot dms.png

# 检查侧边栏中的未读频道
agent-browser click @e21  # 更多未读按钮
agent-browser wait 500
agent-browser snapshot -i > unreads-expanded.txt
agent-browser screenshot unreads.png

# 摘要
echo "=== 摘要 ==="
echo "详见 activity.png、dms.png 和 unreads.png"

参考

Individual skills in this repo

This repo contains 8 individual skills — each has its own dedicated page.

agent-browser

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to

vercel-labs/agentcore

Run agent-browser on AWS Bedrock AgentCore cloud browsers. Use when the user wants to use AgentCore, run browser automation on AWS, use a cloud browser with AWS credentials, or needs a managed browser session backed by AWS infrastructure. Triggers include "use agentcore", "run on AWS", "cloud browser with AWS", "bedrock browser", "agentcore session", or any task requiring AWS-hosted browser automation.

vercel-labs/derive-client

Reverse-engineer a website's internal API by recording browser traffic into a HAR file, then generate a standalone client or CLI that calls the endpoints directly, with no browser needed after the first recording. Use when asked to "derive a client", "build a CLI for <site>", "reverse engineer this site's API", "record network requests", "turn this site into an API", or when the same site will be automated repeatedly and direct HTTP calls would beat driving the browser every time.

vercel-labs/dogfood

Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to "dogfood", "QA", "exploratory test", "find issues", "bug hunt", "test this app/site/platform", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.

vercel-labs/electron

Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include "automate Slack app", "control VS Code", "interact with Discord app", "test this Electron app", "connect to desktop app", or any task requiring automation of a native Electron application.

vercel-labs/protected-vercel-deployments

Access and test Vercel deployments protected by Vercel Authentication, SSO, or Deployment Protection with agent-browser. Use when a preview or production URL redirects to a Vercel login page, returns a protection 401 or 403, or needs short-lived Trusted Sources OIDC authentication instead of a static bypass secret or public exception.

vercel-labs/vercel-sandbox

Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include "Vercel Sandbox browser", "microVM Chrome", "agent-browser in sandbox", "browser automation on Vercel", or any task requiring Chrome in a Vercel Sandbox.

vercel-labs/webmcp-gen

Build and validate experimental WebMCP tools for an existing web page. Use when an agent needs to expose a site's real workflows as page tools, create webmcp.init.js, define deterministic checks, or compare WebMCP with accessibility-tree automation.

相关技能