开发文档

    APIs

    企业若使用APIs访问工作台的对话、留言、客户等资源,需要在「设置中心 - 开发者 - APIs」中获取“APPID”和密钥,后续调用以下 APIs 时都需要使用 。

    注意:使用开放接口需要一定技术能力,请由网站技术人员参考本文代码对接实现。

    请求的 Header 需要带上以下参数:

    参数 类型 说明
    accountid int 账号id
    appid string appid
    secret string 密钥

    获取单个会话

    通过HTTP Post 方式请求 /api/open/getsession,参数如下:

    参数 类型 说明
    visitorid string 访客id

    响应:

    {
    	error_code:0, //错误码
    	description:"success",
    	data:{
    	      单个会话信息,具体参数可去webhooks中查找会话模型
    	      }
    }

    获取单个客户

    通过HTTP Post 方式请求 /api/open/getcustomer,参数如下:

    参数 类型 说明
    visitorid string 访客id

    响应:

    {
    	"data": {
    		"id": "标识id",
    		"visitorid": "访客id",
    		"name": "姓名",
    		"sex": 0, //性别 
    		"age": 0 //年龄
    	},
    	"error_code": 0,
    	"description": "success"
    }

    回复消息

    通过HTTP Post 方式请求/api/open/replymsg,参数如下:

    参数 类型 说明
    visitorid string 访客id
    sessionid string 会话id
    content json 消息内容json

    消息内容,参数如下:

    消息类型 参数值 说明
    文本消息 {type:0,text:"内容"}
    图片消息 {type:1,url:"图片路径",thumburl:"缩率图路径"} 缩略图路径可以为空
    素材消息 {type:2,material_id":"素材id"}
    type值说明

    2:小红书笔记

    3:小红书落地页

    4:小红书名片

    5:小红书留资卡

    6:小红书交易卡

    7:抖音留资卡

    8:抖音小程序卡

    9:抖音一键留资卡

    10:快手留资卡

    11:快手链接卡

    12:快手门店卡

    13:快手企微卡

    响应:

    {
    	"error_code": 0, //错误码
    	"description": ""
    }

    响应参数说明

    参数 参数值 说明
    error_code 1001 参数不合法。一般为accountid、appid、secret、visitorid、sessionid、content有为空的情况
    error_code 1002 服务器错误,请联系管理员
    error_code 1003 账号过期
    error_code 1004 账号无效
    error_code 1027 appid有误
    error_code 1049 secret有误
    error_code 1042 请求接口达到频控限制,默认为30次/分
    error_code 1012 会话不存在,请查看对话列表里面是否有对话
    error_code 1016 发送图片大小超过2M
    error_code 1019 会话状态不在对话中
    error_code
    description
    1001
    material_id error
    素材id为空
    error_code
    description
    1007
    material error
    要发送得素材不存在

    获取单个留言消息

    通过HTTP Post 方式请求 /api/open/getleavemessages,参数如下:

    参数 类型 说明
    sessionid string 访客会话id

    响应:

    {
    	"data": [{
    		"createtime": "创建时间",
    		"contenttype": "内容类型",
    		"msgtype": "消息类别",
    		"content": "留言内容",
    		"operatorid": "客服id",
    		"groupid": "客服组",
    	}],
    	"error_code": 0,
    	"description": "success"
    }

    获取留言会话,翻页查询

    通过HTTP Post 方式请求 /api/open/getleavesessions,参数如下:

    参数 类型 说明
    page int 页码
    size int 每页行数
    timebegin datetime 时间范围 开始
    timeend datetime 时间范围 结束

    响应:

    {
    	"data": {
    		"page": "页码",
    		"count": "总数",
    		"items": "留言会话列表", //数据格式见留言会话模型
    	},
    	"error_code": 0, //错误码
    	"description": ""
    }

    留言消息模型

    参数 类型 说明
    createtime datetime 留言创建时间
    contenttype int 留言内容类别
    msgtype int 消息类别
    content string 留言内容,根据消息类别存储为json格式
    operatorid int 最后处理客服id
    groupid int 最后处理客服分组id

    留言会话模型

    参数 类型 说明
    sessionid string 会话id
    visitorid string 访客永久身份
    createtime datetime 留言创建时间
    accessway int 会话接入方式/渠道
    nickname string 访客昵称
    remark string 访客备注
    appid string 应用接入appid
    appname string 应用名称
    email string 客人邮箱地址
    status int 处理状态
    updateby int 更新人
    updatetime datetime 最后修改时间
    operatorid int 最后处理客服id
    groupid int 最后处理客服分组id

    获取素材

    通过HTTP Post 方式请求/api/open/getmaterials

    请求的 Header 需要带上以下参数:

    参数 类型 说明
    accountid int 账号id
    appid string appid
    secret string 密钥
    content-type 固定值 "application/json"

    body参数如下:

    参数 类型 说明
    type int
    type值说明

    1:小红书笔记

    2:小红书落地页

    3:小红书名片

    4:小红书留资卡

    5:小红书交易卡

    6:抖音留资卡

    7:抖音小程序卡

    8:抖音一键留资卡

    9:快手留资卡

    10:快手链接卡

    11:快手门店卡

    12:快手企微卡

    authid string 非必填,授权账号id,session中的appid(应用接入 appid)。
    多个号,使用逗号(“,”)分割,
    例如:6719ae69000000000b0322e1,6719ae690000aaaa00b0322e1
    page int 非必填,查询小红书笔记时传入,最小1
    size int 非必填,查询小红书笔记时传入,最大50

    响应:

    {
    	data": {
            "list": [
                {
                    "type": 素材类型
    		"appid": 授权账号id,session中的appid(应用接入 appid)
                    "material_id": 素材id
                    "title": 素材title
    
                    "content": { //string 素材展示的详细信息
    					"title":'',
    					"image":''
    			}
                }
            ]
        },
        "error_code": 0,
        "description": "success"
    }

    响应参数说明

    参数 参数值 说明
    error_code 1001 参数不合法。一般为accountid、appid、secret有为空的情况
    error_code 1002 服务器错误,请联系管理员
    error_code 1003 账号过期
    error_code 1004 账号无效
    error_code 1027 appid有误
    error_code 1042 请求接口达到频控限制,默认为30次/分
    error_code 1049 secret有误
    error_code
    description
    1001
    type error
    素材类型有误
    error_code
    description
    1001
    authid error
    授权账号有误
    error_code
    description
    1001
    page error
    查询小红书笔记,页码有误。
    error_code
    description
    1001
    size error
    查询小红书笔记,页数有误。