自定义事件推送

通过自定义事件推送,客服系统可将会话和客服相关信息以回调方式自动推送到其他系统。

自定义事件推送为增值服务。如需开通,请提供租户ID并联系环信商务经理。

设置方法

设置方法:开通该功能后,进入“设置 > 自定义事件推送”页面,点击“创建事件推送”,填写自定义事件名称、接收事件的服务器地址,勾选需要推送的事件,并保存。

自定义事件推送

自定义事件

会话结束事件(ServiceSessionClosedEvent)

消息内容示例:

{
    "eventId": "ca81ade0-6dc5-11e6-9c13-dfa1eed70626", 
    "timestamp": 1472460726612, 
    "event": "ServiceSessionClosedEvent",                 //事件类型
    "payload": {
        "serviceSession": {
            "id": "4fe1b496-90ac-4412-8f40-0f6a13cbfc4b", //会话ID
            "state": "Terminal", 
            "origin_type": "webim",                       //渠道类型,webim为网页渠道
            "timestamp": {
                "create": 1472139263000,                  //会话创建时间
                "start": 1472139269000,                   //会话接起时间
                "stop": 1472460695000                     //会话结束时间
            }, 
            "channel": {                                  //关联
                "id": 3104, 
                "name": "快速创建的关联",                   //关联名称
                "type": "easemob"                         //关联类型,easemob代表环信IM
            }, 
            "visitor": {
                "id": "a6527ed1-e3f4-4537-aeef-ae35199e3765", //访客ID
                "name": "webim-visitor-RY7KQK99XVGXBE3JKCHM", //访客昵称
                "channel_user": {                             //访客所属渠道信息
                    "app_name": "sandbox", 
                    "channel_type": "easemob", 
                    "im_id": "webim-visitor-RY7KQK99XVGXBE3JKCHM", //访客的环信ID
                    "org_name": "sipsoft"
                }
            }, 
            "agent": {
                "id": "b58b99c1-cd3b-44d9-9821-20fb6a0f2f49", //坐席ID
                "name": "Admin",                              //坐席昵称
                "type": "Agent"                               //坐席类型,机器人、普通坐席或管理员
            }, 
            "agent_queue": {
                "id": 2112, 
                "name": "集体组"                              //技能组名称
            }, 
            "summary_category": [                            //会话标签,数组,包含所有的标签ID
                {
                    "id": 23976, 
                    "name": "测试4-4"
                }
            ], 
            "comment": ""                                    //会话备注
            "enquriy":{                               
                "score":3,                                   //满意度评分
                "comment":""                                 //满意度评价详情
            }
        }
    }
}

新消息事件(ServiceSessionMessageEvent)

消息内容示例:

文本消息

{
    "eventId": "3a7e82a0-aa60-11e5-8544-5111ba4b872e",
    "timestamp": 1450976598050,
    "event": "ServiceSessionMessageEvent",
    "payload": {
        "message": {
            "id": "dad14e23-4566-4ca6-b10e-fceeb59c42c2",      //消息ID
            "service_session_id": "4e27dd5e-683d-4664-a0db-bb8457ec7101",  //对应的会话ID
            "from": {
                "id": "27f74a74-5139-4f8c-b65f-15129e7808a8",  //发送方ID(可以是坐席或者访客)
                "name": "Admin",                               //昵称
                "type": "Agent"                                //类型
            },
            "origin_type": "app",                              //渠道
            "channel": {                                       //关联
                "id": 21,
                "type": "easemob"                              //管理类型
            },
            "body": {
                "type": "txt",                                 //消息类型:文本消息
                "msg": "asdf"                                  //消息内容
            }
        }
    }
}

图片消息

{
    "eventId": "bc4a6120-aa68-11e5-b3c3-dd9f501463d3",
    "timestamp": 1450980251761,
    "event": "ServiceSessionMessageEvent",
    "payload": {
        "message": {
            "id": "dc5004d7-39ce-4a03-bca0-af2c16b269d6",
            "service_session_id": "4e27dd5e-683d-4664-a0db-bb8457ec7101",
            "from": {
                "id": "2cb00d04-60f3-48a4-93b8-caf15b22a262",
                "name": "fa38294841604ac89ba2815689f8f636",
                "type": "Visitor"
            },
            "origin_type": "app",
            "channel": {
                "id": 21,
                "name": "yaaa",
                "type": "easemob"
            },
            "body": {
                "type": "img",                                        //消息类型:图片
                "url": "/v1/Tenant/5631/MediaFiles/df56bebd-433c-4b0e-aab9-1684fb75999f", //图片下载地址
                "secret": "u9X0eqpoEeW-Hw1NajGLHchLw_cjQA0WifvU7Lid7UsaLafh",
                "filename": "image.jpg",   //文件名
                "size": {                  //图片尺寸
                    "width": 2448,
                    "height": 3264
                }
            }
        }
    }
}

创建坐席事件(AgentUserCreationEvent)

消息内容示例:

{
    "eventId": "cfb76910-a9fa-11e5-844c-37fa6bbad3ec", 
    "timestamp": 1450933062687, 
    "event": "AgentUserCreationEvent", 
    "payload": { 
        "agent": { 
            "id": "614f3fb7-d757-4894-ba17-90a7c1488a59", 
            "username":"a@qq.com", 
            "nickname":"agent1", 
            "name":"aaaa", 
            "roles":["admin","agent"], 
            "business_id":"11111", 
            "phone":"13311111111", 
            "created_at":123412341234, 
            "updated_at":123412342123 
        } 
    } 
}

坐席状态变更事件(AgentUserStateChangedEvent)

客服和管理员的登录状态分为五种:空闲(online)、忙碌(busy)、离开(leave)、隐身(hidden)、离线(offline),并且,客服和管理员可以切换自己的空闲/忙碌/离开/隐身状态。关于登录状态的描述,见在线状态

如果开通坐席状态变更事件推送,当对应客服/管理员状态变更时,会收到推送消息。

消息内容示例:

{ 
    "eventId": "45114db0-d639-11e5-91c0-a11acb243a77", 
    "timestamp": 1455797716755, 
    "event": "AgentUserStateChangedEvent", 
    "payload": { 
        "agent": { 
            "id": "28d0a4aa-bf19-4724-ab9d-3b74afed34a8", 
            "nickname": "Admin", 
            "username": "licx@easemob.com" 
        }, 
        "status": "Online", 
        "stateChangeTime": 1455797716491 
    } 
} 

坐席登出事件(AgentUserLogoutEvent)

消息内容示例:

{ 
    "eventId": "a9928560-d639-11e5-8447-854851e278ee", 
    "timestamp": 1455797885117, 
    "event": "AgentUserLogoutEvent", 
    "payload": { 
        "agent": { 
            "id": "28d0a4aa-bf19-4724-ab9d-3b74afed34a8", 
            "nickname": "Admin", 
            "username": "licx@easemob.com" 
        }, 
        "logoutTime": 1455797885109 
    } 
} 

删除坐席事件(AgentUserDeletedEvent)

消息内容示例:

{
    "eventId": "07ffc670-ce74-11e6-a4aa-e9370bc22534",
    "timestamp": 1483090934322,
    "event": "AgentUserDeletedEvent",
    "payload": {
        "agent": {
            "id": "4b4f0f36-8286-4ccd-8e99-50b33cfdf958",
            "username": "713test10@qq.com",
            "nickname": "10",
            "name": "",
            "roles": [
                "agent"
            ],
            "phone": "",
            "created_at": 1483090749000,
            "updated_at": 1483090749000
        }
    }
}