群机器人-发送群聊消息

顾名思义,在群里的机器人,

https://open.dingtalk.com/document/orgapp/the-robot-sends-a-group-message

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.6f911563iCuHBc#/?devType=org&api=robot_1.0%23OrgGroupSend


主要下面几个参数

{
	"msgParam":"{ \"content\": \"xxxx\"}",
	"msgKey":"sampleText",
	"robotCode":"robotCode",
	"openConversationId":"cidzJ4ssfffxxxx8I1nhtTmg=="
}

返回值

{
	"processQueryKey":"lGLr2W0bJgmujHSZP9+uWl111111111W7oMRyuAeER8="
}

robotCode怎么来?

企业应用中添加机器人,然后有一个复制,如下所示


openConversationId 怎么来?

获取路径:创建部门和部门群 --> 获得部门群的dept_group_chat_id --> 获得部门群的openConversationId


首先创建个群,或者添加部门的时候同时添加的群

获取部门详情

https://open.dingtalk.com/document/isvapp/query-department-details0-v2

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.6f911563GA14Rh#/?devType=org&api=dingtalk.oapi.v2.department.get

主要用于获取部门关联的chatid(这里叫 dept_group_chat_id)

{
	"errcode":0,
	"result":{
		"brief":"",
		"dept_permits":[],
		"outer_permit_users":[],
		"emp_apply_join_dept":false,
		"org_dept_owner":"050349613226036264",
		"outer_dept":false,
		"auto_approve_apply":false,
		"dept_group_chat_id":"chat1dbd40d87123455",
		"group_contain_sub_dept":false,
		"auto_add_user":true,
		"parent_id":2750391,
		"hide_dept":false,
		"name":"测试用",
		"outer_permit_depts":[],
		"user_permits":[],
		"dept_id":900363352,
		"create_dept_group":true,
		"order":900363352
	},
	"errmsg":"ok",
	"request_id":"16ksnpebmi94h"
}


获取群会话的OpenConversationId

https://open.dingtalk.com/document/orgapp/obtain-group-openconversationid

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.6f911563GA14Rh#/?devType=org&api=im_1.0%23ChatIdToOpenConversationId

{
	"openConversationId":"cidzJ4ssfffxxxx8I1nhtTmg=="
}


获取群内机器人列表

https://open.dingtalk.com/document/orgapp/obtain-the-list-of-robots-in-the-group

https://open-dev.dingtalk.com/apiExplorer?spm=ding_open_doc.document.0.0.6f911563GA14Rh#/?devType=org&api=robot_1.0%23GetBotListInGroup

这一步非必须,如果不知道robotCode,这里也会带有