Skip to main content

<a id=“SuperOffice_WebApi_Agents_ChatAgent”></a> Class ChatAgent

Namespace: SuperOffice.WebApi.Agents
Assembly: SuperOffice.WebApi.dll
Chat functions. Manage chat channels, sessions and messages.

Inheritance

objectAgentBaseChatAgent

Implements

IChatAgent, IAgentBase, IDisposable

Inherited Members

AgentBase._json, AgentBase._binary, AgentBase._config, AgentBase._client, AgentBase._disposeClient, AgentBase.Merge(RequestOptions), AgentBase.BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string), AgentBase.BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.ParseAuthorization(IAuthorization), AgentBase.CancelRequest(), AgentBase.SendRequestObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.SendRequest(HttpRequestMessage, RequestOptions), AgentBase.ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage), AgentBase.ParseResponse<T&gt;(HttpResponseMessage), AgentBase.Finally(RequestOptions), AgentBase.Dispose(), AgentBase.Configuration, AgentBase.Client, AgentBase.HasRunningRequest, AgentBase.ClientCancellationTokenSource, AgentBase.ProgressListener, AgentBase.UploadProgressListener, object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Examples

<pre><code class=“lang-csharp”>using SuperOffice.WebApi; using SuperOffice.WebApi.Agents; var mySession = new WebApiOptions(“http://example.com/super/api”); mySession.Authorization = new AuthorizationUsernamePassword(“user”, “pass”); using (ChatAgent agent = new ChatAgent(mySession)) { // call methods on agent here… }</code></pre>

Constructors

<a id=“SuperOffice_WebApi_Agents_ChatAgent__ctor_System_Net_Http_HttpClient_”></a> ChatAgent(HttpClient)

Constructor: Chat functions. Manage chat channels, sessions and messages.

Parameters

httpClient HttpClient Use this HTTP client instead of making own HttpClient instance.

<a id=“SuperOffice_WebApi_Agents_ChatAgent__ctor_SuperOffice_WebApi_WebApiOptions_System_Net_Http_HttpClient_”></a> ChatAgent(WebApiOptions, HttpClient)

Constructor: Chat functions. Manage chat channels, sessions and messages.

Parameters

options WebApiOptions Base URL and authentication values. httpClient HttpClient Optional: Use this HTTP client instead of making a new one.

Methods

<a id=“SuperOffice_WebApi_Agents_ChatAgent_AcceptChatSessionTransferAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> AcceptChatSessionTransferAsync(int, RequestOptions)

Accept the transfer: assign the session to the user. If the session is not being transferred, nothing happens.

Parameters

chatSessionId int id of the chat session to send requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The updated chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_AddChatMessageAsync_System_Int32_SuperOffice_WebApi_Data_ChatMessage_SuperOffice_WebApi_RequestOptions_”></a> AddChatMessageAsync(int, ChatMessage, RequestOptions)

Add a new message to a chat session

Parameters

chatSessionId int id of the chat session to add message to message ChatMessage Message to add requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatMessage&gt; The chat message added to the session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_AddChatTopicUserAgentAsync_System_Int32_SuperOffice_WebApi_Data_ChatTopicAgent_SuperOffice_WebApi_RequestOptions_”></a> AddChatTopicUserAgentAsync(int, ChatTopicAgent, RequestOptions)

Add a user to a chat topic

Parameters

chatTopicId int Id of the chat topic useragent ChatTopicAgent User’s role within the chat topic to add to topic. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent&gt; The user’s role within the chat topic.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_ChatSessionsForUserAsync_SuperOffice_WebApi_RequestOptions_”></a> ChatSessionsForUserAsync(RequestOptions)

Get all chat sessions which this user is a member of. Members means that you have at least one of: Can Respond, Notifications, Listen or Manager

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity[]&gt; Array of chat sessions the current user can access

<a id=“SuperOffice_WebApi_Agents_ChatAgent_ChatTopicsForUserAsync_SuperOffice_WebApi_RequestOptions_”></a> ChatTopicsForUserAsync(RequestOptions)

Get all chat topics which this user is a member of. Members means that you have at least one of: Can Respond, Notifications, Listen or Manager

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicEntity[]&gt; Array of chat topics the current user can access

<a id=“SuperOffice_WebApi_Agents_ChatAgent_CreateChatSessionForTopicAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> CreateChatSessionForTopicAsync(int, RequestOptions)

Create a new session on a chat topic

Parameters

chatTopicId int Id of the chat topic requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The new chat session.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_CreateDefaultChatSessionEntityAsync_SuperOffice_WebApi_RequestOptions_”></a> CreateDefaultChatSessionEntityAsync(RequestOptions)

Set default values into a new ChatSessionEntity. NetServer calculates default values on the entity, which is required when creating/storing a new instance

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; A blank ChatSessionEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_CreateDefaultChatTopicAgentAsync_SuperOffice_WebApi_RequestOptions_”></a> CreateDefaultChatTopicAgentAsync(RequestOptions)

Set default values into a new ChatTopicAgent. NetServer calculates default values on the entity, which is required when creating/storing a new instance

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent&gt; A blank ChatTopicAgent

<a id=“SuperOffice_WebApi_Agents_ChatAgent_CreateDefaultChatTopicEntityAsync_SuperOffice_WebApi_RequestOptions_”></a> CreateDefaultChatTopicEntityAsync(RequestOptions)

Set default values into a new ChatTopicEntity. NetServer calculates default values on the entity, which is required when creating/storing a new instance

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicEntity&gt; A blank ChatTopicEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_DeleteChatSessionEntityAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> DeleteChatSessionEntityAsync(int, RequestOptions)

Deletes the ChatSessionEntity

Parameters

chatSessionEntityId int The identity of the ChatSessionEntity requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task

<a id=“SuperOffice_WebApi_Agents_ChatAgent_DeleteChatTopicEntityAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> DeleteChatTopicEntityAsync(int, RequestOptions)

Deletes the ChatTopicEntity

Parameters

chatTopicEntityId int The identity of the ChatTopicEntity requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task

<a id=“SuperOffice_WebApi_Agents_ChatAgent_DeleteChatTopicUserAgentAsync_System_Int32_System_String_SuperOffice_WebApi_RequestOptions_”></a> DeleteChatTopicUserAgentAsync(int, string, RequestOptions)

Remove a user from a topic

Parameters

chatTopicId int Id of the chat topic username string Associate username or associate id to delete. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task This method has no return value

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatMessagesAsync_System_Int32_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetChatMessagesAsync(int, int, RequestOptions)

Get all or some of the messages in a chat session

Parameters

chatSessionId int id of the chat session to reset after int Return messages after this message id requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatMessage[]&gt; Array of chat messages in the session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatPresenceAsync_SuperOffice_WebApi_RequestOptions_”></a> GetChatPresenceAsync(RequestOptions)

Get the chat presence status for all chat users

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatPresence[]&gt; An array with ChatPresence objects for each user

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatSessionEntityAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetChatSessionEntityAsync(int, RequestOptions)

Gets a specific ChatSessionEntity object.

Parameters

chatSessionEntityId int The identifier of the ChatSessionEntity object requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; ChatSessionEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatTopicEntityAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetChatTopicEntityAsync(int, RequestOptions)

Gets a specific ChatTopicEntity object.

Parameters

chatTopicEntityId int The identifier of the ChatTopicEntity object requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicEntity&gt; ChatTopicEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatTopicUserAgentAsync_System_Int32_System_String_SuperOffice_WebApi_RequestOptions_”></a> GetChatTopicUserAgentAsync(int, string, RequestOptions)

Get a user assigned to a topic

Parameters

chatTopicId int Id of the chat topic username string Associate username or associate id to get. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent&gt; The user’s role within the chat topic.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatTopicUserAgentListAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetChatTopicUserAgentListAsync(int, RequestOptions)

Get list of users assigned to a chat topic

Parameters

chatTopicId int Id of the chat topic requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent[]&gt; List of user agents assigned to chat topic.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetChatTranscriptAsync_System_Int32_System_Boolean_SuperOffice_WebApi_RequestOptions_”></a> GetChatTranscriptAsync(int, bool, RequestOptions)

Get the chat transcript, formatted as plain text or html

Parameters

chatSessionId int id of the chat session to get the transcript for html bool Get transcript as HTML requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<string&gt; The transcript in text or HTML

<a id=“SuperOffice_WebApi_Agents_ChatAgent_GetUserAgentListAsync_System_Boolean_System_Boolean_SuperOffice_WebApi_RequestOptions_”></a> GetUserAgentListAsync(bool, bool, RequestOptions)

Get list of users that can be assigned to chat topics. Users with Chat-CALs from the MDO list ‘chatuser’

Parameters

flat bool Return flat list instead of grouping by usergroup. onlyPresent bool Only show users who are present requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<MDOListItem[]&gt; List of user agents that can be assigned to chat topics, possibly grouped by usergroup.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_IsWithinOpeningHoursAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> IsWithinOpeningHoursAsync(int, RequestOptions)

Check if we are right now within the opening hours of the given topic. Will use timezones to calculate if configured.

Parameters

chatTopicId int The id of the topic to check requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<bool&gt; True if we are within opening hours, or if the topic does not use opening hours

<a id=“SuperOffice_WebApi_Agents_ChatAgent_PickUpChatSessionAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> PickUpChatSessionAsync(int, RequestOptions)

‘answer’ the session: assign the session to the user. The welcome message is sent to the customer. Returns NULL if session was not in queue.

Parameters

chatSessionId int id of the chat session to answer requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_PickUpFirstChatSessionAsync_SuperOffice_WebApi_RequestOptions_”></a> PickUpFirstChatSessionAsync(RequestOptions)

‘answer’ the first available session from the queue: assign the session to the user. The welcome message is sent to the customer.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The picked-up chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_RejectChatSessionTransferAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> RejectChatSessionTransferAsync(int, RequestOptions)

Do not want. Deny the transfer to the user. If the session is not being transferred, nothing happens.

Parameters

chatSessionId int id of the chat session to send back requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The updated chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_ResetChatSessionAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> ResetChatSessionAsync(int, RequestOptions)

Reset chat session, put it back on the queue for pickup. Used by bots to hand off a session to human

Parameters

chatSessionId int id of the chat session to reset requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The updated chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_SaveChatPresenceAsync_SuperOffice_WebApi_Data_ChatPresence___SuperOffice_WebApi_RequestOptions_”></a> SaveChatPresenceAsync(ChatPresence[], RequestOptions)

Save the chat presence for specified users

Parameters

chatPresence ChatPresence[] An array with ChatPresence objects. Only the UserId and Present information is used while saving requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task void

<a id=“SuperOffice_WebApi_Agents_ChatAgent_SaveChatSessionEntityAsync_SuperOffice_WebApi_Data_ChatSessionEntity_SuperOffice_WebApi_RequestOptions_”></a> SaveChatSessionEntityAsync(ChatSessionEntity, RequestOptions)

Updates the existing ChatSessionEntity or creates a new ChatSessionEntity if the id parameter is 0.

Parameters

chatSessionEntity ChatSessionEntity The ChatSessionEntity that is saved. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; New or updated ChatSessionEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_SaveChatTopicEntityAsync_SuperOffice_WebApi_Data_ChatTopicEntity_SuperOffice_WebApi_RequestOptions_”></a> SaveChatTopicEntityAsync(ChatTopicEntity, RequestOptions)

Updates the existing ChatTopicEntity or creates a new ChatTopicEntity if the id parameter is 0.

Parameters

chatTopicEntity ChatTopicEntity The ChatTopicEntity that is saved. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicEntity&gt; New or updated ChatTopicEntity

<a id=“SuperOffice_WebApi_Agents_ChatAgent_TransferChatSessionAsync_System_Int32_System_String_SuperOffice_WebApi_RequestOptions_”></a> TransferChatSessionAsync(int, string, RequestOptions)

Request to send the session to another user. If the session does not belong to the user, nothing happens.

Parameters

chatSessionId int id of the chat session to send toAssociate string Associate username or associate id to send session to. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatSessionEntity&gt; The updated chat session

<a id=“SuperOffice_WebApi_Agents_ChatAgent_UpdateChatTopicUserAgentAsync_System_Int32_System_String_SuperOffice_WebApi_Data_ChatTopicAgent_SuperOffice_WebApi_RequestOptions_”></a> UpdateChatTopicUserAgentAsync(int, string, ChatTopicAgent, RequestOptions)

Update a user’s role in a chat topic

Parameters

chatTopicId int Id of the chat topic username string Associate username or associate id to get. useragent ChatTopicAgent User’s updated role within the chat topic. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent&gt; The user’s role within the chat topic.

<a id=“SuperOffice_WebApi_Agents_ChatAgent_UpdateChatTopicUserAgentsAsync_System_Int32_SuperOffice_WebApi_Data_ChatTopicAgent___SuperOffice_WebApi_RequestOptions_”></a> UpdateChatTopicUserAgentsAsync(int, ChatTopicAgent[], RequestOptions)

Update users roles in a chat topic

Parameters

chatTopicId int Id of the chat topic useragents ChatTopicAgent[] Users new/updated roles within the chat topic. Replaces existing roles requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<ChatTopicAgent[]&gt; The updated agents within the chat topic.