跳到正文
Skillpedia
自动化18k · #10731

lark-event

它能做什么

这个技能帮助 AI 智能体实时接收 Lark 或 Feishu 的更新,例如新的聊天消息或任务变化。适合搭建需要在事情发生时立即做出反应的机器人或工作流程的人。

适用场景

  • ✓当你希望 Lark 或 Feishu 机器人在收到新消息时自动回复时。
  • ✓当你需要追踪 Lark 中的审批状态变化并逐一处理时。
  • ✓当你正在搭建长期运行的监听程序,逐个处理 Lark 事件时。

技能链接

https://github.com/larksuite/cli/blob/main/skills/lark-event/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/larksuite/cli/blob/main/skills/lark-event/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我设置一个监听程序,在我们的 Lark 群组收到新消息时做出反应,并记录每一条消息。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会启动一个 Lark 命令,监听所选的事件类型,并把每个事件作为一行数据接收。它可以筛选事件、限制读取数量,或在设定时间后停止。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Lark Events

Prerequisite: Read ../lark-shared/SKILL.md first for authentication, --as user/bot switching, Permission denied handling, and safety rules.

Core commands

Command Purpose
lark-cli event list [--json] List all subscribable EventKeys
lark-cli event schema <EventKey> [--json] Show an EventKey's params and output schema
lark-cli event consume <EventKey> [flags] Blocking consume; events → stdout NDJSON
lark-cli event status [--json] [--fail-on-orphan] Inspect the local bus daemon status
lark-cli event stop [--all] [--force] Stop the bus daemon

Common flags

Flag Description
--param key=value / -p Business params (repeatable; comma-separated for multi-value). Unknown keys fail with valid names listed inline
--jq <expr> jq expression to filter / transform each event; empty output skips the event
--max-events N Exit after N events. Default 0 = unlimited
--timeout D Exit after duration D (e.g. 30s, 2m). Default 0 = no timeout. Whichever of --max-events / --timeout fires first wins
--output-dir <dir> Write each event as a file (relative paths only; prevents traversal)
--quiet Suppress ready/exit markers and per-event stderr diagnostics, including drop warnings. This can hide event loss. AI should not use this — it removes readiness and integrity signals
--as user|bot|auto Identity for the session (see lark-shared)

Examples

# Default: stream every event for the key (no filter, no projection)
lark-cli event consume im.message.receive_v1 --as bot

# List every EventKey of one domain (the authoritative, always-current catalog)
lark-cli event list --domain vc --json

# Grab one sample event to inspect payload shape
lark-cli event consume im.message.receive_v1 --max-events 1 --timeout 30s --as bot

# Run for 10 minutes then auto-exit
lark-cli event consume im.message.receive_v1 --timeout 10m --as bot

# Consume multiple EventKeys concurrently (one shape per process, no dispatcher)
lark-cli event consume im.message.receive_v1          --as bot > receive.ndjson &
lark-cli event consume im.message.reaction.created_v1 --as bot > reaction.ndjson &
wait

Call flow

  1. lark-cli event list --json → pick a legal key. --domain <d> narrows to one domain; the domains are application, approval, board, card, im, minutes, task, vc. An unknown domain fails with the valid set listed in the hint.
  2. lark-cli event schema <key> --json → read resolved_output_schema + jq_root_path to determine field paths
  3. lark-cli event consume <key> [--jq '<expr>'] → consume

Subprocess contract

Ready marker

event consume's stderr emits a fixed line [event] ready event_key=<key>. Parent processes should block on stderr until this line appears, then start reading stdout. Do not fall back to sleep.

stdin EOF = graceful exit

event consume treats stdin close as a shutdown signal (wired for AI subprocess callers). Bounded runs are exempt: when --max-events or --timeout is set (> 0), stdin EOF is ignored and the run exits only via its own bound, timeout, or SIGTERM. For unbounded runs, < /dev/null / nohup / systemd's default StandardInput=null will cause an immediate graceful exit (stderr reason: signal). To keep an unbounded run alive:

  • Feed stdin a source that never EOFs: < <(tail -f /dev/null)
  • Or run bounded: --max-events N / --timeout D

Exit codes & reason

On exit, the last stderr line is [event] exited — received N event(s) in Xs (reason: ...).

exit code reason Trigger
0 reason: limit --max-events reached
0 reason: timeout --timeout reached
0 reason: signal Ctrl+C / SIGTERM / stdin EOF (stdin EOF applies to unbounded runs only)
1 JSON error envelope on stderr Lark API business failure during pre-consume setup (for example subscription create/delete)
2 JSON error envelope on stderr (no exited line) Validation failure (unknown EventKey, bad --param / --jq, another bus already connected)
3 JSON error envelope on stderr Auth failure (missing token, missing scopes)
4 / 5 JSON error envelope on stderr Network / internal failure (bus startup, handshake, file I/O)

Startup and runtime failures emit a structured JSON envelope on stderr: `{"ok":false,"error":{"type"

常见问题

使用前需要登录 Lark 吗?

需要。该技能指向一份共享的 Lark 设置指南,其中包括登录和权限说明,应先阅读。

智能体能限制接收的事件数量吗?

可以。监听程序可以在达到设定数量或设定时间后停止。

能把每个事件保存到文件吗?

可以。该技能可以把每个事件写入你选择的文件夹中的文件。

详情

作者的原始描述

Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM messages/reactions/chat changes, Approval status changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.

repo: larksuite/cli

热度

GitHub 星标
18k
排名
#10731
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能