jarvis-js-sdk
v1.7.1
Published
<dl> <dt><a href="#Client">Client</a></dt> <dd></dd> </dl>
Readme
Classes
Typedefs
Client
Kind: global class
- Client
- new Client(handler, options)
- instance
- .open()
- .close()
- .isOpened() ⇒ boolean
- .isConnecting() ⇒ boolean
- .buildMessage(messageType, content, conversationId) ⇒ Message
- .sendMessage(message, toId) ⇒ Promise
- .recallMessage(messageId) ⇒ Promise
- .readMessage(messageId) ⇒ Promise
- .closeConversation(conversationId) ⇒ Promise
- .inviteRate(userId) ⇒ Promise
- .selectMenuItem(menuItemId) ⇒ Promise
- .inputting(content, conversationId, toId) ⇒ Promise
- .getUserInfo() ⇒ Promise
- .updateMyProfile(data) ⇒ Promise
- .getConversations(params) ⇒ Promise
- .getConversationById(conversationId) ⇒ Promise
- .updateUserProfile(id, data) ⇒ Promise
- .rateStaff(score, suggestion, ratingTagIds) ⇒ Promise
- .getVisitInfo(id) ⇒ Promise
- .getPendingCount() ⇒ Promise
- .addCustomerTag(id, data) ⇒ Promise
- .deleteCustomerTag(id, tagId) ⇒ Promise
- .getQuickReply() ⇒ Promise
- .addQuickReply(data) ⇒ Promise
- .editQuickReply(id, data) ⇒ Promise
- .deleteQuickReply(id) ⇒ Promise
- .adminCloseConversation(id) ⇒ *
- .exportHistoryConversations(data) ⇒ Promise
- .getTransferServiceList(params) ⇒ Promise
- .conversationTransfer(id, data) ⇒ Promise
- .requestConversations(data) ⇒ Promise
- .getConversationsCount(params) ⇒ Promise
- .uploadBlobs(file, onUploadProgress) ⇒ Promise
- .likeRobotAnswer(id) ⇒ Promise
- .dislikeRobotAnswer(msgId) ⇒ Promise
- .getSuggestions(query, subChannelId) ⇒ Promise
- .getPendingPosition(convId) ⇒ Promise
- .getCurrentConversationList() ⇒ Promise
- .getSubChannel(subChannelId) ⇒ Promise
- .getHotFaqs(groupID, limit, page) ⇒ Promise
- .getRatings() ⇒ Promise
- .updateConversationRemark(id, data) ⇒ Promise
- static
- .getAnonymousToken() ⇒ Promise
new Client(handler, options)
构造函数
| Param | Type | Description | | --- | --- | --- | | handler | Object | 回调函数入口 | | handler.onOpen | OnOpen | WebSocket建立成功回调函数 | | handler.onClose | OnClose | WebSocket关闭回调函数 | | handler.onError | OnError | WebSocket错误回调函数 | | handler.onMessage | OnMessage | 收到消息回调函数 | | handler.onConversationBuilt | OnConversationBuilt | 会话建立回调函数 | | handler.onConversationClosed | OnConversationClosed | 会话关闭回调函数 | | handler.onMessageRecall | OnMessageRecall | 消息被撤回回调函数 | | handler.onManualServiceStart | OnManualServiceStart | 人工会话建立回调函数 | | handler.onStaffBusy | OnStaffBusy | 客服繁忙回调函数 | | handler.onStaffOffline | OnStaffOffline | 客服不在线回调函数 | | handler.onMultipleLogin | OnMultipleLogin | 多端登录回调函数 | | handler.onConversationTransfer | OnConversationTransfer | 会话转接回调函数 | | options | Object | 参数 | | options.token | string | Token | | options.subChannelId | number | 子渠道ID | | options.debug | boolean | 开启调试模式 | | options.retry | boolean | 请求重试 |
client.open()
打开WebSocket连接
Kind: instance method of Client
client.close()
关闭WebSocket连接
Kind: instance method of Client
client.isOpened() ⇒ boolean
WebSocket是否已开启
Kind: instance method of Client
client.isConnecting() ⇒ boolean
WebSocket是否正在连接
Kind: instance method of Client
client.buildMessage(messageType, content, conversationId) ⇒ Message
构造一条Message
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | messageType | MessageType | 消息类型 | | content | string | Object | 内容,文本消息为string,其他消息为Object,包含url,filename等信息 | | conversationId | number | 消息所在会话的ID |
client.sendMessage(message, toId) ⇒ Promise
发送消息
Kind: instance method of Client
Returns: Promise - 当消息发送成功时resolve
| Param | Type | Description | | --- | --- | --- | | message | Message | 消息,通过buildMessage创建 | | toId | number | 目标ID |
client.recallMessage(messageId) ⇒ Promise
撤回消息
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | messageId | number | 消息ID |
client.readMessage(messageId) ⇒ Promise
消息已读
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | messageId | number | 消息ID |
client.closeConversation(conversationId) ⇒ Promise
关闭会话
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID |
client.inviteRate(userId) ⇒ Promise
邀评,仅供客服调用
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | userId | number | 用户ID |
client.selectMenuItem(menuItemId) ⇒ Promise
点选菜单项,仅供客户调用
Kind: instance method of Client
| Param | Type | | --- | --- | | menuItemId | number |
client.inputting(content, conversationId, toId) ⇒ Promise
正在输入
Kind: instance method of Client
| Param | Type | | --- | --- | | content | string | | conversationId | number | | toId | number |
client.getUserInfo() ⇒ Promise
获取个人信息
Kind: instance method of Client
client.updateMyProfile(data) ⇒ Promise
更新个人信息
Kind: instance method of Client
| Param | Type | | --- | --- | | data | Object |
client.getConversations(params) ⇒ Promise
批量获取会话
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | params | Object | 过滤参数 | | params.state | 'ACTIVE' | 'PENDING' | 'FINISHED' | 会话状态 | | params.page | number | 页码 | | params.limit | number | 每页显示条数 | | params.search | string | 搜索关键字 | | params.begin_at | number | 开始时间 | | params.end_at | number | 结束时间 | | params.order | 'DESC' | 'ASC' | 排序 | | params.customer_id | number | 客户ID | | params.show_all | boolean | 显示全部 |
client.getConversationById(conversationId) ⇒ Promise
获取单条会话
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID |
client.updateUserProfile(id, data) ⇒ Promise
更新用户信息
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | id | number | 用户ID | | data | Object | 用户信息 |
client.rateStaff(score, suggestion, ratingTagIds) ⇒ Promise
评价客服
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | score | number | 分数, 1-5 | | suggestion | string | 评语 | | ratingTagIds | Array.<number> | TagId |
client.getVisitInfo(id) ⇒ Promise
根据会话ID获取用户资料访问信息
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | id | number | 会话ID |
client.getPendingCount() ⇒ Promise
获取当前排队人数
Kind: instance method of Client
client.addCustomerTag(id, data) ⇒ Promise
增加访客标签
Kind: instance method of Client
| Param | Type | | --- | --- | | id | number | | data | Object |
client.deleteCustomerTag(id, tagId) ⇒ Promise
删除访客标签
Kind: instance method of Client
| Param | Type | | --- | --- | | id | number | | tagId | number |
client.getQuickReply() ⇒ Promise
获取快速回复
Kind: instance method of Client
client.addQuickReply(data) ⇒ Promise
增加快速回复
Kind: instance method of Client
| Param | Type | | --- | --- | | data | Object |
client.editQuickReply(id, data) ⇒ Promise
修改快速回复
Kind: instance method of Client
| Param | Type | | --- | --- | | id | number | | data | Object |
client.deleteQuickReply(id) ⇒ Promise
删除快速回复
Kind: instance method of Client
| Param | Type | | --- | --- | | id | number |
client.adminCloseConversation(id) ⇒ *
管理员强制关闭会话
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | id | number | 会话ID |
client.exportHistoryConversations(data) ⇒ Promise
导出历史会话
Kind: instance method of Client
| Param | | --- | | data |
client.getTransferServiceList(params) ⇒ Promise
获取客服用户列表(转接使用)
Kind: instance method of Client
| Param | | --- | | params |
client.conversationTransfer(id, data) ⇒ Promise
会话转接
Kind: instance method of Client
| Param | | --- | | id | | data |
client.requestConversations(data) ⇒ Promise
历史会话发起会话
Kind: instance method of Client
| Param | | --- | | data |
client.getConversationsCount(params) ⇒ Promise
获取会话统计
Kind: instance method of Client
| Param | | --- | | params |
client.uploadBlobs(file, onUploadProgress) ⇒ Promise
上传附件
Kind: instance method of Client
| Param | Type | Description | | --- | --- | --- | | file | File | 文件 | | onUploadProgress | function | 回调函数 |
client.likeRobotAnswer(id) ⇒ Promise
机器人满意回答
Kind: instance method of Client
| Param | | --- | | id |
client.dislikeRobotAnswer(msgId) ⇒ Promise
机器人不满意回答
Kind: instance method of Client
| Param | | --- | | msgId |
client.getSuggestions(query, subChannelId) ⇒ Promise
问题自动补全
Kind: instance method of Client
| Param | Default | | --- | --- | | query | | | subChannelId | 0 |
client.getPendingPosition(convId) ⇒ Promise
当前排队位置
Kind: instance method of Client
| Param | | --- | | convId |
client.getCurrentConversationList() ⇒ Promise
获取当前会话列表
Kind: instance method of Client
client.getSubChannel(subChannelId) ⇒ Promise
获取渠道信息
Kind: instance method of Client
| Param | | --- | | subChannelId |
client.getHotFaqs(groupID, limit, page) ⇒ Promise
获取热门问题
Kind: instance method of Client
| Param | | --- | | groupID | | limit | | page |
client.getRatings() ⇒ Promise
获取评分等级
Kind: instance method of Client
client.updateConversationRemark(id, data) ⇒ Promise
更改会话备注
Kind: instance method of Client
| Param | | --- | | id | | data |
Client.getAnonymousToken() ⇒ Promise
获取匿名Token
Kind: static method of Client
OnOpen : function
WebSocket建立成功回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | event | Event | 事件 |
OnClose : function
WebSocket关闭回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | event | CloseEvent | 事件 |
OnError : function
WebSocket错误回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | event | Event | 事件 |
OnMessage : function
收到消息回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | message | Message | 消息 |
Message : Object
消息
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | id | number | 消息ID | | fromId | number | 发送者ID | | nickname | string | 发送者昵称 | | content | string | Object | 内容,文本消息为string,其他消息为Object,包含url,filename等信息 | | createdAt | number | 消息创建时间戳 | | direction | number | 发送方向,0代表发出,1代表收到 | | messageType | MessageType | 消息类型 | | isRead | boolean | 是否已读 | | conversationId | number | 会话ID |
MessageType : 'Text' | 'Image' | 'Video' | 'Attachment'
消息类型,可以是以下字符串中任意一个
Kind: global typedef
OnConversationBuilt : function
会话建立回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID | | userId | number | 用户ID | | nickname | string | 用户名 | | userType | string | 用户类型 |
OnConversationClosed : function
会话关闭回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID | | reason | number | 关闭原因 1: 客户主动关闭, 2: 客服主动关闭, 3: 超时自动关闭, 4: 管理员强制关闭 |
OnMessageRecall : function
消息被撤回回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID | | messageId | number | 消息ID |
OnManualServiceStart : function
人工会话建立回调函数
Kind: global typedef
OnStaffBusy : function
客服繁忙回调函数
Kind: global typedef
OnStaffOffline : function
客服不在线回调函数
Kind: global typedef
OnMultipleLogin : function
多端登录回调函数
Kind: global typedef
OnConversationTransfer : function
会话转接回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID |
OnInputting : function
会话转接回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | content | string | 消息内容 | | conversationId | number | 会话ID |
OnStaffTimeout : function
客服回复超时回调函数
Kind: global typedef
| Param | Type | Description | | --- | --- | --- | | conversationId | number | 会话ID |
