Integrate an agent with DingTalk
Integrate a Function Compute AgentRun agent with DingTalk to interact with it in group chats or private chats by @mentioning the bot.
Prerequisites
-
You have activated Function Compute and created an AgentRun agent. For instructions, see Create an agent without code.
-
You have DingTalk enterprise administrator permissions and can log on to the DingTalk Open Platform.
Step 1: Create a DingTalk app
1. Create an app and get credentials
-
Log on to the DingTalk Open Platform.
-
In the left navigation pane, choose Application Development, and then click Create App.
-
Select In-house App > DingTalk App, and then click Create App in the upper-right corner of the page.
-
Configure the app name, icon, and other information, and then click Save.
-
In the left navigation pane, click Credentials & Basic Information, and then copy the Client ID and Client Secret.
The Client Secret is displayed only once at creation. Store it securely. If you lose it, you must regenerate it.
2. Grant the required permissions
-
On the app management page, click Permission Management in the left navigation pane.
-
Search for and grant the following three permissions:
-
Write permissions for interactive card instances
-
Stream-based update permissions for AI cards
-
Permission to send messages from internal bots
All three permissions are required. If any are missing, the agent cannot send messages properly in DingTalk.
-
3. Configure the DingTalk bot
-
In the left navigation pane, choose App Capabilities > Add App Capability, and then add the Bots capability.
-
On the bot configuration page, enable the bot.
-
Enter a name and description for the bot.
-
Set Message receiving mode to Stream mode.
The AgentRun integration for DingTalk only supports Stream mode. Do not select HTTP mode.
-
Click Publish to save the bot configuration.
4. Publish the app
-
In the left navigation pane, choose App Release > Version Management & Release, and then click Create New Version.
-
Configure the app version number, visibility scope, and other information, and then click Save and confirm the release.
After the app is published, only DingTalk users within the specified visibility scope can use the bot.
Step 2: Configure DingTalk integration
-
Log on to the AgentRun console.
-
Click the name of the target agent to open its details page.
-
Click the Integration and Publishing tab, click IM Integration, and then click Add IM Bot.
-
In the Add IM Bot panel, set Robot Mode to Standard Bot, set Select Platform to DingTalk Bot, and then configure the following parameters:
Parameter
Description
Robot Name
Enter the display name of the bot. Maximum 128 characters.
Description
(Optional) Enter a description for the bot. Maximum 256 characters.
Robot Mode
Select Standard Bot to process messages using an Agent Endpoint.
Select Endpoint
Select a published Agent Endpoint for the bot to process messages.
Select Protocol
Select a protocol specification for message processing. If you have not created one, click Add Protocol to create a new one, or click Refresh Protocol List to update.
DingTalk Client ID
The Client ID of the DingTalk app from Step 1. You can get it from Application - Application Credentials in the DingTalk Developer Platform.
DingTalk Client Secret
The Client Secret of the DingTalk app from Step 1.
Enable upon Creation
Selected by default. The bot starts running immediately after creation. If you clear the checkbox, the bot is created in a stopped state and can be enabled later from the list.
-
Click Create Bot to complete the DingTalk integration configuration.
NoteAfter you enable the integration, AgentRun establishes a persistent connection with the DingTalk Open Platform and reserves one instance for this connection. This instance incurs charges. For more information, see Billing.
Step 3: Use the agent in DingTalk
After configuration, you can converse with the agent in a DingTalk group chat or private chat.
Use in a group chat
-
In DingTalk, create a new group chat or open an existing one.
-
In the group settings, click Bots > Add bot, search for the bot you created in Step 1, and then add it.
-
In the group chat, @mention the bot name and enter your question to chat with the agent.
Use in a private chat
In the DingTalk search bar, search for the bot by name, open its chat window, and send a message to start a private conversation.