> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aihubmax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenClaw + Feishu

> Deploy an OpenClaw bot on Feishu (Lark) with AihubMax

## Overview

Deploy an AI-powered Feishu (Lark) bot using OpenClaw and AihubMax. This integration allows your team to interact with AI models directly within Feishu conversations.

<Info>
  This guide assumes you have already completed the basic [OpenClaw Manual Installation](/en/integration-guide/openclaw). If not, please set up OpenClaw first.
</Info>

## Prerequisites

<CardGroup cols={2}>
  <Card title="AihubMax API Key" icon="key">
    An active AihubMax API key.
  </Card>

  <Card title="OpenClaw Instance" icon="server">
    A running OpenClaw instance (see [Manual Installation](/en/integration-guide/openclaw)).
  </Card>

  <Card title="Feishu Developer Account" icon="building">
    Access to the [Feishu Open Platform](https://open.feishu.cn/) (or [Lark Open Platform](https://open.larksuite.com/) for international).
  </Card>
</CardGroup>

## Configuration

<Steps>
  <Step title="Create a Feishu App">
    1. Log in to the [Feishu Open Platform](https://open.feishu.cn/app) (or [Lark Open Platform](https://open.larksuite.com/app) for international).
    2. Click **Create App** > **Enterprise Self-Built Application**.
    3. Fill in the app name and description.
    4. Note down the **App ID** (format: `cli_xxx`) and **App Secret**.
  </Step>

  <Step title="Configure Permissions">
    In the Feishu Open Platform, navigate to **Permissions & Scopes** and add the following permissions:

    | Permission               | Description              |
    | ------------------------ | ------------------------ |
    | `im:message`             | Read and write messages  |
    | `im:message:send_as_bot` | Send messages as the bot |
    | `im:chat`                | Access chat information  |
    | `im:chat:readonly`       | Read chat information    |

    <Tip>
      You can batch import permissions via JSON in the Feishu Open Platform to save time.
    </Tip>
  </Step>

  <Step title="Enable Bot Capability">
    1. In the app settings, go to **App Capabilities** > **Bot**.
    2. Enable the bot capability.
  </Step>

  <Step title="Configure Event Subscriptions">
    1. Go to **Event Subscriptions**.
    2. Select **"Use Long Connection"** (WebSocket) as the connection method.
    3. Add the event: `im.message.receive_v1` (Receive messages).

    <Info>
      Using WebSocket long connection means you don't need a public URL or SSL certificate -- the connection is initiated from your server.
    </Info>
  </Step>

  <Step title="Install the Feishu Plugin">
    Install the OpenClaw Feishu plugin:

    ```bash theme={null}
    openclaw plugins install @openclaw/feishu
    ```
  </Step>

  <Step title="Configure OpenClaw">
    Add the Feishu configuration to `~/.openclaw/openclaw.json`:

    ```json theme={null}
    {
      "plugins": {
        "entries": {
          "feishu": {
            "enabled": true
          }
        }
      },
      "channels": {
        "feishu": {
          "enabled": true,
          "dmPolicy": "pairing",
          "accounts": {
            "main": {
              "appId": "cli_xxx",
              "appSecret": "your-app-secret",
              "botName": "My AI Assistant"
            }
          }
        }
      }
    }
    ```

    <Warning>
      Feishu credentials go under `channels.feishu.accounts`, NOT under `plugins.entries.feishu`.
    </Warning>

    Alternatively, you can set environment variables:

    ```bash theme={null}
    export FEISHU_APP_ID="cli_xxx"
    export FEISHU_APP_SECRET="your-app-secret"
    ```

    <Note>
      For Lark international users, add `"domain": "lark"` to the account configuration.
    </Note>
  </Step>

  <Step title="Publish and Test">
    1. In the Feishu Open Platform, click **Publish** to make your bot available.
    2. Add the bot to a Feishu group chat or start a direct conversation.
    3. Send a test message like **"Hello!"**
    4. The bot should respond using the configured AI model through AihubMax.
  </Step>
</Steps>

## Verify the Connection

Send a message to your Feishu bot:

```
Who are you? What model are you using?
```

The bot should reply with a response generated by the AI model configured through AihubMax.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Bot does not respond in Feishu">
    * Verify `appId` and `appSecret` are correct in the config.
    * Check that the bot has been published and approved.
    * Ensure the `im.message.receive_v1` event is subscribed.
    * Check OpenClaw logs for errors.
  </Accordion>

  <Accordion title="Permission denied errors">
    * Ensure all required permissions are granted in the Feishu Open Platform.
    * Some permissions require admin approval -- check the approval status.
    * After adding permissions, you may need to re-publish the bot.
  </Accordion>

  <Accordion title="Plugin not loading">
    * Verify the Feishu plugin is installed: check the plugins section in `openclaw.json`.
    * Ensure `"enabled": true` is set for both the plugin entry and the channel.
    * Restart the OpenClaw daemon after configuration changes.
  </Accordion>

  <Accordion title="AI model errors">
    * Verify your AihubMax API key is valid and has sufficient balance.
    * Test the API key directly:
      ```bash theme={null}
      curl https://api.aihubmax.com/v1/models \
        -H "Authorization: Bearer sk-your-foxapi-api-key"
      ```
  </Accordion>
</AccordionGroup>
