自定义事件推送

通过自定义事件推送,客服系统可将会话和客服相关信息以回调方式自动推送到其他系统。这些事件可应用到多种使用场景,如计算排队时长等。

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

设置方法

推送自定义事件至第三方服务器:

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

设置自定义事件推送

自定义事件

会话结束事件

事件名称: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 
        } 
    } 
}

坐席状态变更事件

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

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

事件名称:AgentUserStateChangedEvent

消息内容示例:

{ 
    "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
        }
    }
}

添加访客标签

事件名称:VisitorTagAddedEvent

消息内容示例:

{
    "eventId": "9f727ee0-07b7-11e7-b77f-3b3c6fac2bb4",
    "timestamp": 1489387089477,
    "event": "VisitorTagAddedEvent",
    "payload": {
        "visitorUserTag": {
            "visitorUserId": "2ad4af98-903a-4050-9cea-2d5807c85002",
            "userTagId": 5596,
            "tag": {
                "tagName": "普通客户",
                "created_at": 1436805675000
            }
        }
    }
}

删除访客标签

事件名称:VisitorTagRemovedEvent

消息内容示例:

{
    "eventId": "a7364210-07b7-11e7-9a61-dbd5753351ee",
    "timestamp": 1489387102520,
    "event": "VisitorTagRemovedEvent",
    "payload": {
        "visitorUserTag": {
            "visitorUserId": "2ad4af98-903a-4050-9cea-2d5807c85002",
            "userTagId": 5596,
            "tag": {
                "tagName": "普通客户",
                "created_at": 1436805675000
            }
        }
    }
}

访客信息变更

事件名称:VisitorUserChangeEvent

消息内容示例:

{
    "eventId": "b9c1e0b0-07b7-11e7-8ab4-53b659cd1343",
    "timestamp": 1489387133611,
    "event": "VisitorUserChangeEvent",
    "payload": {
        "visitor": {
            "id": "2ad4af98-903a-4050-9cea-2d5807c85002",
            "username": "webim-visitor-EM3GEFC7TBQVRXYM6GGC",
            "nickname": "Leoli",
            "name": "Leoli",
            "roles": [
                "visitor"
            ],
            "gendar": 0,
            "created_at": 1488884778000,
            "updated_at": 1489387133493
        }
    }
}

坐席信息变更

事件名称:AgentUserChangeEvent

消息内容示例:

{
    "eventId": "d0a31dd0-07b7-11e7-b1a7-eb03c0f01476",
    "timestamp": 1489387172031,
    "event": "AgentUserChangeEvent",
    "payload": {
        "agent": {
            "id": "eb524dc0-be91-47ac-b6e6-10d013d7d72b",
            "username": "713test4@qq.com",
            "nickname": "Leoli",
            "name": "leoli",
            "roles": [
                "admin",
                "agent"
            ],
            "phone": "18612389889",
            "business_id": "1001",
            "created_at": 1453900968000,
            "updated_at": 1489128601000
        },
        "old_agent": {
            "id": "eb524dc0-be91-47ac-b6e6-10d013d7d72b",
            "username": "713test4@qq.com",
            "nickname": "Leoli",
            "name": "",
            "roles": [
                "admin",
                "agent"
            ],
            "phone": "",
            "created_at": 1453900968000,
            "updated_at": 1489128601000
        }
    }
}

会话创建

事件名称:ServiceSessionCreatedEvent

消息内容示例:

{
    "eventId": "07da4280-6c74-11e7-ba25-29a88e1d64f3",
    "timestamp": 1500463126206,
    "event": "ServiceSessionCreatedEvent",
    "payload": {
        "serviceSession": {
            "id": "d93d1e6c-7bce-4f2e-97e7-40d3c0427d95",
            "state": "Wait",
            "origin_type": "webim",
            "from_agent_callback": false,
            "timestamp": {
                "create": 1500463126000
            },
            "visitor": {
                "id": "e3243090-848a-44fb-babd-f0c3a561d31f",
                "name": "webim-visitor-8WCFW7M7YEGEF2EJCYCP"
            },
            "channel": {
                "id": 10625,
                "type": "easemob"
            },
            "agent_queue": {
                "id": 35018
            }
        }
    }
}

会话接起

事件名称:ServiceSessionOpenedEvent

消息内容示例:

{
    "eventId": "381b7860-6c74-11e7-805a-c112ad1e2ce6",
    "timestamp": 1500463207157,
    "event": "ServiceSessionOpenedEvent",
    "payload": {
        "serviceSession": {
            "id": "d93d1e6c-7bce-4f2e-97e7-40d3c0427d95",
            "state": "Processing",
            "origin_type": "webim",
            "timestamp": {
                "create": 1500463126000,
                "start": 1500463207000
            },
            "visitor": {
                "id": "e3243090-848a-44fb-babd-f0c3a561d31f",
                "name": "webim-visitor-8WCFW7M7YEGEF2EJCYCP"
            },
            "channel": {
                "id": 10625,
                "type": "easemob"
            },
            "agent_queue": {
                "id": 6767
            }
        }
    }
}

会话转接

事件名称:ServiceSessionTransferedEvent

消息内容示例:

{
  "eventId": "c3bad5c0-a1ba-11e7-a05d-4db7a46cd15c",
  "timestamp": 1506320917962,
  "event": "ServiceSessionTransferedEvent",
  "payload": {
    "serviceSession": {
      "id": "562785f2-aed6-4420-bac5-fb1d2bd82f0e",
      "state": "Wait",
      "origin_type": "webim",
      "transfered_to_agent_queue": true,
      "transfered_from": {
        "from_agent_user_id": "946f116d-2e09-410c-9015-4b480edc9939",
        "from_agent_user_nice_name": "Admin",
        "from_agent_user_type": "Agent"
      },
      "transfered_to": {
        "to_queue_id": 39005
      },
      "timestamp": {
        "create": 1506320908000,
        "start": 1506320910000
      },
      "visitor": {
        "id": "678c9d67-f2f1-498f-a458-6f3fbf223a64",
        "name": "webim-visitor-RXFC9WR4KRG8FMK98PCY"
      },
      "channel": {
        "id": 10625,
        "type": "easemob"
      },
      "agent_queue": {
        "id": 39005
      }
    }
  }
}

待接入会话结束

事件名称:ServiceSessionAbortedEvent

消息内容示例:

{
  "eventId": "4642aae0-a1bb-11e7-bc37-fbf67fe4d942",
  "timestamp": 1506321136945,
  "event": "ServiceSessionAbortedEvent",
  "payload": {
    "serviceSession": {
      "id": "562785f2-aed6-4420-bac5-fb1d2bd82f0e",
      "state": "Abort",
      "origin_type": "webim",
      "abort_actor": {
        "user_id": "946f116d-2e09-410c-9015-4b480edc9939",
        "user_name": "260553619@qq.com",
        "nice_name": "Admin"
      },
      "timestamp": {
        "create": 1506320908000,
        "start": 1506321136000,
        "stop": 1506321136000
      },
      "channel": {
        "id": 10625,
        "type": "easemob"
      },
      "visitor": {
        "id": "678c9d67-f2f1-498f-a458-6f3fbf223a64",
        "name": "webim-visitor-RXFC9WR4KRG8FMK98PCY"
      },
      "agent_queue": {
        "id": 39005
      }
    }
  }
}