Interface IChatAgent
Interface for the Chat Agent Chat functions. Manage chat channels, sessions and messages.
Namespace: SuperOffice.CRM.Services
Assembly: SuperOffice.Services.dll
Syntax
[Agent("Chat Agent", "Interface for the Chat Agent. Chat functions. Manage chat channels, sessions and messages.")]
public interface IChatAgent : IAgent
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
Methods
AcceptChatSessionTransferAsync(int, CancellationToken)
Accept the transfer: assign the session to the user. If the session is not being transferred, nothing happens.
Declaration
Task<ChatSessionEntity> AcceptChatSessionTransferAsync(int chatSessionId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to send |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The updated chat session |
AddChatMessageAsync(int, ChatMessage, CancellationToken)
Add a new message to a chat session
Declaration
Task<ChatMessage> AddChatMessageAsync(int chatSessionId, ChatMessage message, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to add message to |
| ChatMessage | message | Message to add |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatMessage> | The chat message added to the session |
AddChatTopicUserAgentAsync(int, ChatTopicAgent, CancellationToken)
Add a user to a chat topic
Declaration
Task<ChatTopicAgent> AddChatTopicUserAgentAsync(int chatTopicId, ChatTopicAgent useragent, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| ChatTopicAgent | useragent | User's role within the chat topic to add to topic. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent> | The user's role within the chat topic. |
ChatSessionsForUserAsync(CancellationToken)
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
Declaration
Task<ChatSessionEntity[]> ChatSessionsForUserAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity[]> | Array of chat sessions the current user can access |
ChatTopicsForUserAsync(CancellationToken)
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
Declaration
Task<ChatTopicEntity[]> ChatTopicsForUserAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicEntity[]> | Array of chat topics the current user can access |
CreateChatSessionForTopicAsync(int, CancellationToken)
Create a new session on a chat topic
Declaration
Task<ChatSessionEntity> CreateChatSessionForTopicAsync(int chatTopicId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The new chat session. |
CreateDefaultChatSessionEntityAsync(CancellationToken)
Loading default values into a new ChatSessionEntity.
Declaration
Task<ChatSessionEntity> CreateDefaultChatSessionEntityAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | New ChatSessionEntity with default values |
CreateDefaultChatTopicAgentAsync(CancellationToken)
Loading default values into a new ChatTopicAgent.
Declaration
Task<ChatTopicAgent> CreateDefaultChatTopicAgentAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent> | New ChatTopicAgent with default values |
CreateDefaultChatTopicEntityAsync(CancellationToken)
Loading default values into a new ChatTopicEntity.
Declaration
Task<ChatTopicEntity> CreateDefaultChatTopicEntityAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicEntity> | New ChatTopicEntity with default values |
DeleteChatSessionEntityAsync(int, CancellationToken)
Deletes the ChatSessionEntity
Declaration
Task DeleteChatSessionEntityAsync(int chatSessionEntityId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionEntityId | The identity of the ChatSessionEntity |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | This method has no return value |
DeleteChatTopicEntityAsync(int, CancellationToken)
Deletes the ChatTopicEntity
Declaration
Task DeleteChatTopicEntityAsync(int chatTopicEntityId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicEntityId | The identity of the ChatTopicEntity |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | This method has no return value |
DeleteChatTopicUserAgentAsync(int, string, CancellationToken)
Remove a user from a topic
Declaration
Task DeleteChatTopicUserAgentAsync(int chatTopicId, string username, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| string | username | Associate username or associate id to delete. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | This method has no return value |
GetChatMessagesAsync(int, int, CancellationToken)
Get all or some of the messages in a chat session
Declaration
Task<ChatMessage[]> GetChatMessagesAsync(int chatSessionId, int after, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to reset |
| int | after | Return messages after this message id |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatMessage[]> | Array of chat messages in the session |
GetChatPresenceAsync(CancellationToken)
Get the chat presence status for all chat users
Declaration
Task<ChatPresence[]> GetChatPresenceAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatPresence[]> | An array with ChatPresence objects for each user |
GetChatSessionEntityAsync(int, CancellationToken)
Gets a ChatSessionEntity object.
Declaration
Task<ChatSessionEntity> GetChatSessionEntityAsync(int chatSessionEntityId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionEntityId | The identifier of the ChatSessionEntity object |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | A single ChatSessionEntity |
GetChatTopicEntityAsync(int, CancellationToken)
Gets a ChatTopicEntity object.
Declaration
Task<ChatTopicEntity> GetChatTopicEntityAsync(int chatTopicEntityId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicEntityId | The identifier of the ChatTopicEntity object |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicEntity> | A single ChatTopicEntity |
GetChatTopicUserAgentAsync(int, string, CancellationToken)
Get a user assigned to a topic
Declaration
Task<ChatTopicAgent> GetChatTopicUserAgentAsync(int chatTopicId, string username, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| string | username | Associate username or associate id to get. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent> | The user's role within the chat topic. |
GetChatTopicUserAgentListAsync(int, CancellationToken)
Get list of users assigned to a chat topic
Declaration
Task<ChatTopicAgent[]> GetChatTopicUserAgentListAsync(int chatTopicId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent[]> | List of user agents assigned to chat topic. |
GetChatTranscriptAsync(int, bool, CancellationToken)
Get the chat transcript, formatted as plain text or html
Declaration
Task<string> GetChatTranscriptAsync(int chatSessionId, bool html, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to get the transcript for |
| bool | html | Get transcript as HTML |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<string> | The transcript in text or HTML |
GetUserAgentListAsync(bool, bool, CancellationToken)
Get list of users that can be assigned to chat topics. Users with Chat-CALs from the MDO list 'chatuser'
Declaration
Task<MDOListItem[]> GetUserAgentListAsync(bool flat, bool onlyPresent, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | flat | Return flat list instead of grouping by usergroup. |
| bool | onlyPresent | Only show users who are present |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<MDOListItem[]> | List of user agents that can be assigned to chat topics, possibly grouped by usergroup. |
IsWithinOpeningHoursAsync(int, CancellationToken)
Check if we are right now within the opening hours of the given topic. Will use timezones to calculate if configured.
Declaration
Task<bool> IsWithinOpeningHoursAsync(int chatTopicId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | The id of the topic to check |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> | True if we are within opening hours, or if the topic does not use opening hours |
PickUpChatSessionAsync(int, CancellationToken)
'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.
Declaration
Task<ChatSessionEntity> PickUpChatSessionAsync(int chatSessionId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to answer |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The chat session |
PickUpFirstChatSessionAsync(CancellationToken)
'answer' the first available session from the queue: assign the session to the user. The welcome message is sent to the customer.
Declaration
Task<ChatSessionEntity> PickUpFirstChatSessionAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The picked-up chat session |
RejectChatSessionTransferAsync(int, CancellationToken)
Do not want. Deny the transfer to the user. If the session is not being transferred, nothing happens.
Declaration
Task<ChatSessionEntity> RejectChatSessionTransferAsync(int chatSessionId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to send back |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The updated chat session |
ResetChatSessionAsync(int, CancellationToken)
Reset chat session, put it back on the queue for pickup. Used by bots to hand off a session to human
Declaration
Task<ChatSessionEntity> ResetChatSessionAsync(int chatSessionId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to reset |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The updated chat session |
SaveChatPresenceAsync(ChatPresence[], CancellationToken)
Save the chat presence for specified users
Declaration
Task SaveChatPresenceAsync(ChatPresence[] chatPresence, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ChatPresence[] | chatPresence | An array with ChatPresence objects. Only the UserId and Present information is used while saving |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task | void |
SaveChatSessionEntityAsync(ChatSessionEntity, CancellationToken)
Updates the existing ChatSessionEntity or creates a new ChatSessionEntity if the id parameter is 0.
Declaration
Task<ChatSessionEntity> SaveChatSessionEntityAsync(ChatSessionEntity chatSessionEntity, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ChatSessionEntity | chatSessionEntity | The ChatSessionEntity that is saved |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | New or updated ChatSessionEntity |
SaveChatTopicEntityAsync(ChatTopicEntity, CancellationToken)
Updates the existing ChatTopicEntity or creates a new ChatTopicEntity if the id parameter is 0.
Declaration
Task<ChatTopicEntity> SaveChatTopicEntityAsync(ChatTopicEntity chatTopicEntity, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ChatTopicEntity | chatTopicEntity | The ChatTopicEntity that is saved |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicEntity> | New or updated ChatTopicEntity |
TransferChatSessionAsync(int, string, CancellationToken)
Request to send the session to another user. If the session does not belong to the user, nothing happens.
Declaration
Task<ChatSessionEntity> TransferChatSessionAsync(int chatSessionId, string toAssociate, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatSessionId | id of the chat session to send |
| string | toAssociate | Associate username or associate id to send session to. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatSessionEntity> | The updated chat session |
UpdateChatTopicUserAgentAsync(int, string, ChatTopicAgent, CancellationToken)
Update a user's role in a chat topic
Declaration
Task<ChatTopicAgent> UpdateChatTopicUserAgentAsync(int chatTopicId, string username, ChatTopicAgent useragent, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| string | username | Associate username or associate id to get. |
| ChatTopicAgent | useragent | User's updated role within the chat topic. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent> | The user's role within the chat topic. |
UpdateChatTopicUserAgentsAsync(int, ChatTopicAgent[], CancellationToken)
Update users roles in a chat topic
Declaration
Task<ChatTopicAgent[]> UpdateChatTopicUserAgentsAsync(int chatTopicId, ChatTopicAgent[] useragents, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | chatTopicId | Id of the chat topic |
| ChatTopicAgent[] | useragents | Users new/updated roles within the chat topic. Replaces existing roles |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<ChatTopicAgent[]> | The updated agents within the chat topic. |