# Chat Widget methods

The following are methods for controlling the chat widget:

## mount & demount

Mount or demount the widget from the window.

```javascript
SinchSdk.Chat.mount({configuration})
```

```javascript
SinchSdk.Chat.demount()
```

## open & close & toggle

Open or close the chat window or configure it so it can be toggled.

```javascript
SinchSdk.Chat.open()
```

```javascript
SinchSdk.Chat.close()
```

```javascript
SinchSdk.Chat.toggle()
```

## send

Send a message over the chat widget.

```javascript
SinchSdk.Chat.send("text")
```

## setTranslation

Set custom translations for the chat widget. Optionally specify a language code.

```javascript
SinchSdk.Chat.setTranslation({
    typeMessageHere: 'Type your message...',
    emojiPickerTitle: 'Emoji',
    endChatButton: 'End conversation',
    initialScreen: {
        title: 'Welcome!',
        description: 'How can we help you today?',
        startButton: 'Start Chat'
    }
}, 'en')
```

## setConversationMetadata

Set metadata to be sent with conversation messages. Use `once` for metadata sent only with the first message, or `eachMessage` for metadata sent with every message.

```javascript
SinchSdk.Chat.setConversationMetadata({
    once: {
        source: 'website',
        campaign: 'summer-sale'
    },
    eachMessage: {
        pageUrl: window.location.href
    }
})
```

## setLocale

Set the locale for the SDK.

```javascript
SinchSdk.setLocale('en-US')
```

## Cleaning up the SDK storage data

The user session along with certain configuration parameters is stored in the browser storage. If you want to clear it, use:

```javascript
SinchSdk.clear()
```

## Terminating the SDK

When you are finished with the SDK, clear the SDK memory including the saved token for authorization with the following method:

```javascript
SinchSdk.terminate()
```