Show / Hide Table of Contents

Class NSChatAgent

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

Syntax
Examples
NSChatAgent agent;
agent.callMethod(arg1, arg2);

Constructors

NSChatAgent()

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

Declaration
NSChatAgent
Examples
NSChatAgent agent;
agent.callMethod(arg1, arg2);

Methods

AcceptChatSessionTransfer(Integer)

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

Declaration
NSChatSessionEntity AcceptChatSessionTransfer(Integer chatSessionId)
Parameters
Type Name Description
Integer chatSessionId
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
Integer chatSessionId;
NSChatSessionEntity res = agent.AcceptChatSessionTransfer(chatSessionId);

AddChatMessage(Integer,NSChatMessage)

Adds a new message to a chat session

Declaration
NSChatMessage AddChatMessage(Integer chatSessionId, NSChatMessage message)
Parameters
Type Name Description
Integer chatSessionId
NSChatMessage message

The message to add.

Returns
Type Description
NSChatMessage
Examples
NSChatAgent agent;
Integer chatSessionId;
NSChatMessage message;
NSChatMessage res = agent.AddChatMessage(chatSessionId, message);

AddChatTopicUserAgent(Integer,NSChatTopicAgent)

Adds a user to a chat topic

Declaration
NSChatTopicAgent AddChatTopicUserAgent(Integer chatTopicId, NSChatTopicAgent useragent)
Parameters
Type Name Description
Integer chatTopicId
NSChatTopicAgent useragent
Returns
Type Description
NSChatTopicAgent
Examples
NSChatAgent agent;
Integer chatTopicId;
NSChatTopicAgent useragent;
NSChatTopicAgent res = agent.AddChatTopicUserAgent(chatTopicId, useragent);

ChatSessionsForUser()

Gets all chat sessions which this user is a member of.

Declaration
NSChatSessionEntity[] ChatSessionsForUser()
Returns
Type Description
NSChatSessionEntity[]
Remarks

Members means that you have at least one of: Can Respond, Notifications, Listen or Manager

Examples
NSChatAgent agent;
NSChatSessionEntity[] res = agent.ChatSessionsForUser();

ChatTopicsForUser()

Gets all chat topics which this user is a member of.nd, Notifications, Listen or Manager.

Declaration
NSChatTopicEntity[] ChatTopicsForUser()
Returns
Type Description
NSChatTopicEntity[]
Remarks

Members means that you have at least one of: Can Respond, Notifications, Listen or Manager

Examples
NSChatAgent agent;
NSChatTopicEntity[] res = agent.ChatTopicsForUser();

CreateChatSessionForTopic(Integer)

Creates a new session on a chat topic

Declaration
NSChatSessionEntity CreateChatSessionForTopic(Integer chatTopicId)
Parameters
Type Name Description
Integer chatTopicId
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
Integer chatTopicId;
NSChatSessionEntity res = agent.CreateChatSessionForTopic(chatTopicId);

CreateDefaultChatSessionEntity()

Sets default values into a new NSChatSessionEntity.

Declaration
NSChatSessionEntity CreateDefaultChatSessionEntity()
Returns
Type Description
NSChatSessionEntity
Remarks

NetServer calculates default values (for example Country) on the entity, which is required when creating/storing a new instance

Examples
NSChatAgent agent;
NSChatSessionEntity thing = agent.CreateDefaultChatSessionEntity();
thing = agent.SaveChatSessionEntity(thing);

CreateDefaultChatTopicAgent()

Sets default values into a new NSChatTopicAgent.

Declaration
NSChatTopicAgent CreateDefaultChatTopicAgent()
Returns
Type Description
NSChatTopicAgent
Remarks

NetServer calculates default values (for example Country) on the entity, which is required when creating/storing a new instance

Examples
NSChatAgent agent;
NSChatTopicAgent thing = agent.CreateDefaultChatTopicAgent();
thing = agent.SaveChatTopicAgent(thing);

CreateDefaultChatTopicEntity()

Sets default values into a new NSChatTopicEntity.

Declaration
NSChatTopicEntity CreateDefaultChatTopicEntity()
Returns
Type Description
NSChatTopicEntity
Remarks

NetServer calculates default values (for example Country) on the entity, which is required when creating/storing a new instance

Examples
NSChatAgent agent;
NSChatTopicEntity thing = agent.CreateDefaultChatTopicEntity();
thing = agent.SaveChatTopicEntity(thing);

DeleteChatSessionEntity(Integer)

Deletes the NSChatSessionEntity

Declaration
Void DeleteChatSessionEntity(Integer chatSessionEntity)
Parameters
Type Name Description
Integer chatSessionEntity
Returns
Type Description
Void
Examples
NSChatAgent agent;
agent.DeleteChatSessionEntity(123);

DeleteChatTopicEntity(Integer)

Deletes the NSChatTopicEntity

Declaration
Void DeleteChatTopicEntity(Integer chatTopicEntity)
Parameters
Type Name Description
Integer chatTopicEntity
Returns
Type Description
Void
Examples
NSChatAgent agent;
agent.DeleteChatTopicEntity(123);

DeleteChatTopicUserAgent(Integer,String)

Removes a user from a topic

Declaration
Void DeleteChatTopicUserAgent(Integer chatTopicId, String username)
Parameters
Type Name Description
Integer chatTopicId
String username
Returns
Type Description
Void
Examples
NSChatAgent agent;
Integer chatTopicId;
String username;
agent.DeleteChatTopicUserAgent(chatTopicId, username);

GetChatMessages(Integer,Integer)

Gets all or some of the messages in a chat session

Declaration
NSChatMessage[] GetChatMessages(Integer chatSessionId, Integer after)
Parameters
Type Name Description
Integer chatSessionId
Integer after
Returns
Type Description
NSChatMessage[]
Examples
NSChatAgent agent;
Integer chatSessionId;
Integer after;
NSChatMessage[] res = agent.GetChatMessages(chatSessionId, after);

GetChatPresence()

Gets the chat presence status for all chat users.

Declaration
NSChatPresence[] GetChatPresence()
Returns
Type Description
NSChatPresence[]
Examples
NSChatAgent agent;
NSChatPresence[] res = agent.GetChatPresence();

GetChatSessionEntity(Integer)

Gets an NSChatSessionEntity object.

Declaration
NSChatSessionEntity GetChatSessionEntity(Integer chatSessionEntityId)
Parameters
Type Name Description
Integer chatSessionEntityId
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
NSChatSessionEntity thing = agent.GetChatSessionEntity(123);

GetChatTopicEntity(Integer)

Gets an NSChatTopicEntity object.

Declaration
NSChatTopicEntity GetChatTopicEntity(Integer chatTopicEntityId)
Parameters
Type Name Description
Integer chatTopicEntityId
Returns
Type Description
NSChatTopicEntity
Examples
NSChatAgent agent;
NSChatTopicEntity thing = agent.GetChatTopicEntity(123);

GetChatTopicUserAgent(Integer,String)

Gets a user assigned to a topic

Declaration
NSChatTopicAgent GetChatTopicUserAgent(Integer chatTopicId, String username)
Parameters
Type Name Description
Integer chatTopicId
String username
Returns
Type Description
NSChatTopicAgent
Examples
NSChatAgent agent;
Integer chatTopicId;
String username;
NSChatTopicAgent res = agent.GetChatTopicUserAgent(chatTopicId, username);

GetChatTopicUserAgentList(Integer)

Gets a list of users assigned to a chat topic.

Declaration
NSChatTopicAgent[] GetChatTopicUserAgentList(Integer chatTopicId)
Parameters
Type Name Description
Integer chatTopicId
Returns
Type Description
NSChatTopicAgent[]
Examples
NSChatAgent agent;
Integer chatTopicId;
NSChatTopicAgent[] res = agent.GetChatTopicUserAgentList(chatTopicId);

GetChatTranscript(Integer,Bool)

Gets the chat transcript, formatted as plain text or HTML.

Declaration
String GetChatTranscript(Integer chatSessionId, Bool html)
Parameters
Type Name Description
Integer chatSessionId
Bool html
Returns
Type Description
String

chat transcript, formatted as plain text or HTMl.

Examples
NSChatAgent agent;
Integer chatSessionId;
Bool html;
String res = agent.GetChatTranscript(chatSessionId, html);

GetUserAgentList(Bool,Bool)

Gets list of users that can be assigned to chat topics.

Declaration
NSMDOListItem[] GetUserAgentList(Bool flat, Bool onlyPresent)
Parameters
Type Name Description
Bool flat
Bool onlyPresent
Returns
Type Description
NSMDOListItem[]
Remarks

Users with Chat-CALs from the MDO list 'chatuser'

Examples
NSChatAgent agent;
Bool flat;
Bool onlyPresent;
NSMDOListItem[] res = agent.GetUserAgentList(flat, onlyPresent);

IsWithinOpeningHours(Integer)

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

Declaration
Bool IsWithinOpeningHours(Integer chatTopicId)
Parameters
Type Name Description
Integer chatTopicId
Returns
Type Description
Bool
Examples
NSChatAgent agent;
Integer chatTopicId;
Bool res = agent.IsWithinOpeningHours(chatTopicId);

PickUpChatSession(Integer)

Answer the session: assign the session to the user. The welcome message is sent to the customer.

Declaration
NSChatSessionEntity PickUpChatSession(Integer chatSessionId)
Parameters
Type Name Description
Integer chatSessionId
Returns
Type Description
NSChatSessionEntity

Returns NULL if session was not in queue.

Examples
NSChatAgent agent;
Integer chatSessionId;
NSChatSessionEntity res = agent.PickUpChatSession(chatSessionId);

PickUpFirstChatSession()

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

Declaration
NSChatSessionEntity PickUpFirstChatSession()
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
NSChatSessionEntity res = agent.PickUpFirstChatSession();

RejectChatSessionTransfer(Integer)

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

Declaration
NSChatSessionEntity RejectChatSessionTransfer(Integer chatSessionId)
Parameters
Type Name Description
Integer chatSessionId
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
Integer chatSessionId;
NSChatSessionEntity res = agent.RejectChatSessionTransfer(chatSessionId);

ResetChatSession(Integer)

Resets chat session, puts it back on the queue for pickup.

Declaration
NSChatSessionEntity ResetChatSession(Integer chatSessionId)
Parameters
Type Name Description
Integer chatSessionId
Returns
Type Description
NSChatSessionEntity
Remarks

Used by bots to hand off a session to human

Examples
NSChatAgent agent;
Integer chatSessionId;
NSChatSessionEntity res = agent.ResetChatSession(chatSessionId);

SaveChatPresence(NSChatPresence[])

Saves the chat presence for specified users

Declaration
Void SaveChatPresence(NSChatPresence[] chatPresence)
Parameters
Type Name Description
NSChatPresence[] chatPresence
Returns
Type Description
Void
Examples
NSChatAgent agent;
NSChatPresence[] chatPresence;
agent.SaveChatPresence(chatPresence);

SaveChatSessionEntity(NSChatSessionEntity)

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

Declaration
NSChatSessionEntity SaveChatSessionEntity(NSChatSessionEntity chatSessionEntity)
Parameters
Type Name Description
NSChatSessionEntity chatSessionEntity
Returns
Type Description
NSChatSessionEntity
Examples
NSChat  agent;
NSChatSessionEntity thing = agent.CreateDefaultChatSessionEntity();
thing = agent.SaveChatSessionEntity(thing);

SaveChatTopicEntity(NSChatTopicEntity)

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

Declaration
NSChatTopicEntity SaveChatTopicEntity(NSChatTopicEntity chatTopicEntity)
Parameters
Type Name Description
NSChatSessionEntity chatSessionEntity

The NSChatTopicEntity to save.

Returns
Type Description
NSChatTopicEntity
Examples
NSChat  agent;
NSChatTopicEntity thing = agent.CreateDefaultChatTopicEntity();
thing = agent.SaveChatTopicEntity(thing);

TransferChatSession(Integer,String)

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

Declaration
NSChatSessionEntity TransferChatSession(Integer chatSessionId, String toAssociate)
Parameters
Type Name Description
Integer chatSessionId
String toAssociate
Returns
Type Description
NSChatSessionEntity
Examples
NSChatAgent agent;
Integer chatSessionId;
String toAssociate;
NSChatSessionEntity res = agent.TransferChatSession(chatSessionId, toAssociate);

UpdateChatTopicUserAgent(Integer,String,NSChatTopicAgent)

Updates a user's role in a chat topic

Declaration
NSChatTopicAgent UpdateChatTopicUserAgent(Integer chatTopicId, String username, NSChatTopicAgent useragent)
Parameters
Type Name Description
Integer chatTopicId
String username
NSChatTopicAgent useragent
Returns
Type Description
NSChatTopicAgent
Examples
NSChatAgent agent;
Integer chatTopicId;
String username;
NSChatTopicAgent useragent;
NSChatTopicAgent res = agent.UpdateChatTopicUserAgent(chatTopicId, username, useragent);

UpdateChatTopicUserAgent(Integer,NSChatTopicAgent[])

Updates users roles in a chat topic

Declaration
NSChatTopicAgent[] UpdateChatTopicUserAgents(Integer chatTopicId, NSChatTopicAgent[] useragents)
Parameters
Type Name Description
Integer chatTopicId
NSChatTopicAgent[] useragents
Returns
Type Description
NSChatTopicAgent[]
Examples
NSChatAgent agent;
Integer chatTopicId;
NSChatTopicAgent[] useragents;
NSChatTopicAgent[] res = agent.UpdateChatTopicUserAgents(chatTopicId, useragents);
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top