Class ChatAgent
Facade for the Chat Agent Chat functions. Manage chat channels, sessions and messages.
Namespace: SuperOffice.CRM.Services
Assembly: SuperOffice.Services.dll
Syntax
public class ChatAgent : AgentBase<IChatAgent>, IDisposable, 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...
}
}
Constructors
ChatAgent()
Facade for the Chat Agent Chat functions. Manage chat channels, sessions and messages.
Declaration
public ChatAgent()
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
AcceptChatSessionTransfer(Int32)
Accept the transfer: assign the session to the user. If the session is not being transferred, nothing happens.
Declaration
public ChatSessionEntity AcceptChatSessionTransfer(int chatSessionId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to send |
Returns
Type | Description |
---|---|
ChatSessionEntity | The updated chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
AddChatMessage(Int32, ChatMessage)
Add a new message to a chat session
Declaration
public ChatMessage AddChatMessage(int chatSessionId, ChatMessage message)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to add message to |
ChatMessage | message | Message to add |
Returns
Type | Description |
---|---|
ChatMessage | The chat message added to the session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
AddChatTopicUserAgent(Int32, ChatTopicAgent)
Add a user to a chat topic
Declaration
public ChatTopicAgent AddChatTopicUserAgent(int chatTopicId, ChatTopicAgent useragent)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
ChatTopicAgent | useragent | User's role within the chat topic to add to topic. |
Returns
Type | Description |
---|---|
ChatTopicAgent | The user's role within the chat topic. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
ChatSessionsForUser()
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
public ChatSessionEntity[] ChatSessionsForUser()
Returns
Type | Description |
---|---|
ChatSessionEntity[] | Array of chat sessions the current user can access |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
ChatTopicsForUser()
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
public ChatTopicEntity[] ChatTopicsForUser()
Returns
Type | Description |
---|---|
ChatTopicEntity[] | Array of chat topics the current user can access |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
CreateChatSessionForTopic(Int32)
Create a new session on a chat topic
Declaration
public ChatSessionEntity CreateChatSessionForTopic(int chatTopicId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
Returns
Type | Description |
---|---|
ChatSessionEntity | The new chat session. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
CreateDefaultChatSessionEntity()
Loading default values into a new ChatSessionEntity. NetServer calculates default values (e.g. Country) on the entity, which is required when creating/storing a new instance
Declaration
public ChatSessionEntity CreateDefaultChatSessionEntity()
Returns
Type | Description |
---|---|
ChatSessionEntity | New ChatSessionEntity with default values |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
CreateDefaultChatTopicAgent()
Loading default values into a new ChatTopicAgent. NetServer calculates default values (e.g. Country) on the entity, which is required when creating/storing a new instance
Declaration
public ChatTopicAgent CreateDefaultChatTopicAgent()
Returns
Type | Description |
---|---|
ChatTopicAgent | New ChatTopicAgent with default values |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
CreateDefaultChatTopicEntity()
Loading default values into a new ChatTopicEntity. NetServer calculates default values (e.g. Country) on the entity, which is required when creating/storing a new instance
Declaration
public ChatTopicEntity CreateDefaultChatTopicEntity()
Returns
Type | Description |
---|---|
ChatTopicEntity | New ChatTopicEntity with default values |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
DeleteChatSessionEntity(Int32)
Deletes the ChatSessionEntity
Declaration
public void DeleteChatSessionEntity(int chatSessionEntityId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionEntityId | The identity of the ChatSessionEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
DeleteChatTopicEntity(Int32)
Deletes the ChatTopicEntity
Declaration
public void DeleteChatTopicEntity(int chatTopicEntityId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicEntityId | The identity of the ChatTopicEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
DeleteChatTopicUserAgent(Int32, String)
Remove a user from a topic
Declaration
public void DeleteChatTopicUserAgent(int chatTopicId, string username)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
String | username | Associate username or associate id to delete. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatMessages(Int32, Int32)
Get all or some of the messages in a chat session
Declaration
public ChatMessage[] GetChatMessages(int chatSessionId, int after)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to reset |
Int32 | after | Return messages after this message id |
Returns
Type | Description |
---|---|
ChatMessage[] | Array of chat messages in the session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatPresence()
Get the chat presence status for all chat users
Declaration
public ChatPresence[] GetChatPresence()
Returns
Type | Description |
---|---|
ChatPresence[] | An array with ChatPresence objects for each user |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatSessionEntity(Int32)
Gets a ChatSessionEntity object.
Declaration
public ChatSessionEntity GetChatSessionEntity(int chatSessionEntityId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionEntityId | The identifier of the ChatSessionEntity object |
Returns
Type | Description |
---|---|
ChatSessionEntity | ChatSessionEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatTopicEntity(Int32)
Gets a ChatTopicEntity object.
Declaration
public ChatTopicEntity GetChatTopicEntity(int chatTopicEntityId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicEntityId | The identifier of the ChatTopicEntity object |
Returns
Type | Description |
---|---|
ChatTopicEntity | ChatTopicEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatTopicUserAgent(Int32, String)
Get a user assigned to a topic
Declaration
public ChatTopicAgent GetChatTopicUserAgent(int chatTopicId, string username)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
String | username | Associate username or associate id to get. |
Returns
Type | Description |
---|---|
ChatTopicAgent | The user's role within the chat topic. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatTopicUserAgentList(Int32)
Get list of users assigned to a chat topic
Declaration
public ChatTopicAgent[] GetChatTopicUserAgentList(int chatTopicId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
Returns
Type | Description |
---|---|
ChatTopicAgent[] | List of user agents assigned to chat topic. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetChatTranscript(Int32, Boolean)
Get the chat transcript, formatted as plain text or html
Declaration
public string GetChatTranscript(int chatSessionId, bool html)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to get the transcript for |
Boolean | html | Get transcript as HTML |
Returns
Type | Description |
---|---|
String | The transcript in text or HTML |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
GetUserAgentList(Boolean, Boolean)
Get list of users that can be assigned to chat topics. Users with Chat-CALs from the MDO list 'chatuser'
Declaration
public MDOListItem[] GetUserAgentList(bool flat, bool onlyPresent)
Parameters
Type | Name | Description |
---|---|---|
Boolean | flat | Return flat list instead of grouping by usergroup. |
Boolean | onlyPresent | Only show users who are present |
Returns
Type | Description |
---|---|
MDOListItem[] | List of user agents that can be assigned to chat topics, possibly grouped by usergroup. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
IsWithinOpeningHours(Int32)
Check if we are right now within the opening hours of the given topic. Will use timezones to calculate if configured.
Declaration
public bool IsWithinOpeningHours(int chatTopicId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | The id of the topic to check |
Returns
Type | Description |
---|---|
Boolean | True if we are within opening hours, or if the topic does not use opening hours |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
PickUpChatSession(Int32)
'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
public ChatSessionEntity PickUpChatSession(int chatSessionId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to answer |
Returns
Type | Description |
---|---|
ChatSessionEntity | The chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
PickUpFirstChatSession()
'answer' the first available session from the queue: assign the session to the user. The welcome message is sent to the customer.
Declaration
public ChatSessionEntity PickUpFirstChatSession()
Returns
Type | Description |
---|---|
ChatSessionEntity | The picked-up chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
RejectChatSessionTransfer(Int32)
Do not want. Deny the transfer to the user. If the session is not being transferred, nothing happens.
Declaration
public ChatSessionEntity RejectChatSessionTransfer(int chatSessionId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to send back |
Returns
Type | Description |
---|---|
ChatSessionEntity | The updated chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
ResetChatSession(Int32)
Reset chat session, put it back on the queue for pickup. Used by bots to hand off a session to human
Declaration
public ChatSessionEntity ResetChatSession(int chatSessionId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to reset |
Returns
Type | Description |
---|---|
ChatSessionEntity | The updated chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
SaveChatPresence(ChatPresence[])
Save the chat presence for specified users
Declaration
public void SaveChatPresence(ChatPresence[] chatPresence)
Parameters
Type | Name | Description |
---|---|---|
ChatPresence[] | chatPresence | An array with ChatPresence objects. Only the UserId and Present information is used while saving |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
SaveChatSessionEntity(ChatSessionEntity)
Updates the existing ChatSessionEntity or creates a new ChatSessionEntity if the id parameter is empty
Declaration
public ChatSessionEntity SaveChatSessionEntity(ChatSessionEntity chatSessionEntity)
Parameters
Type | Name | Description |
---|---|---|
ChatSessionEntity | chatSessionEntity | The ChatSessionEntity that is saved. |
Returns
Type | Description |
---|---|
ChatSessionEntity | New or updated ChatSessionEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
SaveChatTopicEntity(ChatTopicEntity)
Updates the existing ChatTopicEntity or creates a new ChatTopicEntity if the id parameter is empty
Declaration
public ChatTopicEntity SaveChatTopicEntity(ChatTopicEntity chatTopicEntity)
Parameters
Type | Name | Description |
---|---|---|
ChatTopicEntity | chatTopicEntity | The ChatTopicEntity that is saved. |
Returns
Type | Description |
---|---|
ChatTopicEntity | New or updated ChatTopicEntity |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
TransferChatSession(Int32, String)
Request to send the session to another user. If the session does not belong to the user, nothing happens.
Declaration
public ChatSessionEntity TransferChatSession(int chatSessionId, string toAssociate)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatSessionId | id of the chat session to send |
String | toAssociate | Associate username or associate id to send session to. |
Returns
Type | Description |
---|---|
ChatSessionEntity | The updated chat session |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
UpdateChatTopicUserAgent(Int32, String, ChatTopicAgent)
Update a user's role in a chat topic
Declaration
public ChatTopicAgent UpdateChatTopicUserAgent(int chatTopicId, string username, ChatTopicAgent useragent)
Parameters
Type | Name | Description |
---|---|---|
Int32 | 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. |
Returns
Type | Description |
---|---|
ChatTopicAgent | The user's role within the chat topic. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}
UpdateChatTopicUserAgents(Int32, ChatTopicAgent[])
Update users roles in a chat topic
Declaration
public ChatTopicAgent[] UpdateChatTopicUserAgents(int chatTopicId, ChatTopicAgent[] useragents)
Parameters
Type | Name | Description |
---|---|---|
Int32 | chatTopicId | Id of the chat topic |
ChatTopicAgent[] | useragents | Users new/updated roles within the chat topic. Replaces existing roles |
Returns
Type | Description |
---|---|
ChatTopicAgent[] | The updated agents within the chat topic. |
Examples
using SuperOffice;
using SuperOffice.CRM.Services;
using (SoSession mySession = SoSession.Authenticate("user", "pass"))
{
using (ChatAgent agent = new ChatAgent())
{
// call methods on agent here...
}
}