Receive Feishu (Lark) approval event notifications and trigger Dify workflows. Supports encrypted transmission, signature verification, and multiple event format versions.
Why use this plugin
- Real-time triggers: Start Dify workflows immediately after approval without polling
- Secure & reliable: Supports Feishu's recommended dual security mechanism (signature verification + AES-256 encryption)
- Auto-filtering: Only processes APPROVED status approvals, automatically ignoring other statuses
- Out-of-the-box: Compatible with Feishu v1.0 and v2.0 event formats without additional configuration
What is Feishu Approval?
- Feishu Approval is an approval process management system provided by Feishu Open Platform
- Through event subscription, you can receive real-time approval status change notifications
- Official documentation: https://open.feishu.cn/document/server-docs/approval-v4/event/function-introduction
| Mode | Configuration | Security Features | Recommended Use Case |
|---|---|---|---|
| Encrypted Mode | Encrypt Key | Signature verification + AES-256-CBC encryption | Production (Recommended) |
| Plaintext Mode | Verification Token only | Basic Token verification | Development/Testing |
- v1.0 Format: Feishu approval events (
approval_task) - v2.0 Format: General event subscription (
approval.instance.status_updated) - Automatic detection and adaptation, no manual configuration required
- Only triggers workflows for
status == "APPROVED"approvals - Other statuses (PENDING, REJECTED, etc.) are automatically ignored
- Avoids unnecessary workflow executions
The plugin provides the following variables to Dify workflows:
| Variable Name | Type | Description | Example |
|---|---|---|---|
instance_code |
string | Approval instance Code | B5463FE5-14CF-49D9-9C7E-5E7B7BEACCBF |
approval_code |
string | Approval definition Code | 9540C9E3-48B6-4812-A2F3-3E011190BDB4 |
status |
string | Approval status (always APPROVED) | APPROVED |
operate_time |
string | Status change timestamp | 1762376996307 |
app_id |
string | Feishu App ID | cli_a9837cdad77f500c |
event_id |
string | Unique event ID (for idempotency) | dec15e6d19502ff7c8cfcfa3f3e67842 |
uuid |
string | Approval instance UUID | eac5a638542c9f69a70f210748d435a7 |
- Visit Feishu Developer Console
- Create an "Enterprise Self-Built Application"
- Enter application management page
- Navigate to Features → Add Application Features
- Enable Bot feature
- Navigate to Permission Management
- Add the following permissions:
approval:approval- View and comment on approvalsapproval:approval:readonly- Get approval information (recommended)
- Navigate to Credentials & Basic Information
- Copy App ID (format:
cli_xxx...) - Copy App Secret
- Navigate to Events & Callbacks
- Ensure Event Subscription toggle is enabled
- Find Verification Token in the Security Policy section
- Copy the Token (format:
x7T88t...)
- In the same Security Policy section
- Find Encrypt Key
- If empty, click the Generate button
- Immediately copy and save the key (old key becomes invalid after reset)
- Install/import this plugin in Dify
- Fill in the following information when creating a subscription:
| Configuration | Required | Description | Location |
|---|---|---|---|
| App ID | ✅ Required | Feishu App ID | Credentials & Basic Information |
| App Secret | ✅ Required | Feishu App Secret | Credentials & Basic Information |
| Verification Token | ✅ Required | Event verification token | Events & Callbacks → Security Policy |
| Encrypt Key | 🟡 Recommended | Event encryption key | Events & Callbacks → Security Policy |
- Copy the Webhook URL generated by Dify
- In Feishu Developer Console, navigate to Events & Callbacks
- Paste Dify's Webhook URL in the Request URL field
- Click Save (Feishu will send a URL verification request)
- If configured correctly, verification success will be displayed
- In the Event Configuration section on the same page
- Click Add Event
- Search and add:
approval.instance.status_updated(v2.0)- or
approval_task(v1.0)
- Save configuration
- Navigate to Version Management & Publishing
- Create new version
- Submit and publish
- Create a new Workflow
- Select Plugin Trigger as trigger node type
- Select plugin: Feishu Approval Trigger
- Select event: Feishu Approval (Approved)
- Workflow will automatically trigger when Feishu approval is approved
In subsequent workflow nodes, you can reference the following variables:
# Example: Use in LLM node
Approval Instance Code: {{instance_code}}
Approval Definition Code: {{approval_code}}
Approval Status: {{status}}
Operation Time: {{operate_time}}- Auto Notification: Automatically send notifications to WeChat Work, DingTalk, etc. after approval
- Data Sync: Synchronize approval data to database or CRM system
- Process Chaining: Trigger downstream approvals or business processes
- Intelligent Processing: Use LLM to analyze approval content and automatically execute subsequent operations
Activation Condition: Configure Encrypt Key
Security Features:
-
Signature Verification (Level 1)
- Algorithm:
SHA256(timestamp + nonce + encrypt_key + raw_body) - Verifies HTTP Headers:
X-Lark-Signature - Prevents request tampering
- Algorithm:
-
Payload Encryption (Level 2)
- Algorithm: AES-256-CBC
- Key Derivation:
SHA256(encrypt_key) - Prevents data eavesdropping
-
Token Verification (Level 3)
- Verifies
tokenfield in event - Dual authentication
- Verifies
Configuration Requirements:
✅ Configure Encrypt Key in Feishu Console
✅ Fill in Encrypt Key in Dify subscriptionActivation Condition: Do not configure Encrypt Key
Security Features:
⚠️ Token verification only (plaintext transmission)⚠️ Cannot prevent man-in-the-middle attacks⚠️ Cannot prevent data eavesdropping
Applicable Scenarios:
- Local development testing
- Internal network environment
- Non-sensitive data
The plugin automatically handles Feishu's URL verification requests:
-
Plaintext Challenge (Encrypt Key not configured)
Feishu sends: {"type": "url_verification", "challenge": "xxx"} Plugin responds: {"challenge": "xxx"}
-
Encrypted Challenge (Encrypt Key configured)
Feishu sends: {"encrypt": "base64_encrypted_string"} Plugin auto: Decrypt → Extract challenge → Respond
Response Time: < 1 second (meets Feishu requirements)
Error Message: TriggerValidationError: Invalid Verification Token
Solutions:
- Check if
Verification Tokenconfigured in Dify matches Feishu console - Ensure no extra spaces or line breaks
- If Encrypt Key was modified, Verification Token may have changed, need to recopy
Error Message: TriggerValidationError: Invalid signature
Solutions:
- Check if
Encrypt Keyconfigured in Dify is correct - Ensure Feishu console's Encrypt Key matches Dify
- If key was reset, need to update subscription configuration in Dify
Error Message: TriggerDispatchError: Failed to decrypt payload
Solutions:
- Check if Encrypt Key is correct
- Try removing Encrypt Key and test with plaintext mode
- Ensure Encrypt Key is properly configured in Feishu console
Possible Causes:
-
Approval status is not APPROVED
- Plugin only processes APPROVED status
- Other statuses (PENDING, REJECTED) are silently ignored
-
Incorrect event subscription
- Ensure approval events are subscribed in Feishu console
- Check if application version is published
-
Insufficient permissions
- Check if application has approval-related permissions
- Ensure application is published and effective
Error Message: Verification fails when saving Webhook URL in Feishu
Solutions:
- Ensure plugin is running
- Check if Dify Webhook URL is accessible
- If using Encrypt Key, ensure configuration is correct
- Check plugin logs to see if verification request was received
{
"uuid": "...",
"token": "x7T88tRQv3...",
"type": "event_callback",
"ts": "1762376996.467246",
"event": {
"type": "approval_task",
"status": "APPROVED",
"instance_code": "B5463FE5-14CF-49D9-9C7E-5E7B7BEACCBF",
"approval_code": "9540C9E3-48B6-4812-A2F3-3E011190BDB4",
"operate_time": "1762376996307",
"app_id": "cli_a9837cdad77f500c",
...
}
}{
"schema": "2.0",
"header": {
"event_id": "...",
"event_type": "approval.instance.status_updated",
"token": "x7T88tRQv3...",
"app_id": "cli_a9837cdad77f500c"
},
"event": {
"object": {
"status": "APPROVED",
"instance_code": "...",
"approval_code": "...",
...
}
}
}Feishu Approval System
↓ (Approval passed)
Feishu Event Subscription
↓ (HTTP POST)
Dify Webhook URL
↓
1. Signature Verification (if Encrypt Key configured)
2. Payload Decryption (if encrypted)
3. Token Verification
4. Event Type Identification (v1.0/v2.0)
↓
5. Status Filtering (APPROVED only)
↓
6. Data Transformation → Variables
↓
Trigger Dify Workflow
- Response Time: < 3 seconds (Feishu requirement)
- Challenge Response: < 1 second (Feishu requirement)
- Idempotency: Use
event_idoruuidfor deduplication
- Configure Encrypt Key (required)
- Verify signature verification works correctly
- Test that approved approvals correctly trigger workflows
- Test that other statuses (REJECTED) do not trigger workflows
- Implement idempotency check in Dify workflow (using
event_idvariable) - Configure alert monitoring (if webhook fails)
-
Must use Encrypt Key (production environment)
- Prevent data leakage (approval content may contain sensitive information)
- Prevent request forgery attacks
-
Regularly rotate keys
- Regularly update App Secret and Encrypt Key
- Update Dify subscription configuration after rotation
-
Principle of least privilege
- Only grant necessary approval-related permissions
- Avoid granting excessive API permissions
Feishu uses an "at-least-once delivery" strategy, where the same event may be pushed multiple times.
- Monitor Webhook failure rate
- Set alerts: consecutive failures > 3 times
- Regularly check Feishu application subscription status
- Feishu Open Platform
- Feishu Approval API Documentation
- Feishu Event Subscription Guide
- Dify Trigger Plugin Documentation
Maintainer: stream Version: 0.0.1 Last Updated: 2025-01-06