Integrate an IM bot

Updated at:

SysAgent can be integrated into DingTalk or Lark Instant Messaging (IM) group chats. After integration, group members can submit issues and receive results in the group chat. This topic describes how to create and configure a bot, register the connection information in SysAgent, add the bot to a group chat, and verify connectivity.

Prerequisites

  • Prepare a DingTalk or Lark account that has the permissions to create and configure apps and publish versions.

  • Determine the group chat that you want to integrate with SysAgent.

  • Make sure that the current account can access the SysAgent bot configuration entry in the Operating System Console.

  • Keep the app secret, Webhook, and access tokens secure. Do not expose them in group chats, tickets, or public materials.

Integrate a Lark bot

Configure a Lark app

  1. Log on to the Lark Open Platform and create an app.

  2. Add the Bot capability to the app.

  3. Configure the permissions required for the bot to send and receive messages, read group chat messages, obtain group information, send messages, and update cards.

  4. Select Long connection as the event subscription method.

  5. Subscribe to the events for the bot being added to a group, the bot being removed from a group, and message receiving, and configure the card callback.

  6. To add the bot to external groups, enable Allow the bot to be used in external groups before you publish the app. If approval is required on the page, contact your Lark administrator.

  7. After you confirm that the configuration is correct, publish the app version.

Note

Permission identifiers: im:message, im:message.group_at_msg:readonly, im:chat, im:message:send_as_bot, and cardkit:card:write. To receive one-to-one chat messages, you must also enable im:message.p2p_msg:readonly.

Event and callback identifiers: im.chat.member.bot.added_v1, im.chat.member.bot.deleted_v1, im.message.receive_v1, and card.action.trigger.

Register in SysAgent and add the bot to a group chat

  1. Log on to the Operating System Console, enter the connection information on the SysAgent bot configuration page, and save it.

  2. In Lark, select the target group chat and add the bot to the group chat by using its full name.

  3. Confirm that the bot appears in the member list of the group chat.

Integrate a DingTalk bot

Create and add a DingTalk bot

  1. Log on to the DingTalk Open Platform and create an app.

  2. Apply for the Group chat bot capability for the app.

  3. Set the message receiving mode and save the configuration.

  4. Add the bot to the target group chat.

  5. In the group chat, open the bot avatar and go to Bot settings.

Obtain the Webhook and register it in SysAgent

  1. Copy the Webhook in the bot settings.

  2. Log on to the Operating System Console and open the SysAgent bot configuration page.

  3. Enter the bot connection information and save it.

  4. Return to the target group chat and confirm that the bot is in the group.

Verify the integration

  1. Select a test question that does not contain sensitive information.

  2. Enter a specific object and issue.

  3. Send the message and confirm that the bot can receive the request.

  4. View the returned result and confirm that the object and content are consistent with the request.

FAQ

  • The Lark bot does not respond: check whether the app is published, and check the bot permissions, long connection, event subscriptions, card callback, and group membership status.

  • The DingTalk bot does not respond: check the group membership status of the bot, the message receiving mode, and the Webhook configuration.

  • The bot configuration entry does not appear in SysAgent: contact product service personnel to confirm the activation status of the current account, and refer to the prompts on the console page.

  • Messages can be received but results cannot be returned: check the connection information registered in SysAgent, save it, and test again.

  • The connection information is suspected to be leaked: update the connection information on the corresponding platform, and update the registered information in SysAgent accordingly.