For users who integrate external IM platforms through the Forward Channel API, this guide covers channel authorization, fixed/pairing execution context modes, chat commands, and how to create the app/bot, configure permissions, and obtain credentials for each channel.
Distinguish channel authorization from Channel Pairing
Forward Channel has two independent configuration dimensions:
| Dimension | Problem it solves | Options |
|---|---|---|
| Channel authorization | How Forward obtains IM bot connection and send/receive permissions | QR Session scan (recommended) or direct credentials |
| Identity resolution | Which Identity and Template should be used for a given inbound message | fixed or pairing |
pairing Channel still needs to complete channel authorization first so binding_status=bound; afterwards, when a real IM conversation is triggered for the first time, Forward generates a Pairing Code to bind the execution context for that message scope.
QR-code binding flow (recommended)
QR-code binding works for all channels — dingtalk, feishu, wecom, wechat. The steps are:
- Create the Channel: call Create Channel with
name,channel_type, and the desired identity resolution mode, omittingchannel_config.credentials. Forfixedmode, also passidentity_idandtemplate_id; forpairingmode, passidentity_resolution.mode=pairingwithoutidentity_idortemplate_id. - Create a QR Session: call Create Channel QR Session to obtain
qr_code_image_base64(the QR code image) orqr_code_content(the authorization URL).poll_interval_secondsis an optional compatibility field and should not be relied upon as a stable return value. - Show the QR code and authorize: display the QR code to the user, then use the corresponding channel client to scan and confirm authorization.
- Poll the authorization status: call Get Channel QR Session to poll
status. Usepoll_interval_secondsif present; otherwise default to a 3-second interval. Poll untilconfirmed(other states:waiting,scanned,expired,denied,error). - Complete channel authorization: after
status=confirmed, refresh the Channel detail;binding_statuswill becomebound. AfixedChannel can now process inbound messages with its fixed execution context; apairingChannel will return a Pairing Code for unpaired messages — complete Channel Pairing (below) before messages enter the Agent.
QR codes have a short validity. If a session becomes
expired or denied, create a new QR Session and scan again.Identity resolution modes
fixed mode
fixed is the default. You must specify identity_id and template_id when creating the Channel; all inbound messages use this fixed execution context:
pairing mode
In pairing mode, the Channel only represents an IM transport connection — no Identity or Template is specified at creation:
- A user sends a message from a real IM private chat or group chat to the bot.
- Channel Gateway creates a pending pairing record for the unpaired direct/room scope and sends a pairing code prompt without creating a Session.
- The admin calls Pair a channel with
code + identity_id + template_id. For automated authorization, first query List channel pairings, match your rules againstchannel_id + scope_type + scope_external_id, then submitchannel_pairing_id + identity_id + template_id. - Subsequent messages resolve Identity and Template via the Pairing, then create or reuse a Session.
- To revoke the binding, use the
idfrom the Pair response to call Unpair a channel.
Identity state and messages
In both fixed and pairing modes, if the resolved Identity is disabled, new ordinary messages do not start Agent execution. The channel returns an Identity-disabled message asking the user to enable it and try again. Accepted executions and result replies finish naturally. Confirmations for existing pending actions and /cancel continue to follow the existing Session and permission rules.
Disabling an Identity does not unbind the channel or change the Channel's own switch. Re-enabling the Identity does not automatically enable a manually disabled Channel. See Disable an identity and Enable an identity.
Chat commands
After channel authorization, you can send the following text commands in conversations with the bot. In pairing mode, complete pairing first. Commands apply to the current conversation in which the message is sent. Group chats, channels, and topics still follow the channel's trigger rules; where an explicit @Bot mention is required, include @Bot when sending a command as well.
| Command | Alias | Purpose |
|---|---|---|
/help | /? | View available commands and usage. |
/status | /state | View the current session ID, task status, queued message count, model, context window size, and session link. |
/clear | /new | Clear the current session and queued messages. If a task is running, request cancellation first. The next message starts a new session. |
/cancel | /stop | Request cancellation of the running task and clear queued messages, keeping the current session. |
/btw <question> | — | Answer a temporary question using the current session context, without affecting the main task or writing to its history. For example, /btw What risks remain in the current plan?. |
/target | — | View the current channel's push target information and configuration JSON, which can be used to configure Schedule sinks. |
/, and command names are case-insensitive. Both /cancel and /clear clear unprocessed messages queued in the current session. To stop only the current task and continue the same session afterward, use /cancel.
In fixed mode, /target returns the Channel ID and the external user or group ID. In pairing mode, it returns the authorized Channel Pairing ID. For push target formats and limits, see Create a schedule: Push targets.
Direct credential integration (as needed)
If you must use direct credentials, create an app/bot on the corresponding open platform, configure the required permissions, obtain the credentials, and then pass them to Create Channel through channel_config.credentials. Mapping of channel_type and credential fields per channel:
| Channel | channel_type | channel_config.credentials fields | Supports QR binding |
|---|---|---|---|
| DingTalk | dingtalk | client_id, client_secret | Yes (recommended) |
| Feishu | feishu | app_id, app_secret | Yes (recommended) |
| WeCom | wecom | bot_id, secret | Yes (recommended) |
| Personal WeChat | wechat | No credentials required | QR binding only |
Credentials are only written when creating/updating a Channel; they are never returned in plaintext.
DingTalk
Create a DingTalk app
- Go to the DingTalk Open Platform. Choose an organization that has developer permissions, or acquire developer permissions on a given organization. If no suitable organization exists, use the DingTalk mobile app to quickly create one by scanning a QR code.
- In the top navigation, click App Development, then click Create App on the DingTalk App page.
Create a DingTalk bot
- Once the app is created, select Add App Capability in the left navigation, then click Add on the bot card.
- On the bot configuration page, enable bot configuration.
- For Message Reception Mode, choose Stream mode, then click Publish to finish configuring the bot.
Configure permissions
In the app's Permission Management, enable the following permissions:
| Permission | Description |
|---|---|
Card.Streaming.Write | Streaming write to card messages |
Card.Instance.Write | Create / update card instances |
qyapi_robot_sendmsg | Bot sends messages |
Publish the app
- Select Version Management and Release in the left navigation, then click Create New Version.
- Fill in the app version number and description, choose the app's availability scope based on your business needs, and click Save to publish.
If the availability scope is set to all employees, the app will be visible to every employee of the current enterprise after publishing.
Get the credentials
On the Credentials & Basic Info page in the left navigation, record the Client ID and Client Secret — they correspond to the API's client_id and client_secret.
Feishu
Create a Feishu app
- Visit the Feishu Open Platform and click Developer Console in the top-right corner.
- Click Create Custom App for Enterprise, fill in the required info, and click Create.
Add and configure the bot
- Select Add App Capability in the left navigation, and click Add on the bot card.
- Click the edit icon next to "How to get started" on the bot configuration card.
- Under Message Card Callback Request Method, click Configure, choose Receive callbacks via long connection, and save.
- Click Event Configuration, choose the same Receive callbacks via long connection subscription mode, and save.
- On the Event Configuration page, add the following four events and save:
- Bot joined chat
- Bot removed from chat
- Message read
- Receive message
Configure permissions
In Permission Management > Enable Permissions, click Batch Import / Export Permissions, paste the JSON below to import the required permissions in one click, confirm, and click Apply for Approval:
Publish the app
- Select Version Management and Release in the left navigation.
- Click Create Version, fill in the required info, and click Save.
Get the credentials
On the app's Credentials & Basic Info page, copy the App ID (format like cli_xxx) and App Secret — they correspond to the API's app_id and app_secret.
WeCom
Create a smart bot
- Visit the WeCom Admin Console. In the left navigation, click Security & Management > Management Tools, click Create Bot, and then click Manually Create.
- Configure the bot's visibility scope.
- Scroll to the bottom and click API Mode Creation, and choose Use long connection as the connection method.
Get the credentials
In the Secret area of the configuration method, click Get and record the Bot ID and Secret — they correspond to the API's bot_id and secret.
Personal WeChat
Personal WeChat only supports QR-code binding — no need to create an app on any open platform, and no direct credentials are required. When creating a Channel, pass wechat as channel_type and complete the authorization following the QR-code binding flow (recommended) above.