Skip to content
Worix
BrowsePublish
Log inSign Up

Feishu Agent Relay - Multi-Bot Collabora

Enables multi-Agent collaboration on Feishu by relaying tasks between coordinator and specialist Bots with user ID mapping and proactive messaging.

90 downloads
Free
Reviewed
bot
chinese
collaboration
communication
feishu
lark
multi-agent
productivity
relay

Feishu Agent Relay

๐Ÿšจ Installation: Choose Your Mode First!

โš ๏ธ BEFORE SETUP: You must choose a deployment mode!

ModeForUser IDSetupSecurity
Single-UserPersonal useAuto ("me")โœ… 5 minโœ… High
Multi-UserTeamsManual entryโš ๏ธ 30 minโš ๏ธ Low

Quick Decision Guide

Choose Single-User Mode if:

  • โœ… Only YOU will use the Bots
  • โœ… Personal productivity system
  • โœ… Want ZERO manual configuration
  • โœ… Want fastest setup (5 minutes)

๐Ÿ“– Guide: references/single-user-setup.md

Choose Multi-User Mode if:

  • โœ… Multiple people will use the system
  • โœ… Team or organization
  • โœ… Need to track different users
  • โœ… Planning to add verification later

๐Ÿ“– Guide: references/feishu-bot-setup.md


โš ๏ธ Important Limitations

Read this before using the skill:

1. Manual User ID Registration โš ๏ธ SECURITY LIMITATION (Multi-User Mode Only)

Current flow requires users to manually enter their User ID:

User โ†’ Bot: "ไฝ ๅฅฝ"
Bot โ†’ User: "่ฏทๅ‘Š่ฏ‰ๆˆ‘ๆ‚จ็š„ User ID๏ผˆๅทฅๅท/็”จๆˆทๅ๏ผ‰"
User โ†’ Bot: "ๆˆ‘็š„ user ID ๆ˜ฏ๏ผšuser_demo_001"  โ† โš ๏ธ MANUAL STEP - NO VERIFICATION

โš ๏ธ Risks:

  • โŒ No identity verification - System trusts whatever user types
  • โŒ Identity spoofing possible - User could claim another person's ID
  • โŒ Human error - Users may mistype their ID
  • โŒ No audit trail - Cannot prove who actually registered
  • โŒ NOT production-ready - Internal/personal use ONLY

โœ… Acceptable for:

  • Personal projects (use Single-User Mode!)
  • Small team internal tools
  • Testing and prototyping

โŒ NOT acceptable for:

  • Production systems
  • External-facing applications
  • Security-sensitive operations

๐Ÿ”ง Single-User Mode avoids this: No manual ID entry needed!


2. Multiple Feishu Bots Required ๐Ÿ”ง SETUP REQUIRED

This skill requires multiple Feishu Bot applications:

Bot TypeQuantityExample Names
Coordinator1ๅ่ฐƒๅ‘˜
Specialists2+ๆŠ€ๆœฏไธ“ๅฎถ๏ผŒไบงๅ“ไธ“ๅฎถ

๐Ÿ“– Setup Guide: references/feishu-bot-setup.md


โšก Single-User Mode: Zero Configuration

Recommended for personal use!

# 1. Set environment variable
export DEPLOYMENT_MODE=single-user

# 2. Create empty mapping table (no users needed)
cat > user-mapping.json << 'EOF'
{
  "version": "1.0",
  "users": {},
  "agents": { ... }
}
EOF

# 3. Contact any Bot - auto-registers you!
# That's it! No manual User ID entry needed.

How it works:

  • First contact: Bot auto-registers you as userid "me"
  • All Bots: Automatically track your open_id
  • Relay: Uses hardcoded userid "me" (no queries needed)
  • Security: No identity spoofing risk (only you)

๐Ÿ“– Full guide: references/single-user-setup.md


๐Ÿ‘ฅ Multi-User Mode: Manual Configuration

For teams and organizations.

# 1. Set environment variable
export DEPLOYMENT_MODE=multi-user

# 2. Each user must register:
User โ†’ Bot: "ไฝ ๅฅฝ"
Bot โ†’ User: "่ฏทๅ‘Š่ฏ‰ๆˆ‘ๆ‚จ็š„ User ID"
User โ†’ Bot: "ๆˆ‘็š„ user ID ๆ˜ฏ๏ผšzhangsan"

โš ๏ธ Security Warning: Manual User ID entry has NO verification. Internal use only!

๐Ÿ“– Full guide: references/feishu-bot-setup.md


Quick Start

This skill enables multi-Agent collaboration on Feishu where:

  • Users contact a coordinator Bot
  • Coordinator relays tasks to specialist Bots
  • Specialists proactively message users
User โ†’ Coordinator Bot โ†’ sessions_send โ†’ Specialist Bot โ†’ User (proactive DM)
                          (userid only)    queries mapping

๐Ÿ“‹ Setup Checklist

Phase 1: Feishu Bot Configuration (~30 minutes)

  • Create Feishu Developer Account
  • Create Coordinator Bot + Specialist Bots
  • Configure Permissions
  • Configure Event Subscriptions
  • Test Each Bot

๐Ÿ“– Guide: references/feishu-bot-setup.md

Phase 2: Choose Deployment Mode

  • Single-User: Set DEPLOYMENT_MODE=single-user
  • Multi-User: Set DEPLOYMENT_MODE=multi-user
  • Initialize mapping table
  • Deploy mapping API

๐Ÿ“– Single-User Guide: references/single-user-setup.md

Phase 3: Testing (~15 minutes)

  • Test first contact (auto-register or manual)
  • Test relay flow
  • Test proactive message
  • Verify mapping table

When to Use This Skill

Use when:

  • โœ… Multiple Feishu Bots working together
  • โœ… Users contact one Bot, receive responses from different Bots
  • โœ… Cross-Bot user identity management needed
  • โœ… Specialist Bots proactively message users

Don't use for:

  • โŒ Single-Bot scenarios
  • โŒ Production without verification (multi-user)
  • โŒ External-facing applications

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     User        โ”‚
โ”‚  (Feishu DM)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚ 1. User contacts coordinator
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     2. Coordinator identifies user
โ”‚  Coordinator    โ”‚        (auto or manual)
โ”‚    Agent        โ”‚
โ”‚  (orchestrator) โ”‚     3. Relay via sessions_send
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        (userid only)
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     4. Specialist queries mapping
โ”‚   Specialist    โ”‚        for own open_id
โ”‚    Agent        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     5. Send proactive DM
         โ”‚
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   user-mapping.json     โ”‚
โ”‚  userid โ†’ open_id map   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Critical Concept: Feishu open_id Isolation

Each Bot has different open_id for the same user:

Same user (userid: user_demo_001):
โ”œโ”€ Coordinator Bot:    ou_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
โ”œโ”€ Tech Expert Bot:    ou_bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
โ””โ”€ Product Expert Bot: ou_cccccccccccccccccccccccccccccccc

You CANNOT use one Bot's open_id for another Bot!

Correct Relay Pattern โœ…

// 1. Coordinator queries userid
const user = await mapping.getUserByOpenId('coordinator', userOpenId);

// 2. Send relay (userid only, NO open_id)
await sessions_send({
  agentId: 'product-expert',
  sessionKey: 'agent:product-expert:main',  // โœ… Key!
  message: `ใ€่ฝฌๆŽฅไปปๅŠกใ€‘็”จๆˆท User ID: ${user.userid}`
});

// 3. Specialist queries mapping for ITS OWN open_id
const userOpenId = mapping.users[userId]?.botOpenIds?.['product-expert'];

// 4. Send message using correct open_id
await message({
  action: 'send',
  channel: 'feishu',
  target: userOpenId,  // โœ… This Bot's open_id
  message: 'ๆ‚จๅฅฝ๏ผŒๆˆ‘ๆ˜ฏไบงๅ“ไธ“ๅฎถ...'
});

Workflows

Workflow 1A: Single-User - Auto Registration

const DEPLOYMENT_MODE = process.env.DEPLOYMENT_MODE || 'single-user';
const SINGLE_USER_ID = 'me';

const userOpenId = getMessageContext().from;

// Auto-register on first contact
const existing = await mapping.getBotOpenId(SINGLE_USER_ID, 'coordinator');

if (!existing) {
  await mapping.updateBotOpenId(SINGLE_USER_ID, 'coordinator', userOpenId, 'Default User');
  
  await message({
    message: `ๆ‚จๅฅฝ๏ผ๐ŸŽ‰ ็ณป็ปŸๅทฒ่‡ชๅŠจ้…็ฝฎๅฎŒๆˆ๏ผˆๅ•็”จๆˆทๆจกๅผ๏ผ‰ใ€‚`
  });
  return;
}

Workflow 1B: Multi-User - Manual Registration

const userOpenId = getMessageContext().from;
const user = await mapping.getUserByOpenId('coordinator', userOpenId);

if (!user) {
  // Ask for User ID
  await message({
    message: `ๆ‚จๅฅฝ๏ผ่ฏทๅ‘Š่ฏ‰ๆˆ‘ๆ‚จ็š„ User ID๏ผˆๅทฅๅท/็”จๆˆทๅ๏ผ‰ใ€‚`
  });
  return;
}

await mapping.updateBotOpenId(user.userid, 'coordinator', userOpenId, user.name);

Workflow 2: Coordinator Relay

const user = await mapping.getUserByOpenId('coordinator', userOpenId);

await sessions_send({
  agentId: 'product-expert',
  sessionKey: 'agent:product-expert:main',
  message: `ใ€่ฝฌๆŽฅไปปๅŠกใ€‘็”จๆˆท User ID: ${user.userid}, ไปปๅŠก๏ผš${task}`
});

Workflow 3: Specialist Proactive Message

const userId = extractUserId(message);
const userOpenId = mapping.users[userId]?.botOpenIds?.['product-expert'];

if (!userOpenId) {
  await sessions_send({
    agentId: 'coordinator',
    message: `็”จๆˆท ${userId} ๅฐšๆœชไธŽๆˆ‘ๅปบ็ซ‹ๅฏน่ฏ`
  });
  return;
}

await message({
  action: 'send',
  channel: 'feishu',
  target: userOpenId,
  message: 'ๆ‚จๅฅฝ๏ผŒๆˆ‘ๆ˜ฏไบงๅ“ไธ“ๅฎถ...'
});

User Mapping Table

Single-User Mode (Auto-populated)

{
  "version": "1.0",
  "users": {
    "me": {
      "name": "Default User",
      "botOpenIds": {
        "coordinator": "ou_xxx",
        "tech-expert": "ou_yyy",
        "product-expert": "ou_zzz"
      }
    }
  },
  "agents": { ... }
}

Multi-User Mode (Manual registration)

{
  "version": "1.0",
  "users": {
    "zhangsan": {
      "name": "ๅผ ไธ‰",
      "botOpenIds": {
        "coordinator": "ou_abc...",
        "product-expert": "ou_def..."
      }
    },
    "lisi": { ... }
  },
  "agents": { ... }
}

Configuration

Environment Variables

VariableValuesDefaultDescription
DEPLOYMENT_MODEsingle-user, multi-usermulti-userDeployment mode
SINGLE_USER_IDAny string"me"User ID for single-user

Agent SOUL.md Template

# SOUL.md - ๅ่ฐƒ่€…

## ้ƒจ็ฝฒๆจกๅผ
- Mode: single-user (ๆˆ– multi-user)
- User ID: "me" (single-user) ๆˆ– dynamic (multi-user)

## ้…็ฝฎ
- Bot App ID: cli_xxx
- ๆ˜ ๅฐ„่กจ๏ผš/path/to/user-mapping.json

Error Handling

400 "cross app open_id"

Cause: Using wrong Bot's open_id.

Fix: Each Bot must use its own open_id from mapping.

User not found

Cause: First-time user, not registered.

Fix: Auto-register (single-user) or ask for ID (multi-user).


Testing Checklist

  • Bots created and configured
  • Deployment mode set
  • Mapping table initialized
  • First contact works
  • Relay flow works
  • Proactive message works
  • Mapping table updated correctly

Best Practices

DO โœ…

  • Use agent:xxx:main for sessionKey
  • Pass only userid in relay
  • Let specialists query own open_id
  • Use mapping API (not direct file access)
  • Choose appropriate deployment mode
  • Auto-register in single-user mode

DON'T โŒ

  • Pass open_id in relay
  • Use one Bot's open_id for another
  • Use feishu:direct:openid sessionKey
  • Use multi-user for production without verification
  • Share single-user Bots with others

Security Considerations

Single-User Mode โœ…

  • No identity spoofing risk (only you)
  • No manual ID entry
  • Automatic registration
  • Recommended for personal use

Multi-User Mode โš ๏ธ

  • Manual ID entry (no verification)
  • Identity spoofing possible
  • Internal use only
  • Add verification for production

Resources

scripts/

  • mapping-api.js - Unified mapping API

references/

  • single-user-setup.md - Single-user mode guide (START HERE for personal use)
  • feishu-bot-setup.md - Multi-user mode guide
  • mapping-schema.md - Schema details
  • relay-examples.md - Code examples

Version: 1.2
Last Updated: 2026-03-07
Deployment Modes: Single-User (zero-config) | Multi-User (manual)
Recommendation: Start with Single-User for testing, switch to Multi-User for teams
Status: โœ… Functional for internal/personal use | โš ๏ธ Not production-ready (multi-user mode)

Download

ZIP package โ€” ready to use

Skill Info

Creator
Glassmarbles
Downloads
90
Published
Mar 15, 2026
Updated
Mar 16, 2026