npm package: @shixing.xingshi/feishu-for-user
Description: OpenClaw Feishu user-identity tools (UAT + doc)
Latest version: 2026.2.14

# Feishu For User Extension

Runs Feishu actions as **user identity** via `user_access_token`.

## Tools

- `feishu_user_uat`: OAuth flow and token management
- `feishu_user_doc`: Create Feishu Docx as user
- `feishu_user_search`: Feishu knowledge QA search as user
- `feishu_user_calendar`: Query user primary calendar and list events by time window

## Install location

Put this folder under:

- `~/.openclaw/extensions/feishu_for_user`

## Session scope recommendation

This plugin binds Feishu `open_id` tokens per DM sender. Use DM scope
`per-channel-peer` so each sender has an isolated session key.

If DM sessions are shared (for example `main`), tool calls without explicit
`sender_key`/`user_access_token` are blocked to prevent cross-user token mix.

## Config example

```json
{
  "plugins": {
    "allow": ["feishu_for_user"],
    "entries": {
      "feishu_for_user": {
        "enabled": true,
        "config": {
          "appId": "cli_xxx",
          "appSecret": "xxx",
          "domain": "feishu",
          "redirectUri": "http://127.0.0.1:18789/feishu/callback",
          "tokenStorePath": "~/.openclaw/credentials/feishu-for-user-token.json"
        }
      }
    }
  }
}
```

`tokenStorePath` is required.

## feishu_user_uat usage

1. Generate auth URL:

```json
{ "action": "authorize" }
```

2. Finish consent in browser.
   If your `redirectUri` points to OpenClaw gateway (for example `http://127.0.0.1:18789/feishu/callback`), UAT is saved automatically.

3. Optional manual exchange (only when auto callback cannot reach OpenClaw):

```json
{
  "action": "callback",
  "callback_url": "http://127.0.0.1:18789/feishu/callback?code=xxx&state=xxx"
}
```

4. Optional status:

```json
{ "action": "status" }
```

`open_id` is now used as storage key, and sender->open_id binding is auto-derived from DM `sessionKey` by plugin hook.

## feishu_user_doc usage

Create a doc using stored UAT:

```json
{ "title": "User doc from OpenClaw" }
```

Create in specific folder:

```json
{ "title": "Roadmap", "folder_token": "fldcn..." }
```

Overwrite (replace) an existing document with markdown content:

```json
{
  "action": "overwrite",
  "doc_token": "X3g2d...",
  "content": "# New Content\n\nThis will replace previous document body."
}
```

## feishu_user_search usage

```json
{
  "query": "报销流程",
  "enterprise_knowledge_source": {
    "entities": [
      { "entity_id": "wiki", "searchable": false },
      { "entity_id": "doc", "searchable": false }
    ]
  }
}
```

If your DM sessions are not sender-isolated (for example shared `main` session), tools are blocked to avoid cross-user token mix.

`enterprise_knowledge_source` is always included in request.
The tool forces the following to enabled:
- `space.searchable = true`
- `wiki.searchable = true`
- `message.searchable = true`
- `helpdesk_faq.searchable = true`
- `lingo.searchable = true`
- `minutes.searchable = true`
- `mail.searchable = true`
- `comment.wiki_searchable = true`
- `comment.space_searchable = true`

## feishu_user_calendar usage

Query current user's primary calendar events:

```json
{
  "query": "中午 吃饭",
  "start_time": "2026-02-16T00:00:00+08:00",
  "end_time": "2026-02-16T23:59:59+08:00"
}
```

Behavior:

- First calls calendar primary API to resolve `calendar_id`
- Then calls calendar event list API with the time window
- Returns both `events` and `matched_events` (filtered by `query` over title/description/location/organizer)