Give Your Coding Agent Direct Feishu Group Access: A Real Landing Page Workflow
Let AI Agent Read Feishu Group Chat Directly to Work for Me: A Real Landing Page Project Retrospective
A reusable approach: hand Feishu group chats, spreadsheets, and attachments to a coding agent, and let it read requirements, change code, verify, and report on its own. Names, clients, projects, accounts, keys, and domains mentioned in the post have been anonymized; command structure is preserved as is.
1. The Pain Point
When delivering frontend/landing page projects, requirements are scattered in Feishu group chats:
- The client contact throws a screenshot: "This corner is missing a piece."
- Operations drops a Feishu spreadsheet: "Event code updated, please handle it."
- QA sends a screen recording: "It's still hollow on iOS."
- Data engineer shares a database screenshot: "These two rows are wrong."
Previously the action was: read the group manually → understand → switch windows to change code → reply with a screenshot. Most of the day was spent moving information around.
The goal is direct: Let the agent read the group on its own, find things relevant to me, act directly, and post the conclusion.
2. Overall Approach
Feishu (group chat / spreadsheet / attachment)
| lark-cli (CLI, outputs JSON)
v
Agent (DSH)
| read JSON -> judge relevance -> execute task
v
Repo code / build artifacts / local verification -> sync back to group
Three key choices:
- Use CLI instead of plugin: one command, one JSON. The agent naturally composes arguments, can massage output with scripts, and debugging is direct.
- Write full JSON to disk and parse:
--format jsonoutputs to a file, read with Python, avoiding shoving large raw JSON into context. - Let the agent judge "is this relevant to me?": Not every group message requires action. Judgment matters more than automation.
3. Environment Setup
# 1. Install lark-cli
npm i -g @larksuite/cli
# 2. Log in as "myself" (not a bot)
lark-cli auth login --as user
# 3. Verify
lark-cli auth status
Key points:
- Must use
--as user. A bot identity cannot read the groups you are in. - Required permissions approximately: read messages, read message resources, read spreadsheets (apply least privilege).
- When the CLI reports errors, it provides troubleshooting links; just fill in the missing permissions accordingly.
4. Command Quick Reference (Only 4 High-Frequency Commands)
1. Read Group Messages (Latest N, Descending)
lark-cli im +chat-messages-list \
--chat-id "oc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--page-size 25 \
--order desc \
--no-reactions \
--as user --format json > /tmp/msgs.json
--chat-id: group ID (starts withoc_) or single-chat ID--no-reactions: skip emoji reactions, cuts down noise fields--order desc: newest first, most useful in practice — check if anyone @'d me first
2. Download Images / Files / Videos from a Message
lark-cli im +messages-resources-download \
--message-id "om_xxxxxxxxxxxxxxxxxxxxx" \
--file-key "img_v3_xxxxxxxxxxxx" \
--type image \
--output ./shot.bin \
--as user --format json
Key points:
--typeisimageorfile; videos (.mov/.mp4) usefile- Save as
.binand detect the real format (experienced.gifsuffix actually being WebP) message-idmust match: for images in rich text (post) messages, use the post'smessage_id, not the image's own ID
3. Read a Sheet in a Feishu Spreadsheet
# First see which sheets exist
lark-cli sheets +workbook-info \
--spreadsheet-token "xxxxxxxxxxxxxxxx" --as user --format json
# Then fetch values by sheet name and range (value mode: only values)
lark-cli sheets +cells-get \
--spreadsheet-token "xxxxxxxxxxxxxxxx" \
--sheet-name "Sheet2" \
--range "A1:H20" \
--include value \
--as user --format json > /tmp/sheet.json
Key points:
- When a document has multiple sheets, you must specify
--sheet-name. Pitfall: read only the first sheet, miss the one actually in use, waste a round trip. --include valueis much cleaner than default output (no styles/formulas).- Cells may be rich text arrays; use the
.valuefield to get plain text.
4. Read Cloud Document Body
lark-cli docs +fetch --doc "https://xxx.feishu.cn/wiki/xxxx" --as user --format json
⚠️ A wiki link may point to either a "document" or a "spreadsheet":
{"ok":false,"error":{"code":3380002,"message":"Unsupported document type 'sheet'. Only docx is supported."}}
When you see this, don't change anything; switch to sheets +cells-get to read it.
5. A Complete End-to-End Example (Anonymized)
Step 1: Read the Group, Judge Relevance
lark-cli im +chat-messages-list --chat-id "$CHAT" --page-size 25 --order desc \
--no-reactions --as user --format json > msgs.json
Use Python to print as "time | sender | content" columns:
18:40 | Contact A | @me Please copy an html separately, embed the code provided by B, and give me the page
18:37 | QA B | @ContactA @me Who is embedding the landing page?
18:35 | Ops C | I can't download code on the platform side, code needs to be provided by R&D
→ Conclusion: It involves me (@me, and requires delivering an html file).
Step 2: Read the Requirements Document / Spreadsheet
The link in the group is a wiki → docs +fetch reports Unsupported document type 'sheet' → switch to sheets +cells-get.
Read key info (example, all values anonymized):
| Item | Prod Config | Test Config (another sheet) |
|---|---|---|
| Tracking ID prefix | AAA… |
BBB… (different) |
| Page view PV | trackId 11 | trackId 21 |
| Page visit duration | trackId 12 | trackId 22 |
| Button click | trackId 13 | trackId 23 |
This is the easiest place to trip up: the same document has two sheets, one prod, one test, and event IDs are all off. If you only read the first sheet, the code is wrong.
Step 3: Modify the Code
- Copy a separate directory (don't touch the live prod version — the group explicitly said "don't change the page in prod")
- Use placeholder replacement for ID shifts to avoid chained replacements:
s = s.replace('trackId: "11"', 'trackId: "__A__"') # 11 -> 21
s = s.replace('trackId: "12"', 'trackId: "__B__"') # 12 -> 22
s = s.replace('trackId: "13"', 'trackId: "__C__"') # 13 -> 23
s = s.replace('trackId: "__A__"', 'trackId: "21"')
s = s.replace('trackId: "__B__"', 'trackId: "22"')
s = s.replace('trackId: "__C__"', 'trackId: "23"')
Sequential replacement of
11→21then12→22looks safe because values differ, but if you do adjacent values like5→6,6→7, you'd re-replace the just-replaced value. Uniform placeholders are safest.
Step 4: Local Verification (Key: Not by Eyeballing)
Intercept the real SDK, inject a fake recorder, and check which events are actually called:
await page.route("**/sdk.js", r => r.abort()); // block real reporting, don't pollute data
await page.addInitScript(() => {
window.__calls = [];
window.py = function () { window.__calls.push(Array.from(arguments)); };
});
// open page → click button → read window.__calls
Output:
On load: custom{21} → custom{22}
On button click: additional custom{23}
This is more reliable than a screenshot: you see event names, IDs, and ordering. A screenshot can only show "the page looks right".
Step 5: Hand Off the File
The recipient wants a directly uploadable html file, not a link. So the artifact is a single-file version: all images inlined as data URIs.
data = "data:image/webp;base64," + base64.b64encode(open(p, "rb").read()).decode()
html = html.replace("images/big.webp", data)
One file, 1~2 MB, no lost images when sending.
6. Pitfall Checklist (All Real)
| # | Pitfall | Handling |
|---|---|---|
| 1 | Wiki link points to a spreadsheet, docs +fetch fails with Unsupported document type 'sheet' |
Switch to sheets +cells-get |
| 2 | Document has multiple sheets; only read the first | Run +workbook-info to list all, specify --sheet-name |
| 3 | Image in rich text message, downloading with image ID fails | Use the message_id of that post |
| 4 | .gif suffix is actually WebP |
Save as .bin and detect real format |
| 5 | Determine if message @'s me | Read sender.name + @名字 in content, don't rely on mentions field |
| 6 | Large JSON in context burns tokens | --format json > file, only print needed columns |
| 7 | Cross-day messages, misjudge "just now" | Print full create_time, don't use relative time |
| 8 | Timestamps in screenshots are in milliseconds | Convert by milliseconds, not seconds |
| 9 | Same person resends same requirement | Sort by create_time, take latest |
| 10 | In group, "done" means their side is configured, not asking me to act | Don't execute just because you see "done", confirm the subject first |
7. Giving the Agent "Judgment" Matters More Than "Full Automation"
In practice, the most valuable thing is not auto-replies, but the ability to judge "is this relevant to me?"
Rules given to the agent:
1. Look at the latest 20 messages, mark all that mention my name or my job responsibility
2. Classify each: notification (no action), question (needs answer), or assignment (needs execution)
3. For assignments: first read linked docs/spreadsheets, then act, finally report conclusion + evidence
4. For notifications: only reply "ok" if @'d
5. If uncertain, ask a human, don't guess
Actual output looks like (anonymized):
This one involves you: QA at 18:37 directly @'d you, you haven't replied yet. He asked "Who is doing the landing page embedding?". Also at 18:39 the contact explicitly said "don't touch the page running in prod" — this is a hard constraint for you.
This is far more useful than "reply to all messages".
8. Security Boundaries (Very Important)
| Item | Practice |
|---|---|
| Credentials | CLI token stored locally, never print token to logs or context |
| Read scope | Only read groups / docs relevant to the current project, no full traversal |
| Sensitive info | Passwords, phone numbers, ID numbers from group should not be written into repo or blog |
| External actions | Must confirm before sending messages / files; only send when user says "send" |
| Blog writing | Anonymize names, clients, project names, accounts, keys, internal domains |
9. Optional Automation: Scheduled "Inspection"
If you want a summary every morning:
- Trigger: 09:30 on workdays
- Task: read group messages after 18:00 yesterday → extract "to-dos relevant to me + things I need to reply to" → output checklist
- Goal: continue working in the same conversation
⚠️ Prerequisite: Scheduled tasks must be created only when explicitly requested by the user, no self-initiated polling.
10. Results
In the same batch of projects, this workflow supported:
- Reading group messages 50+ times (requirement changes, acceptance feedback, data verification)
- Downloading and analyzing 20+ screenshots / 6 screen recordings
- Reading 3 versions of event tracking configuration in spreadsheets
- Zero errors in information transport; rework all stemmed from "misunderstanding requirements", not "misreading data"
The most valuable summary:
An agent won't judge whether a requirement is correct, but it guarantees that the information you see always matches what's in the group.
Appendix: Minimal Working Script
import json, subprocess
CHAT = "oc_xxxxxxxx"
out = subprocess.run([
"lark-cli", "im", "+chat-messages-list",
"--chat-id", CHAT, "--page-size", "20", "--order", "desc",
"--no-reactions", "--as", "user", "--format", "json",
], capture_output=True)
data = json.loads(out.stdout.decode("utf-8"))
for m in data["data"]["messages"]:
who = (m.get("sender") or {}).get("name") or ""
text = (m.get("content") or "").replace("\n", " ")
print(f'{m["create_time"]} | {who} | {m.get("msg_type")} | {text[:200]}')
Run it once and you'll know what's being said in the group.