Manage chatbots

Update time: 2022/12/13 09:24:22

Add, delete, or clear chatbot accounts.

Add one or more chatbots in a chat room

Add one or more chatbots in a specified chat room. The chatbots expires in 24 hours.

URL

httpPOST https://api.netease.im/nimserver/chatroom/addRobot.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

Request parameters

  • For information about how to set the header in a POST request, see API Call methods.

  • The settings of the body in a POST request:

ParameterTypeRequiredDescription
roomid longYes Chat room ID
accids JSONArray Yes List of chatbot accounts (accids). A maximum number of 100 accounts are allowed.
roleExt String No Chatbot information extension field in JSON, up to 4,096 characters
notifyExt String No Extension field for the notification of chatbot joining a chat room in JSON, up to 2,048 characters.

Example

cURL request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/addRobot.action'

Example success response

json
"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]",
    "oldAccids": "[\"hzwangwu\"]"
  },
  "code": 200
}

Delete one or more chatbots from a chat room

Delete one or more chatbots from a chat room. You can delete a maximum of 100 chatbots at a time.

httpPOST https://api.netease.im/nimserver/chatroom/removeRobot.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

Request parameters

  • For information about how to set the header in a POST request, see API Call methods.

  • The settings of the body in a POST request:

ParameterTypeRequiredDescription
roomid longYes Chat room ID
accids JSONArray Yes List of chatbot accounts (accids). A maximum number of 100 accounts are allowed.

Example

cURL request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&accids=["zhangsan","lisi"]' 'https://api.netease.im/nimserver/chatroom/removeRobot.action'

Example success response

json"Content-Type": "application/json; charset=utf-8"
{
  "desc": {
    "failAccids": "[\"hzzhangsan\"]",
    "successAccids": "[\"hzlisi\"]"
  },
  "code": 200
}

Clear all chatbots

Clear all chatbots in a chat room.

URL

httpPOST https://api.netease.im/nimserver/chatroom/cleanRobot.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8

Request parameters

  • For information about how to set the header in a POST request, see API Call methods.

  • The settings of the body in a POST request:

ParameterTypeRequiredDescription
roomid longYes Chat room ID
notify boolean No Whether a notification message is sent for leaving a chat room. The default value is false

Example

cURL request example

curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: f541664055e557244421661866ad7799" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=70&notify=false' 'https://api.netease.im/nimserver/chatroom/cleanRobot.action'

Example success response

json"Content-Type": "application/json; charset=utf-8"
{
    "code": 200,
    "desc": {
        "size": 2
    }
}

Status codes

The status code is returned in the response body. For more information, see Status codes.

Was this page helpful?
Yes
No
  • Add one or more chatbots in a chat room
  • URL
  • Request parameters
  • Example
  • cURL request example
  • Example success response
  • Delete one or more chatbots from a chat room
  • Request parameters
  • Example
  • cURL request example
  • Example success response
  • Clear all chatbots
  • URL
  • Request parameters
  • Example
  • cURL request example
  • Example success response
  • Status codes