# Initialization

## Initialization <a href="#undefined" id="undefined"></a>

Before using Game Chat, it must be initialized. \
Add the project ID you checked in the dashboard. To initialize Game Chat, follow these steps:

1. Access the dashboard and check the project ID in the settings menu.
2. Use the following code to initialize instances.

* Import the NBaseSDK module.

```csharp
using NBaseSDK;
```

* Create an NBaseSDK Chat instance.

```csharp
NBaseSDK.Chat nc = NBaseSDK.Chat.GetInstance();
```

* Initialize NChat. \
  Enter the settings for projectId, region, and language.

```csharp
nc.initialize([PROJECT_ID], [REGION], [LANGUAGE]);
```

<table><thead><tr><th width="158">ID</th><th width="98">Type</th><th width="365">Description</th><th>Required</th></tr></thead><tbody><tr><td>PROJECT_ID</td><td>string</td><td>ID (Game Chat dashboard Project ID)</td><td>O</td></tr><tr><td>REGION</td><td>string</td><td>Region (use "kr" if not using a specific one)</td><td>O</td></tr><tr><td>LANGUAGE</td><td>string</td><td>Language code ("en", "ko", etc.)</td><td>O</td></tr></tbody></table>

## Error handling <a href="#undefined" id="undefined"></a>

* Basic error handling is to add the code inside the try... catch as follows:

```csharp
try
{
    // Write the code that may cause an error here.
    ...
}
catch (InvalidOperationException e)
{
    // Write the handling for specific error types here.
    Console.WriteLine("InvalidOperationException: {0}", e.Message);
}
catch(Exception e)
{
    // Write the general error handling here.
    Console.WriteLine("Error: {0}", e.Message);
}

```
