← Back to Plugins
Tools

Larkflow Openclaw

sunecom By sunecom 👁 45 views ▲ 0 votes

๐Ÿค– LarkFlow - Feishu approval workflow automation plugin for OpenClaw. Rule engine + AI sub-agent for auto-approve/reject/notify. ๅŸบไบŽ OpenClaw ็š„้ฃžไนฆๅฎกๆ‰นๆต่‡ชๅŠจๅŒ–ๆ’ไปถใ€‚

Homepage GitHub

Install

npm install

#

README

# LarkFlow ๐Ÿค–

> **Feishu Approval Workflow Automation โ€” powered by OpenClaw**  
> ๅŸบไบŽ OpenClaw ็š„้ฃžไนฆๅฎกๆ‰นๆต่‡ชๅŠจๅŒ–ๆ’ไปถ

---

## What is LarkFlow?

LarkFlow is an **OpenClaw plugin** that automates Feishu (้ฃžไนฆ) approval workflows. It listens for approval events, matches them against configurable rules, optionally uses AI to analyze complex cases, and takes automatic actions โ€” all through OpenClaw's plugin and hook system.

### Use Cases

- **๐Ÿ’ฐ Expense Reports** โ€” Auto-approve โ‰คยฅ5000, AI-review ยฅ5000-20000, escalate >ยฅ20000
- **๐Ÿ–๏ธ Leave Requests** โ€” Auto-approve โ‰ค3 days, forward >3 days to manager
- **๐Ÿ“‹ Purchase Orders** โ€” Match budget codes, auto-reject overspend
- **๐Ÿš€ DevOps Approvals** โ€” Auto-approve staging deploys, escalate production

---

## Features

| Feature | Description |
|---------|-------------|
| **Rule Engine** | Define rules with priority, keyword match, amount ranges, applicant filters |
| **AI Decider** | Sub-agents analyze complex approvals using local/cloud models |
| **Feishu Integration** | Native webhook handling + notification via Feishu channel |
| **OpenClaw Hooks** | `message:received` hook for real-time approval detection |
| **Plugin Config** | JSON5 schema with full OpenClaw config validation |

---

## Quick Start

### 1. Install Plugin

```bash
# From local path
openclaw plugins install -l ./larkflow

# Or via npm (once published)
openclaw plugins install larkflow
```

### 2. Configure

Add to `~/.openclaw/openclaw.json`:

```json5
{
  plugins: {
    slots: {
      // No slot needed โ€” LarkFlow registers hooks automatically
    },
    entries: {
      larkflow: {
        enabled: true,
        config: {
          feishuChatId: "oc_xxxxxxxxxxxxxxxxxxxxxxxxxxx",
          notifyOnAction: true,
          rules: [
            {
              name: "ๅฐ้ขๆŠฅ้”€่‡ชๅŠจ้€š่ฟ‡",
              priority: 1,
              match: {
                approvalType: "expense_report",
                titleContains: ["ๆŠฅ้”€", "expense"],
                amountMax: 5000,
              },
              action: "auto_approve",
              reason: "ๅฐ้ขๆŠฅ้”€่ง„ๅˆ™๏ผš้‡‘้ข โ‰ค ยฅ5000 ่‡ชๅŠจ้€š่ฟ‡",
            },
            {
              name: "ๅคง้ข้‡‡่ดญ้œ€AIๅฎกๆ ธ",
              priority: 2,
              match: {
                approvalType: "purchase_order",
                amountMin: 20000,
              },
              action: "ai_decide",
            },
            {
              name: "่ถ…้•ฟ่ฏทๅ‡่ฝฌไบบๅทฅ",
              priority: 3,
              match: {
                approvalType: "leave",
                titleContains: ["่ฏทๅ‡", "leave", "ไผ‘ๅ‡", "vacation"],
                amountMin: 7,  // days
              },
              action: "forward",
              forwardTo: "ou_xxxxxxxxxx",
            },
          ],
        },
      },
    },
  },
}
```

### 3. Restart Gateway

```bash
openclaw gateway restart
```

### 4. Verify

```bash
openclaw plugins list | grep larkflow
```

---

## Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Feishu     โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  LarkFlow        โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  OpenClaw      โ”‚
โ”‚  Approval   โ”‚     โ”‚  Webhook Handler โ”‚     โ”‚  Agent Loop    โ”‚
โ”‚  Webhook    โ”‚     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
                             โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  Rule Engine     โ”‚
                    โ”‚  (first match)   โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ              โ–ผ              โ–ผ
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚ Auto Action โ”‚ โ”‚  AI Decider  โ”‚ โ”‚ Forward    โ”‚
     โ”‚ (approve/   โ”‚ โ”‚  (sub-agent) โ”‚ โ”‚ (to human) โ”‚
     โ”‚  reject)    โ”‚ โ”‚              โ”‚ โ”‚            โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ”‚              โ”‚              โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  Feishu Channel  โ”‚
                    โ”‚  (notification)  โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

---

## Development

```bash
# Clone & setup
git clone https://github.com/sunecom/larkflow.git
cd larkflow
npm install

# Build
npm run build

# Test
npm test

# Run with dev Gateway
openclaw gateway --plugins ./dist
```

---

## Configuration Reference

### `openclaw.json` Plugin Config

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `feishuChatId` | string | โœ… | โ€” | Feishu chat ID for notifications |
| `approvalWebhook` | string | โŒ | โ€” | Feishu approval webhook URL |
| `rules[]` | array | โŒ | [] | Approval rule list |
| `aiDecidePrompt` | string | โŒ | (default) | Custom prompt for AI decision |
| `notifyOnAction` | boolean | โŒ | true | Send notification on auto-action |

### Rule Fields

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | โœ… | Rule display name |
| `priority` | number | โŒ | Lower = higher priority (default 999) |
| `match.approvalType` | string | โŒ | Feishu approval code |
| `match.titleContains` | string[] | โŒ | Keyword match (any) |
| `match.amountMax` | number | โŒ | Amount โ‰ค this value |
| `match.amountMin` | number | โŒ | Amount โ‰ฅ this value |
| `match.applicantIds` | string[] | โŒ | Specific applicant IDs |
| `action` | enum | โœ… | auto_approve / auto_reject / ai_decide / notify_only / forward |
| `forwardTo` | string | โŒ | User open_id for forward action |
| `reason` | string | โŒ | Reason logged with action |

---

> ๐Ÿš€ Powered by [AiToMoney Team](https://github.com/sunecom) | Check out our **GEO ToolKit** โ†’ [geo.aitomoney.online](https://geo.aitomoney.online)

---

## License

MIT โ€” Free as a lobster in the ocean. ๐Ÿฆž
tools

Comments

Sign in to leave a comment

Loading comments...