客服 iOS AgentSDK API


目录

会话管理类

当前会话列表

//page 页码;limit:每页会话数(一般要包括所有会话)
  [[HDClient sharedClient].chatManager asyncLoadConversationsWithPage:<#(NSInteger)#> limit:<#(NSInteger)#> completion:^(NSArray *conversations, HDError *error) 
 { 
   //conversations 会话【HDConversation *】
  }];

常用语

//加载常用语
[[HDClient sharedClient].chatManager getQuickReplyCompletion:^(id responseObject, HDError *error) {
        if (error == nil) {
            
        }
    }]; 

//增加常用语,parentId 父节点id,text 常用语内容,leaf 是否是叶子节点(0、1标识)
[[HDClient sharedClient].chatManager addQuickReplyWithParentId:<#(NSString *)#> text:<#(NSString *)#> leaf:<#(NSInteger )#> completion:^(id responseObject, HDError *error) {
}];
 //更新常用语,qrid,常用语id
 [[HDClient sharedClient].chatManager updateQuickReplyWithParentId:<#(NSString *)#> text:<#(NSString *)#> leaf:_<#(NSInteger )#> qrId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {               
 }];
 //删除常用语           
 [[HDClient sharedClient].chatManager deleteQuickReplyWithId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
 }];
 

消息管理类

//下边用到的_conversation即是HDConversationManager
   HDConversationManager *_conversation =  [[HDConversationManager alloc] initWithSessionId:<#(NSString *)#> chatGroupId:<#(NSInteger)#>];

获取聊天消息

[_conversation loadMessageCompletion:^(NSArray<HDMessage *> *messages, HDError *error) {
        //获取消息回调
    }];

设置消息已读

[_conversation markMessagesAsReadWithVisitorId:<#(NSString *)#> parameters:nil completion:^(id responseObject, HDError *error) {
        if (error == nil) {
            //标记已读成功
        }
    }];

获取聊天历史消息

[_conversation loadHistoryCompletion:^(NSArray<HDMessage *> *messages, HDError *error) {
       
    }];

发送文本消息

//构造消息体
HDTextMessageBody *body = [[HDTextMessageBody alloc] initWithText:<#(NSString *)#>];
HDMessage *message = [[HDMessage alloc] initWithSessionId:<#(NSString)#> to:<#(NSString *)#> messageBody:body];
//发送消息
[_conversation sendMessage:message progress:nil completion:^(HDMessage *aMessage, HDError *aError) {
        //发送结束,回调
    }];

</code>

发送图片消息

//构造消息体
HDImageMessageBody *body = [[HDImageMessageBody alloc] initWithData:<#(NSData *)#> displayName:<#(NSString *)#>];
HDMessage *message = [[HDMessage alloc] initWithSessionId:<#(NSString *)#> to:<#(NSString *)#> messageBody:body];
    [_conversation sendMessage:msg progress:nil completion:^(HDMessage *aMessage, HDError *aError) {
         //发送结束,回调
    }];

发送语音消息

//构造消息体
HDVoiceMessageBody *body = [[HDVoiceMessageBody alloc] initWithLocalPath:<#(NSString *)#> displayName:<#(NSString *)#>];
HDMessage *message = [[HDMessage alloc] initWithSessionId:<#(NSString *)#> to:<#(NSString *)#> messageBody:body];
 //发送消息
[_conversation sendMessage:msg progress:nil completion:^(HDMessage *aMessage, HDError *aError) {
    //发送结束,回调
}];

==== 结束会话 ==== 
<code>
[_conversation endConversationWithVisitorId:<#(NSString *)#> parameters:nil completion:^(id responseObject, HDError *error) {
        if (!error) {
           //成功关闭
        } else {
           //关闭失败
        }
    }];

获取当前用户

[HDClient sharedClient].currentAgentUser

获取会话标签树

[_conversation asyncGetTreeCompletion:^(id responseObject, HDError *error) {
        if (!error) {
           
        } else {
           
        }
    }];

获取会话标签

[_conversation asyncGetSessionSummaryResultsCompletion:^(id responseObject, HDError *error) {
        if (!error) {
           
        } else {
           
        }
    }];

获取会话标签备注

[_conversation asyncGetSessionCommentCompletion:^(id responseObject, HDError *error) {
        if (!error) {
        }
    }];

修改会话标签备注

[_conversation asyncSaveSessionCommentParameters:<#(NSDictionary *)#> completion:^(id responseObject, HDError *error) {
            if (error) {
                
            }
        }];

修改会话标签

[_conversation asyncSaveSessionSummaryResultsParameters:<#(NSDictionary *)#> completion:^(id responseObject, HDError *error) {
        if (!error) {
        }
    }];

获取技能组

[_conversation getSkillGroupCompletion:^(id responseObject, HDError *error) {
}]

客服同事列表

[[HDClient sharedClient].chatManager asyncGetAllCustomersCompletion:^(NSArray<HDConversation *> *customers, HDError *error) {
}];

给同事发消息

[[HDClient sharedClient].chatManager customerSendMessage:<#(HDMessage *)#> completion:^(id responseObject, HDError *error) {
}];

获取同事未读消息

/**
 @param remoteUserId 客服userId
 @param parameters 参数
 @param completion 完成回调
 */
[[HDClient sharedClient].chatManager asyncGetAgentUnreadMessagesWithRemoteAgentUserId:<#(NSString *)#> parameters:<#(NSDictionary *)#> completion:^(NSArray <HDMessage *> *messages, HDError *error) {
}];

查询同事聊天记录

/**
 查询客服同事聊天记录【包括已读、未读】

 @param remoteUserId 对方userId
 @param parameters 参数
 @param completion 完成回调
 */
[[HDClient sharedClient].chatManager aysncGetAgentMessagesWithRemoteUserId:<#(NSString *)#> parameters:<#(NSDictionary *)#> 
 completion:^(NSArray<HDMessage *> *messages, HDError *error) {
}];

标记同事消息为已读

/**
 @param userId 对方userId
 @param createDateTime 最后一条消息的时间戳
 @param completion 完成回调
 */
 [[HDClient sharedClient].chatManager asyncMarkMessagesAsReadWithRemoteAgentUserId:<#(NSString *)#> lastCreateDateTime:<#(NSTimeInterval)#> completion:^(id responseObject, HDError *error) {
}];

获取历史会话

/**=
 @param page 页码
 @param limit 每页的数量
 @param parameters 参数
 @param completion 完成回调
 */
[[HDClient sharedClient].chatManager asyncFetchHistoryConversationWithPage:<#(NSInteger)#> limit:<#(NSInteger)#> parameters:<#(NSDictionary *)#> completion:^(NSArray *conversations, HDError *error, NSInteger totalNum) {
}];

回呼

/**
 @param vistorId 回呼用户的userId
 @param completion 完成回调
 */
[[HDClient sharedClient].chatManager asyncFetchCreateSessionWithVistorId:<#(NSString *)#> completion:^(HDHistoryConversation *history, HDError *error) {
}];

获取历史会话聊天记录

/**
 @param sessionServicesId 会话id
 @param page 页码
 @param completion 完成回调
 */
[[HDClient sharedClient].chatManager asyncFetchHistoryMessagesWithSessionServicesId:<#(NSString *)#> page:<#(NSInteger)#> completion:^(id responseObject, HDError *error) {
}];

获取关联列表

[[HDClient sharedClient].chatManager getChannelsCompletion:^(id responseObject, HDError *error) {
}];

待接入管理类

获取待接入队列

/**
 @param pageIndex 第几页
 @param pageSize 每页数据个数
 @param parameters 预留参数,暂传nil
 @param completion 请求完成的回调【error == nil,为请求成功】
 */
[[HDClient sharedClient].waitManager asyncGetWaitQueuesWithPage:<#(NSInteger)#> pageSize:<#(NSInteger)#> parameters:<#(NSDictionary *)#> completion:^(NSArray<HDWaitUser *> *waitUsers, HDError *error) {
}];

接入会话

/**
 @param userId 对方userId
 @param completion 完成回调
 */
[[HDClient sharedClient].waitManager asyncFetchUserWaitQueuesWithUserId:<#(NSInteger)#> completion:^(id responseObject, HDError *error) {
}];

筛选会话

//参数为固定key的字典
[HDClient sharedClient].waitManager asyncScreenWaitQueuesWithParameters:<#(NSDictionary *)#> completion:^(NSArray<HDWaitUser *> *users, HDError *error) {}];

设置管理类

/**
 修改最大接入数

 @param userNum 人数NSString 类型
 @param completion 完成回调
 */
 [[HDClient sharedClient].setManager updateServiceUsersWithNum:<#(NSString*) #> completion:^(id responseObject, HDError *error) {
 }];

更新在线状态

//HDOnlineStatus 是状态的枚举
[[HDClient sharedClient].setManager updateOnLineStatusWithStatus:<#(HDOnlineStatus)#> completion:^(id responseObject, HDError *error) {
        
    }];

开关问候语

//YES 为开启,NO 为关闭
[[HDClient sharedClient].setManager enableGreeting:<#(BOOL)#> completion:^(id responseObject, HDError *error) {
 }];
 

获取客服问候语

[HDClient sharedClient].currentAgentUser.greetingContent

更新客服问候语

//问候语内容
 [[HDClient sharedClient].setManager updateGreetingContent:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
 }];

修改坐席信息

//参数为key - value 
[[HDClient sharedClient].setManager modifyInfoWithKey:<#(NSString *)#> value:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
}];
 

上传坐席头像

//UIImage 类型
[[HDClient sharedClient].setManager asyncUploadImageWithFile:<#(NSData*)#> completion:^(NSString *url, HDError *error) {
}];

获取访客标签

//参数:访客userId
[[HDClient sharedClient].setManager getVisitorUserTagsWithUserId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
        
    }];

修改访客标签

//tag实例
[[HDClient sharedClient].setManager updateVisitorUserTagWithUserTag:<#(HDUserTag *)#> completion:^(id responseObject, HDError *error) {
}];

通知管理类

获取通知消息

/**
 @param pageIndex 第几页
 @param pageSize 每页数据个数
 @param status 已读还是未读
 @param type 消息类型
 @param parameters 预留参数暂传nil
 @param completion 完成请求的回调
 */
[[HDClient sharedClient].notiManager asyncGetNoticeWithPageIndex:<#(NSInteger)#> pageSize:<#(NSInteger)#> status:<#(HDNoticeStatus)#> type:<#(HDNoticeType)#> prameters:<#(NSDictionary *)#> completion:^(NSArray<HDNotifyModel *> *notices, HDError *error) {
}];

未读通知消息标记为已读

/**
 @param ids 通知的id数组
 @param parameters 预留参数暂传nil
 @param completion 完成请求的回调
 */
[[HDClient sharedClient].notiManager asyncPUTMarkNoticeASReadWithUnreadNoticeIds:<#(NSArray <NSString *> *)#> parameters:<#(NSDictionary *)#> completion:^(id responseObjcet, HDError *error) {
        
    }];

创建会话

/**
 @param visitorId visitorId
 @param completion 完成回调
 */
[[HDClient sharedClient].notiManager asyncMessageCenterCreateSessionWithVisitorId:<#(NSString *)#> Completion:^(id responseObject, HDError *error) {
        
    }];

获取访客资料

/**
 @param visitorId
 @param completion 完成回调
 */
[[HDClient sharedClient].notiManager asyncFetchVisitorItemsWithVisitorId:<#(NSString *)#> completion:^(HDVisitorInfo *visitorInfo, HDError *error) {
}];

更新访客资料

/**
 @param customerId 访客id,获取访客资料的时候拿到
 @param parameters 参数
 @param completion 完成回调
 */
[[HDClient sharedClient].notiManager updateVisitorItemWithCustomerId:<#(NSString *)#> visitorId:<#(NSString *)#> parameters:<#(NSDictionary *)#>  completion:^(id responseObject, HDError *error) {
}];

留言管理类

获取留言

/**
 获取不同状态的留言列表【例如:未处理,处理中,已处理也可自定义】

 @param statusId 状态对应的Id【传nil为全部留言】
 @param pageIndex 第几页
 @param pageSize 每页数据个数
 @param parameters 预留参数,暂传nil
 @param completion 完成回调
 */
[[HDClient sharedClient].leaveMsgManager asyncGetLeaveMessagesWithStatusId:<#(NSString *)#> pageIndex:<#(NSInteger)#> pageSize:<#(NSInteger)#> parameters:<#(NSDictionary *)#> completion:^(NSArray<HDLeaveMessage *> *leaveMessages, HDError *error) {
}];

获取受让人列表

[[HDClient sharedClient].leaveMsgManager asyncGetAssigneesCompletion:^(NSArray<HDAssignee *> *assignees, HDError *error) {

    }];

获取留言状态

//获取留言状态【eg:未处理,处理中,已处理也可自定义】
[[HDClient sharedClient].leaveMsgManager asyncGetLeaveMsgStatusWithParameters:<#(NSDictionary *)#> completion:^(NSArray<HDStatus *> *statuses, HDError *error) {
}];

获取留言详情

/**
 @param leaveMsgId 留言id
 @param completion 完成回调
 */[[HDClient sharedClient].leaveMsgManager asyncGetLeaveMsgDetailWithLeaveMsgId:<#(NSNumber *)#> completion:^(id responseObject, HDError *error) {
}];

获取留言评论

/**
 @param leaveMsgId 留言id
 @param completion 完成回调
 */
[[HDClient sharedClient].leaveMsgManager asyncGetLeaveMsgCommentWithLeaveMsgId:<#(NSString *)#> completion:^(NSArray<HDLeaveMessage *> *comments, HDError *error) {
}];

留言发布评论

/**
 @param leaveMsgId 留言id
 @param text 文字内容
 @param attachments 附件
 */
[[HDClient sharedClient].leaveMsgManager asyncPostLeaveMsgCommentWithLeaveMsgId:<#(NSString *)#> text:<#(NSString *)#> attachments:<#(NSArray <HDAttachment *>*)#> completion:^(id responseObject, HDError *error) {
    }];

分配留言

/**
 @param user 受让人
 @param leaveMsgId leaveMsgId
 @param completion 完成回调
 */
[[HDClient sharedClient].leaveMsgManager asyncAssignLeaveMsgWithUser:<#(UserModel *)#> leaveMsgId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
}];

取消分配留言

/**
 @param user 当前分配人id
 @param leaveMsgId ID
 @param completion 完成回调
 */
[[HDClient sharedClient].leaveMsgManager asyncUnAssignLeaveMsgWithUserId:<#(NSString *)#> leaveMsgId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
}];

设置留言状态

/**
 @param leaveMsgId ID
 @param statusId 状态id
 @param completion 完成回调
 */
[[HDClient sharedClient].leaveMsgManager asyncSetLeaveMsgStatusWithLeaveMsgId:<#(NSString *)#> statusId:<#(NSString *)#> completion:^(id responseObject, HDError *error) {
}];

上传附件

/**
 @param imageData 图片数据
 @param completion 完成回调(附件实例)
 */
 [[HDClient sharedClient].leaveMsgManager asyncUploadImageWithFile:data completion:^(HDAttachment *attachment, HDError *error) {
}];