会话接入、结束和转接 - IM在线客服
接入会话
当用户向一个团队
发送消息时,该team所有在线状态的客服都将收到待接入会话,其中一个客服接入后,会话状态变为已接入状态,其他客服就无法接入。
let csteam = goEasy.im.csteam('team001');//客服团队或者商家id
csteam.accept({
customer: {
id:'customer001',//用户id
data: {name: '可爱前端', avatar: 'xxx.png'},//客户数据,用于显示在客服的会话列表
},
onSuccess: () => {
console.log('accept successfully.');
},
onFailed: (error) => {
console.log('accept failed', error);
}
});
结束会话
当客服人员完成一个用户的服务后,需要结束会话。
let csteam = goEasy.im.csteam('team001');//客服团队或者商家id
csteam.end({
id: 'customer001', //用户id
onSuccess: () => {
console.log('end successfully.');
},
onFailed: (error) => {
console.log('end failed', error);
}
})
转接会话
当客服人员接入一个会话后,在必要时可以将该会话转接给团队中的其他客服人员进行处理。
要注意的是:一个会话只能转接给状态为在线
的其他客服人员。
查询当前在线客服
let csteam = goEasy.im.csteam('team001');//客服团队或者商家id
csteam.agents({
onSuccess: (result) => {
console.log('当前在线客服:', result.content);
},
onFailed: (error) => {
console.log('查询当前在线客服失败', error);
}
});
将用户转接给指定客服
let csteam = goEasy.im.csteam('team001');//客服团队或者商家id
csteam.transfer({
customerId: 'customer001', //用户id
agentId: 'agent001',//新的客服id
onSuccess: () => {
console.log('转接成功');
},
onFailed: (error) => {
console.log('转接失败', error);
}
})