> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# NSCustomerServiceAgent

> Agent used for Customer Service methods.

Agent used for Customer Service methods.

## Constructors

### NSCustomerServiceAgent()

```crmscript theme={null}
NSCustomerServiceAgent
```

Agent used for Customer Service methods.

## Methods

## AddMessageFromMailData(Integer,String)

Adds a message to an existing request in the sam way as importMail would do it from an email.

```crmscript theme={null}
NSTicketInfo AddMessageFromMailData(Integer ticketId, String data)
```

**Returns:** [CRMScript.NetServer.NSTicketInfo](CRMScript.NetServer.NSTicketInfo)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Integer ticketId;
String data;
NSTicketInfo res = agent.AddMessageFromMailData(ticketId, data);
```

## ChatSessionsForUser()

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

```crmscript theme={null}
NSChatSession[] ChatSessionsForUser()
```

**Returns:** [CRMScript.NetServer.NSChatSession](CRMScript.NetServer.NSChatSession)\[] - chat topics.

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

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSChatSession[] res = agent.ChatSessionsForUser();
```

## CheckIfCustomizedTemplates()

Checks whether the core HTML templates are customized

```crmscript theme={null}
Bool CheckIfCustomizedTemplates()
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Bool res = agent.CheckIfCustomizedTemplates();
```

## CheckSymmetricEncryption(String)

Checks that we are using the same encryption keys

```crmscript theme={null}
String CheckSymmetricEncryption(String encryptedString)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String encryptedString;
String res = agent.CheckSymmetricEncryption(encryptedString);
```

## CreateDefaultCustomerCenterConfig()

Sets default values into a new NSCustomerCenterConfig.

```crmscript theme={null}
NSCustomerCenterConfig CreateDefaultCustomerCenterConfig()
```

**Returns:** [CRMScript.NetServer.NSCustomerCenterConfig](CRMScript.NetServer.NSCustomerCenterConfig)

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

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSCustomerCenterConfig thing = agent.CreateDefaultCustomerCenterConfig();
thing = agent.SaveCustomerCenterConfig(thing);
```

## CreateDefaultMailboxEntity()

Sets default values into a new NSMailboxEntity

```crmscript theme={null}
NSMailboxEntity CreateDefaultMailboxEntity()
```

**Returns:** [CRMScript.NetServer.NSMailboxEntity](CRMScript.NetServer.NSMailboxEntity)

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

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSMailboxEntity thing = agent.CreateDefaultMailboxEntity();
thing = agent.SaveMailboxEntity(thing);
```

## CreateDefaultSmsConfig()

Sets default values into a new NSSmsConfig.

```crmscript theme={null}
NSSmsConfig CreateDefaultSmsConfig()
```

**Returns:** [CRMScript.NetServer.NSSmsConfig](CRMScript.NetServer.NSSmsConfig)

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

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSSmsConfig thing = agent.CreateDefaultSmsConfig();
thing = agent.SaveSmsConfig(thing);
```

## CreateSession(String)

Creates a login session for a CS user

```crmscript theme={null}
NSCsSessionKey CreateSession(String remoteIp)
```

**Returns:** [CRMScript.NetServer.NSCsSessionKey](CRMScript.NetServer.NSCsSessionKey)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String remoteIp;
NSCsSessionKey res = agent.CreateSession(remoteIp);
```

## CreateTicketFromMailData(Integer,String)

Creates a new ticket in the same way as importMail would import an email.

```crmscript theme={null}
NSTicketInfo CreateTicketFromMailData(Integer mailboxId, String data)
```

**Returns:** [CRMScript.NetServer.NSTicketInfo](CRMScript.NetServer.NSTicketInfo)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Integer mailboxId;
String data;
NSTicketInfo res = agent.CreateTicketFromMailData(mailboxId, data);
```

## DeleteChatSessions(Integer\[])

Deletes the specified chat sessions.

```crmscript theme={null}
Void DeleteChatSessions(Integer[] ids)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Integer[] ids;
agent.DeleteChatSessions(ids);
```

## DeleteCustomerCenterConfig(Integer)

Deletes the NSCustomerCenterConfig

```crmscript theme={null}
DeleteCustomerCenterConfig(Integer customerCenterConfig)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
agent.DeleteCustomerCenterConfig(123);
```

## EventHandlerExists(Integer)

Checks if an event handler exists.

```crmscript theme={null}
Bool EventHandlerExists(Integer eventHandlerType)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Integer eventHandlerType;
Bool res = agent.EventHandlerExists(eventHandlerType);
```

## ExecuteEventHandlers(NSEventData)

Executes event handlers in CRMScript for a given event.

```crmscript theme={null}
NSEventData ExecuteEventHandlers(NSEventData eventData)
```

**Returns:** [CRMScript.NetServer.NSEventData](CRMScript.NetServer.NSEventData)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSEventData eventData;
NSEventData res = agent.ExecuteEventHandlers(eventData);
```

## FindTicketsByTitleOrId(String,Integer)

Searches for tickets matching title or ID

```crmscript theme={null}
NSTicketInfo[] FindTicketsByTitleOrId(String titleOrId, Integer maxRows)
```

**Returns:** [CRMScript.NetServer.NSTicketInfo](CRMScript.NetServer.NSTicketInfo)\[]

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String titleOrId;
Integer maxRows;
NSTicketInfo[] res = agent.FindTicketsByTitleOrId(titleOrId, maxRows);
```

## GetAllCustomerCenterConfigs()

Gets all rows from cust\_config as an array of NSCustomerCenterConfig entities

```crmscript theme={null}
NSCustomerCenterConfig[] GetAllCustomerCenterConfigs()
```

**Returns:** [CRMScript.NetServer.NSCustomerCenterConfig](CRMScript.NetServer.NSCustomerCenterConfig)\[]

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSCustomerCenterConfig[] res = agent.GetAllCustomerCenterConfigs();
```

## GetCustomerCenterConfig(Integer)

Gets an NSCustomerCenterConfig object.

```crmscript theme={null}
NSCustomerCenterConfig GetCustomerCenterConfig(Integer customerCenterConfigId)
```

**Returns:** [CRMScript.NetServer.NSCustomerCenterConfig](CRMScript.NetServer.NSCustomerCenterConfig)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSCustomerCenterConfig thing = agent.GetCustomerCenterConfig(123);
```

## GetCustomerServiceStartup()

Gets the carrier with data that Service needs when starting up

```crmscript theme={null}
NSCustomerServiceStartup GetCustomerServiceStartup()
```

**Returns:** [CRMScript.NetServer.NSCustomerServiceStartup](CRMScript.NetServer.NSCustomerServiceStartup)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSCustomerServiceStartup res = agent.GetCustomerServiceStartup();
```

## GetMailboxEntity(Integer)

Gets an NSMailboxEntity object.

```crmscript theme={null}
NSMailboxEntity GetMailboxEntity(Integer mailboxEntityId)
```

**Returns:** [CRMScript.NetServer.NSMailboxEntity](CRMScript.NetServer.NSMailboxEntity)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSMailboxEntity thing = agent.GetMailboxEntity(123);
```

## GetMailboxes()

Gets all registered mailboxes in Service

```crmscript theme={null}
NSMailbox[] GetMailboxes()
```

**Returns:** [CRMScript.NetServer.NSMailbox](CRMScript.NetServer.NSMailbox)\[]

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSMailbox[] res = agent.GetMailboxes();
```

## GetProgramUrl(String,Bool)

Converts a module name into a Service URL.

```crmscript theme={null}
String GetProgramUrl(String programName, Bool external)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String programName;
Bool external;
String res = agent.GetProgramUrl(programName, external);
```

## GetSmsConfig()

Gets the NSSmsConfig settings for Customer Service SMS providers.

```crmscript theme={null}
NSSmsConfig GetSmsConfig()
```

**Returns:** [CRMScript.NetServer.NSSmsConfig](CRMScript.NetServer.NSSmsConfig)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
NSSmsConfig res = agent.GetSmsConfig();
```

## GetStatistics()

Gets the calculated results for the required statistics for the Service Status page

```crmscript theme={null}
CRMScript.NetServer.NSStatisticsDataSet[] GetStatistics(Integer[] functions)
```

**Returns:** [CRMScript.NetServer.NSStatisticsDataSet](CRMScript.NetServer.NSStatisticsDataSet)\[] - Array of StatisticsDataSet.

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Integer[] functions;
NSStatisticsDataSet[] res = agent.GetStatistics(functions);
```

## HasChatNotify()

Checks if user has any chat notification

```crmscript theme={null}
Bool HasChatNotify()
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
Bool res = agent.HasChatNotify();
```

## RemoveSession(Integer)

Removes a login session for a Service user

```crmscript theme={null}
Void RemoveSession(Integer loginId)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## SaveAllCustomerCenterConfigs(NSCustomerCenterConfig\[])

Saves an array of NSCustomerCenterConfig entities to the database

```crmscript theme={null}
Void SaveAllCustomerCenterConfigs(NSCustomerCenterConfig[] custConfigs)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
agent.SaveAllCustomerCenterConfigs(custConfigs);
```

## SaveCustomerCenterConfig(NSCustomerCenterConfig)

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

```crmscript theme={null}
NSCustomerCenterConfig SaveCustomerCenterConfig(NSCustomerCenterConfig customerCenterConfig)
```

**Returns:** [CRMScript.NetServer.NSCustomerCenterConfig](CRMScript.NetServer.NSCustomerCenterConfig)

**Example:**

```crmscript theme={null}
NSCustomerService  agent;
NSCustomerCenterConfig thing = agent.CreateDefaultCustomerCenterConfig();
thing = agent.SaveCustomerCenterConfig(thing);
```

## SaveMailboxEntity(NSMailboxEntity)

Updates the existing NSMailboxEntity or creates a new NSMailboxEntity if the ID parameter is 0

```crmscript theme={null}
NSMailboxEntity SaveMailboxEntity(NSMailboxEntity mailboxEntity)
```

**Returns:** [CRMScript.NetServer.NSMailboxEntity](CRMScript.NetServer.NSMailboxEntity)

**Example:**

```crmscript theme={null}
NSCustomerService  agent;
NSMailboxEntity thing = agent.CreateDefaultMailboxEntity();
thing = agent.SaveMailboxEntity(thing);
```

## SaveSmsConfig(NSSmsConfig)

Updates the existing NSSmsConfig or creates a new NSSmsConfig if the ID parameter is 0

```crmscript theme={null}
NSSmsConfig SaveSmsConfig(NSSmsConfig smsConfig)
```

**Returns:** [CRMScript.NetServer.NSSmsConfig](CRMScript.NetServer.NSSmsConfig)

**Example:**

```crmscript theme={null}
NSCustomerService  agent;
NSSmsConfig thing = agent.CreateDefaultSmsConfig();
thing = agent.SaveSmsConfig(thing);
```

## SessionIsValid(String)

Checks if a Service session is valid

```crmscript theme={null}
Bool SessionIsValid(String csSessionKey)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String csSessionKey;
Bool res = agent.SessionIsValid(csSessionKey);
```

## TestSmtpServer(String,String,Bool)

Tests an SMTP account, by sending an email to a special @superoffice.com account

```crmscript theme={null}
NSSmtpTestResult TestSmtpServer(String smtpUri, String from, Bool useStoredPassword)
```

**Returns:** [CRMScript.NetServer.NSSmtpTestResult](CRMScript.NetServer.NSSmtpTestResult)

**Example:**

```crmscript theme={null}
NSCustomerServiceAgent agent;
String smtpUri;
String from;
Bool useStoredPassword;
NSSmtpTestResult res = agent.TestSmtpServer(smtpUri, from, useStoredPassword);
```

## UpdateFeatureToggles(CsFeatureToggle\[])

Updates the cached FeatureToggles for Service

```crmscript theme={null}
Void UpdateFeatureToggles(CsFeatureToggle[] featureToggles)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)


## Related topics

- [Namespace CRMScript.NetServer](/en/automation/crmscript/reference/CRMScript.NetServer.md)
- [SuperOffice.WebApi.Agents.CustomerServiceAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.CustomerServiceAgent.md)
- [SuperOffice.WebApi.Agents.ICustomerServiceAgent](/en/api/reference/webapi/SuperOffice.WebApi.Agents.ICustomerServiceAgent.md)
- [Customer](/en/automation/crmscript/reference/CRMScript.Native.Customer.md)
- [Get Faq For Customer](/en/api/reference/restful/agent/customerservice_agent/get-faq-for-customer.md)
- [Get Customer Service Startup](/en/api/reference/restful/agent/customerservice_agent/get-customer-service-startup.md)
