我正在尝试使用 DDP Realtime API 发起 LiveChat 对话,但我遇到了问题。
https://rocket.chat/docs/developer-guides/realtime-api/livechat-api
我正在按照文档执行所有步骤。在第一个 API 结果中,您可以看到它 saunumAgents: 2
和online: true
. 但是,当我尝试向同一部门发送消息时,它会说:“对不起,没有在线代理”。
有没有办法找出问题所在?
的结果livechat:getInitialData
{ enabled: true,
title: 'xyz.com',
color: '#C1272D',
registrationForm: false,
room: null,
triggers: [],
departments:
[ { _id: 'CxCTgXL4csw3TcW6S',
enabled: true,
name: 'Support',
description: '',
numAgents: 2,
showOnRegistration: true,
_updatedAt: 2017-09-24T06:46:39.657Z } ],
allowSwitchingDepartments: true,
online: true,
offlineColor: '#666666',
offlineMessage: 'We are not online right now. Please leave us a message:',
offlineSuccessMessage: '',
offlineUnavailableMessage: '',
displayOfflineForm: true,
videoCall: true,
offlineTitle: 'Leave a message',
language: '',
transcript: false,
transcriptMessage: 'Would you like a copy of this chat emailed?' }
的结果livechat:registerGuest
{ userId: 'j65Cp5peeLJLYhWQi',
token: 'J8IpnpB1yN1AYtO0e0EzLhuaRhe0zaZkjHBAamsehSO' }
登录结果
{ id: 'j65Cp5peeLJLYhWQi',
token: 'J8IpnpB1yN1AYtO0e0EzLhuaRhe0zaZkjHBAamsehSO',
tokenExpires: 2017-12-23T07:45:01.928Z }
的结果sendMessageLivechat
{ isClientSafe: true,
error: 'no-agent-online',
reason: 'Sorry, no online agents',
message: 'Sorry, no online agents [no-agent-online]',
errorType: 'Meteor.Error' }
这些是我发送到的参数sendMessageLiveChat
。
"_id" : "j65Cp5peeLJLYhWQi"
"rid" : "a_random_string"
"msg": "Hello"
"token" : "J8IpnpB1yN1AYtO0e0EzLhuaRhe0zaZkjHBAamsehSO"
有人可以帮助我吗?
这就是我调用 registerGuest 的方式。
ddpClient.call("livechat:registerGuest",[{"token":authToken,"name":"test1","email":"test2@gmail.com","department":department._id},25],function(err, info){
});
我这里传递的令牌是管理员的 authToken
ddpClient 对象是使用 DDP npm 包获取的。