# Configure Feishu event subscriptions

Feishu sends subscribed events, such as incoming messages, to MOI. MOI routes them to the configured agent or task.

## Prepare the app and credentials

Use a Feishu custom app with bot capability. If necessary, follow [Prepare a Feishu app](message.md#prepare-feishu-app) first.

Copy **App ID** and **App Secret** from credentials and basic information. Open **Events and callbacks → Encryption policy** and copy **Verification Token**. Also copy **Encrypt Key** if event encryption is enabled. All credentials must come from the same app.

## Create the MOI subscription instance

1. Open **Resource Center → Tools → Feishu**.
2. Select **Add → Event subscription**.
3. Enter the instance name, App ID, App Secret, and Verification Token. Enter Encrypt Key only when the Feishu app uses event encryption.
4. Save, open instance details, and copy the **MOI callback URL**.

## Configure Feishu events

1. Open the same app in the developer console and navigate to **Events and callbacks → Event configuration**.
2. Choose delivery to a developer server, enter the MOI callback URL, and complete URL verification. See [Feishu request-URL configuration](https://open.feishu.cn/document/server-docs/event-subscription-guide/event-subscription-configure-/request-url-configuration-case).
3. Select **Add event**. To receive chat messages, select **Receive message v2.0** (`im.message.receive_v1`) and confirm.
4. Enable the permissions required by the [receive-message event](https://open.feishu.cn/document/server-docs/im-v1/message/events/receive).
5. Create and publish an app version. Verify that the test user is within its availability scope.

## Route and validate events in MOI

Return to the subscription instance and configure its event-routing target. Send a matching test message in a group or direct conversation. Check Feishu delivery and execution of the correct MOI target separately.

| Symptom | Check |
| --- | --- |
| Callback verification failed | URL, Verification Token, Encrypt Key, and reachability |
| Feishu does not deliver events | Added subscription, required permissions, and republished app version |
| MOI receives events without triggering the target | Correct routing target and event type on the subscription instance |

- [Feishu configuration](../feishu.md)
