# Moltbot Connector Skills

Channel bridge skills for Moltbot, managed with Python 3.11 and uv.

## What is in this repo

- `feishu-connection`: Feishu/Lark WebSocket bridge.
- `dingtalk-connection`: DingTalk outgoing webhook bridge.

Each skill has its own `README.md` under `skills/<skill>/` with detailed setup steps.

## Requirements

- Python 3.11
- uv (https://github.com/astral-sh/uv)
- A running Moltbot (Clawdbot) Gateway on the same machine

## Install with npx

```bash
npx skills add xiaomingx/moltbot-connector-feishu-dingtalk
```

This installs the skill bundles so your agent framework can load them directly.
Installed skills are placed under your agent's skill directory; use that path as `<skill-dir>`.

## Use the skills

Choose a channel below and run the bridge on the same machine as the Moltbot Gateway.

### Feishu / Lark

1) Create and publish a Feishu self-built app with bot capability.
2) Save the App Secret to `~/.clawdbot/secrets/feishu_app_secret`.
3) Run the bridge:

```bash
cd <skill-dir>/feishu-connection
uv sync
FEISHU_APP_ID=cli_xxx uv run python bridge.py
```

### DingTalk

1) Create a DingTalk bot with outgoing webhook enabled.
2) Make sure DingTalk can reach your webhook (public endpoint or tunnel).
3) Run the bridge:

```bash
cd <skill-dir>/dingtalk-connection
uv sync
uv run python bridge.py
```

## Local development

If you cloned this repo, use `skills/` as `<skill-dir>`.

## Configuration

Both bridges read the local Gateway config at `~/.clawdbot/clawdbot.json` by default.
Override paths and behavior with environment variables:

- `CLAWDBOT_CONFIG_PATH`
- `CLAWDBOT_AGENT_ID`
- `*_THINKING_THRESHOLD_MS` (per skill)

See each skill README for full env var lists and provider-specific setup.

## Quick Start Example (Feishu/Lark)

Assuming you have Moltbot Gateway installed and running.

### 1. Feishu Configuration
- Go to the [Feishu Open Platform](https://open.feishu.cn/app) and create a self-built app.
- Enable the **Bot** capability in the "Add Capabilities" section.
- Set the **Event Subscription** push type to **WebSocket**.
- Create and release a version to activate the settings.

### 2. Environment Setup
Prepare your local configuration and secrets:
```bash
# 1) Config file (if not already present)
# Default path: ~/.clawdbot/clawdbot.json

# 2) Save your App Secret
mkdir -p ~/.clawdbot/secrets/
echo "your_app_secret_here" > ~/.clawdbot/secrets/feishu_app_secret
```

### 3. Launch the Bridge
```bash
# Enter the Feishu connector directory
cd <skill-dir>/feishu-connection

# Sync dependencies
uv sync

# Start the bridge (replace with your FEISHU_APP_ID)
FEISHU_APP_ID=cli_a5dxxxxx uv run python bridge.py
```

### 4. Interactive Test
Send a message like `Hello` to the bot in Feishu. You will see the event flow in your terminal:
1. Bridge receives the Feishu message.
2. Bridge forwards it to the local Gateway.
3. Gateway calls the AI and returns the response.
4. Bridge sends the response back to Feishu.

---

## Auto-start (macOS)

Each skill includes a launchd helper:

```bash
# Feishu
cd <skill-dir>/feishu-connection
FEISHU_APP_ID=cli_xxx uv run python setup_service.py

# DingTalk
cd <skill-dir>/dingtalk-connection
uv run python setup_service.py
```

## Repo layout

```
skills/
  feishu-connection/
  dingtalk-connection/
```

## License

MIT. See `LICENSE`.
