Skills2026年3月30日·1 分钟阅读

Lark CLI Skill: Events — Real-Time Event Subscriptions

Lark/Feishu CLI skill for event-driven workflows. WebSocket real-time event listening with regex routing and NDJSON output.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Stage only
信任
信任等级:Community
入口
Lark CLI Skill: Events — Real-Time Event Subscriptions
安全暂存命令
npx -y tokrepo@latest install d74aa20d-6376-47bd-8e48-8e9af76504e9 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
Lark CLI skill that enables real-time WebSocket event listening with regex routing and NDJSON output.
§01

What it is

This is a Lark/Feishu CLI skill for event-driven workflows. It provides WebSocket real-time event listening with regex-based routing and NDJSON output, designed for automation pipelines and integrations.

The skill is part of the Lark CLI, a command-line tool for the Lark/Feishu Open Platform. It is best for teams using Lark/Feishu for workplace collaboration who want to build event-driven automations.

§02

How it saves time or tokens

Instead of polling the Lark API for changes, this skill uses WebSocket connections to receive events in real time. Regex routing filters events at the source, reducing noise in your pipeline. NDJSON output integrates directly with tools like jq, making it easy to chain event processing without writing custom parsers. The estimated token cost is around 500 tokens.

§03

How to use

  1. Install the Lark CLI and this skill:
npm install -g @larksuite/cli
npx skills add larksuite/cli -y -g
  1. Configure authentication:
lark-cli config init
lark-cli auth login --recommend
  1. Start listening for events with regex filtering
§04

Example

# Listen for all message events
lark-cli events listen --pattern 'im.message.*'

# Filter to specific event types with NDJSON output
lark-cli events listen --pattern 'im.message.receive_v1' --format ndjson

# Pipe to jq for processing
lark-cli events listen --pattern 'im.message.*' --format ndjson | \
  jq '.event.message.content'
§05

Related on TokRepo

§06

Common pitfalls

  • Not completing the auth setup before trying to listen for events
  • Using overly broad regex patterns that flood your pipeline with irrelevant events
  • Forgetting that WebSocket connections need to be re-established after network interruptions

常见问题

What is the Lark CLI?+

The Lark CLI is a command-line tool for the Lark/Feishu Open Platform with 200+ commands and 19 AI Agent Skills. It provides programmatic access to Lark workspace features including messaging, documents, and event subscriptions.

How does regex routing work for events?+

You specify a regex pattern when subscribing to events. Only events whose type matches the pattern are forwarded to your listener. This filters at the WebSocket level, reducing the data your pipeline processes.

What is NDJSON output format?+

NDJSON (Newline Delimited JSON) outputs one JSON object per line. This format works well with streaming tools like jq, grep, and awk, making it easy to build Unix-style processing pipelines for Lark events.

Can I use this skill with Feishu (the China version)?+

Yes. The Lark CLI supports both Lark (international) and Feishu (China) platforms. The events skill works with both, using the appropriate API endpoints based on your configuration.

Does the skill handle reconnection automatically?+

The WebSocket connection management is handled by the Lark CLI. If the connection drops, the CLI attempts to reconnect automatically. For production use, wrap the listener in a process manager like PM2.

引用来源 (3)
🙏

来源与感谢

Created by LarkSuite. Licensed under MIT. larksuite/cli — 4,100+ GitHub stars

Part of the Lark CLI Official Skills Collection on TokRepo.

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产