# [C] RealtimeClient #### `constructor` Creates a new RealtimeClient to interact with realtime transcription models. If you make use of the client, you can generate this instance automatically via [`MeetingBot.getRealtimeClient()`](/ts-sdk/api-reference/meetingbot#getrealtimeclient). If this would be used on the front-end, then you can fetch the websocket url in the back-end, forward it to the front-end and use this class directly. | Parameter | Default | Description | | --- | --- | --- | | `ws_url` | *required* | URL to the websocket server | ```ts import { RealtimeClient } from '@skribby/sdk' const realtimeClient = new RealtimeClient('wss://example.org/123456'); ``` ## Properties ### `connected` Simple property to be able to check whether the client is connected or not. By default it's `false` until the [`connect`](#connect) method is called and connection is established. #### Returns `boolean` #### Example ```ts console.log(realtimeClient.connected); ``` ## Methods ### `on` Create a new event listener with a callback to handle events #### Parameters | Parameter | Default | Description | | --- | --- | --- | | `event` | *required* (string) | Event name to listen to. Refer to the [Realtime Core Concepts](/concepts/realtime-transcription#websocket-events) for all available events. | | `callback` | *required* (function with 1 parameter) | Callback when event has been triggered. Refer to the [Realtime Core Concepts](/concepts/realtime-transcription#websocket-events) for returned data per event. The callback will contain the `data` segment, if `data` is not provided the returned parameter will be `undefined`. | #### Returns `void` #### Example ```ts realtimeClient.on('start', () => { console.log('Bot has started!'); }); realtimeClient.on('ts', data => { console.log(`${data.speaker_name} said: ${data.transcript}`); }); ``` ### `send` Send an action to the bot #### Parameters | Parameter | Default | Description | | --- | --- | --- | | `action` | *required* (string) | Action name. Refer to the [Realtime Core Concepts](/concepts/realtime-transcription#websocket-actions) for all available actions. | | `data` | *conditionally required* (depending on the action) | Data to send alongside the action. Refer to the [Realtime Core Concepts](/concepts/realtime-transcription#websocket-actions) for required data per action. The required data to be sent is the `data` portion of each action in that document. | #### Returns `void` #### Example ```ts realtimeClient.send('chat-message', { content: "Hello from my script!" }); realtimeClient.send('stop'); ``` ### `connect` Start connection with the websocket server. #### Returns `void` #### Example ```ts await realtimeClient.connect(); ``` ### `disconnect` Disconnect from the websocket server. #### Returns `void` #### Example ```ts await realtimeClient.disconnect(); ```