Skip to content

Commit 50b91bd

Browse files
m1hengclaude
andcommitted
docs: add Feishu to README, CLAUDE.md, example app, and configs
- README.md: add Feishu to platform list, install command, feature matrix, and packages table - CLAUDE.md: add Feishu to build commands, package structure, thread ID format, recording analysis, and env vars - examples/nextjs-chat: add Feishu adapter integration, env vars, and documentation - .env.example: add Feishu credential template Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b6d51ea commit 50b91bd

File tree

7 files changed

+52
-16
lines changed

7 files changed

+52
-16
lines changed

CLAUDE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pnpm --filter chat build
3535
pnpm --filter @chat-adapter/slack build
3636
pnpm --filter @chat-adapter/gchat build
3737
pnpm --filter @chat-adapter/teams build
38+
pnpm --filter @chat-adapter/feishu build
3839

3940
# Run tests for a specific package
4041
pnpm --filter chat test
@@ -59,6 +60,7 @@ This is a **pnpm monorepo** using **Turborepo** for build orchestration. All pac
5960
- **`packages/adapter-slack`** - Slack adapter using `@slack/web-api`
6061
- **`packages/adapter-gchat`** - Google Chat adapter using `googleapis`
6162
- **`packages/adapter-teams`** - Microsoft Teams adapter using `botbuilder`
63+
- **`packages/adapter-feishu`** - Feishu (Lark) adapter using direct fetch
6264
- **`packages/state-memory`** - In-memory state adapter (for development/testing)
6365
- **`packages/state-redis`** - Redis state adapter (for production)
6466
- **`packages/integration-tests`** - Integration tests against real platform APIs
@@ -67,7 +69,7 @@ This is a **pnpm monorepo** using **Turborepo** for build orchestration. All pac
6769
### Core Concepts
6870

6971
1. **Chat** (`packages/chat-sdk/src/chat.ts` in `chat` package) - Main entry point that coordinates adapters and handlers
70-
2. **Adapter** - Platform-specific implementations (Slack, Teams, Google Chat). Each adapter:
72+
2. **Adapter** - Platform-specific implementations (Slack, Teams, Google Chat, Feishu). Each adapter:
7173
- Handles webhook verification and parsing
7274
- Converts platform-specific message formats to/from normalized format
7375
- Provides `FormatConverter` for markdown/AST transformations
@@ -82,6 +84,7 @@ All thread IDs follow the pattern: `{adapter}:{channel}:{thread}`
8284
- Slack: `slack:C123ABC:1234567890.123456`
8385
- Teams: `teams:{base64(conversationId)}:{base64(serviceUrl)}`
8486
- Google Chat: `gchat:spaces/ABC123:{base64(threadName)}`
87+
- Feishu: `feishu:oc_abc123:om_msg456`
8588

8689
### Message Handling Flow
8790

@@ -160,6 +163,7 @@ cat /tmp/recording.json | jq '[.[] | select(.type == "webhook")] | group_by(.pla
160163
cat /tmp/recording.json | jq '[.[] | select(.type == "webhook" and .platform == "teams") | .body | fromjson]' > /tmp/teams-webhooks.json
161164
cat /tmp/recording.json | jq '[.[] | select(.type == "webhook" and .platform == "slack") | .body | fromjson]' > /tmp/slack-webhooks.json
162165
cat /tmp/recording.json | jq '[.[] | select(.type == "webhook" and .platform == "gchat") | .body | fromjson]' > /tmp/gchat-webhooks.json
166+
cat /tmp/recording.json | jq '[.[] | select(.type == "webhook" and .platform == "feishu") | .body | fromjson]' > /tmp/feishu-webhooks.json
163167

164168
# Inspect specific webhook fields (e.g., Teams channelData)
165169
cat /tmp/teams-webhooks.json | jq '[.[] | {type, text, channelData, value}]'
@@ -208,6 +212,7 @@ Key env vars used (see `turbo.json` for full list):
208212
- `SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET` - Slack credentials
209213
- `TEAMS_APP_ID`, `TEAMS_APP_PASSWORD`, `TEAMS_APP_TENANT_ID` - Teams credentials
210214
- `GOOGLE_CHAT_CREDENTIALS` or `GOOGLE_CHAT_USE_ADC` - Google Chat auth
215+
- `FEISHU_APP_ID`, `FEISHU_APP_SECRET` - Feishu credentials
211216
- `REDIS_URL` - Redis connection for state adapter
212217
- `BOT_USERNAME` - Default bot username
213218

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![npm downloads](https://img.shields.io/npm/dm/chat)](https://www.npmjs.com/package/chat)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
66

7-
A unified TypeScript SDK for building chat bots across Slack, Microsoft Teams, Google Chat, Discord, GitHub, and Linear. Write your bot logic once, deploy everywhere.
7+
A unified TypeScript SDK for building chat bots across Slack, Microsoft Teams, Google Chat, Discord, GitHub, Linear, and Feishu (Lark). Write your bot logic once, deploy everywhere.
88

99
## Installation
1010

@@ -15,7 +15,7 @@ npm install chat
1515
Install adapters for your platforms:
1616

1717
```bash
18-
npm install @chat-adapter/slack @chat-adapter/teams @chat-adapter/gchat @chat-adapter/discord
18+
npm install @chat-adapter/slack @chat-adapter/teams @chat-adapter/gchat @chat-adapter/discord @chat-adapter/feishu
1919
```
2020

2121
## Usage
@@ -55,6 +55,7 @@ See the [Getting Started guide](https://chat-sdk.dev/docs/getting-started) for a
5555
| Discord | `@chat-adapter/discord` | Yes | Yes | Yes | No | Post+Edit | Yes |
5656
| GitHub | `@chat-adapter/github` | Yes | Yes | No | No | No | No |
5757
| Linear | `@chat-adapter/linear` | Yes | Yes | No | No | No | No |
58+
| Feishu | `@chat-adapter/feishu` | Yes | Yes | Yes | No | Post+Edit | Yes |
5859

5960
## Features
6061

@@ -80,6 +81,7 @@ See the [Getting Started guide](https://chat-sdk.dev/docs/getting-started) for a
8081
| `@chat-adapter/discord` | [Discord adapter](https://chat-sdk.dev/docs/adapters/discord) |
8182
| `@chat-adapter/github` | [GitHub adapter](https://chat-sdk.dev/docs/adapters/github) |
8283
| `@chat-adapter/linear` | [Linear adapter](https://chat-sdk.dev/docs/adapters/linear) |
84+
| `@chat-adapter/feishu` | [Feishu adapter](https://chat-sdk.dev/docs/adapters/feishu) |
8385
| `@chat-adapter/state-redis` | [Redis state adapter](https://chat-sdk.dev/docs/state/redis) (production) |
8486
| `@chat-adapter/state-ioredis` | [ioredis state adapter](https://chat-sdk.dev/docs/state/ioredis) (alternative) |
8587
| `@chat-adapter/state-memory` | [In-memory state adapter](https://chat-sdk.dev/docs/state/memory) (development) |

examples/nextjs-chat/.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,11 @@ BOT_USERNAME=mybot
4242
# LINEAR_WEBHOOK_SECRET=your-webhook-secret
4343
# LINEAR_BOT_USERNAME=my-bot
4444

45+
# Feishu / Lark (optional)
46+
# FEISHU_APP_ID=your-app-id
47+
# FEISHU_APP_SECRET=your-app-secret
48+
# FEISHU_ENCRYPT_KEY=your-encryption-key
49+
# FEISHU_VERIFICATION_TOKEN=your-verification-token
50+
4551
# Redis (for production state persistence)
4652
# REDIS_URL=redis://localhost:6379

examples/nextjs-chat/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Next.js Chat Example
22

3-
A full-featured example app demonstrating the Chat SDK with Next.js. Integrates with Slack, Microsoft Teams, Google Chat, Discord, GitHub, and Linear — configure whichever platforms you need via environment variables.
3+
A full-featured example app demonstrating the Chat SDK with Next.js. Integrates with Slack, Microsoft Teams, Google Chat, Discord, GitHub, Linear, and Feishu (Lark) — configure whichever platforms you need via environment variables.
44

55
## Getting started
66

@@ -46,7 +46,7 @@ The app runs at `http://localhost:3000`. Platform webhooks should point to `/api
4646
- **Ephemeral messages** — user-only visible messages with DM fallback
4747
- **DMs** — programmatic direct message initiation
4848
- **File uploads** — attachment detection and display
49-
- **Multi-platform** — same bot logic across all six platforms
49+
- **Multi-platform** — same bot logic across all seven platforms
5050

5151
## Project structure
5252

@@ -82,6 +82,10 @@ Copy `.env.example` for the full list. At minimum, set `BOT_USERNAME` and creden
8282
| `DISCORD_PUBLIC_KEY` | Discord interaction verification key |
8383
| `GITHUB_TOKEN` | GitHub PAT or App credentials |
8484
| `LINEAR_API_KEY` | Linear API key |
85+
| `FEISHU_APP_ID` | Feishu app ID |
86+
| `FEISHU_APP_SECRET` | Feishu app secret |
87+
| `FEISHU_ENCRYPT_KEY` | Feishu event encryption key (optional) |
88+
| `FEISHU_VERIFICATION_TOKEN` | Feishu webhook verification token (optional) |
8589
| `REDIS_URL` | Redis connection string |
8690

8791
See the [Chat SDK docs](https://chat-sdk.dev/docs) for full platform setup guides.

examples/nextjs-chat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@chat-adapter/discord": "workspace:*",
15+
"@chat-adapter/feishu": "workspace:*",
1516
"@chat-adapter/gchat": "workspace:*",
1617
"@chat-adapter/github": "workspace:*",
1718
"@chat-adapter/linear": "workspace:*",

examples/nextjs-chat/src/lib/adapters.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
createDiscordAdapter,
33
type DiscordAdapter,
44
} from "@chat-adapter/discord";
5+
import { createFeishuAdapter, type FeishuAdapter } from "@chat-adapter/feishu";
56
import {
67
createGoogleChatAdapter,
78
type GoogleChatAdapter,
@@ -18,6 +19,7 @@ const logger = new ConsoleLogger("info");
1819

1920
export interface Adapters {
2021
discord?: DiscordAdapter;
22+
feishu?: FeishuAdapter;
2123
gchat?: GoogleChatAdapter;
2224
github?: GitHubAdapter;
2325
linear?: LinearAdapter;
@@ -36,6 +38,15 @@ const DISCORD_METHODS = [
3638
"openDM",
3739
"fetchMessages",
3840
];
41+
const FEISHU_METHODS = [
42+
"postMessage",
43+
"editMessage",
44+
"deleteMessage",
45+
"addReaction",
46+
"removeReaction",
47+
"startTyping",
48+
"fetchMessages",
49+
];
3950
const SLACK_METHODS = [
4051
"postMessage",
4152
"editMessage",
@@ -187,5 +198,16 @@ export function buildAdapters(): Adapters {
187198
}
188199
}
189200

201+
// Feishu adapter (optional) - env vars: FEISHU_APP_ID, FEISHU_APP_SECRET
202+
if (process.env.FEISHU_APP_ID) {
203+
adapters.feishu = withRecording(
204+
createFeishuAdapter({
205+
logger: logger.child("feishu"),
206+
}),
207+
"feishu",
208+
FEISHU_METHODS
209+
);
210+
}
211+
190212
return adapters;
191213
}

pnpm-lock.yaml

Lines changed: 7 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)