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()
.
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 |
import { RealtimeClient } from '@skribby/sdk'
const realtimeClient = new RealtimeClient('wss://example.org/123456');
Simple property to be able to check whether the client is connected or not.
By default it's false
until the connect
method is called and connection is established.
boolean
console.log(realtimeClient.connected);
Create a new event listener with a callback to handle events
Parameter | Default | Description |
---|---|---|
event | required (string) | Event name to listen to. Refer to the Realtime Core Concepts for all available events. |
callback | required (function with 1 parameter) | Callback when event has been triggered. Refer to the Realtime Core Concepts for returned data per event. The callback will contain the data segment, if data is not provided the returned parameter will be undefined . |
void
realtimeClient.on('start', () => {
console.log('Bot has started!');
});
realtimeClient.on('ts', data => {
console.log(`${data.speaker_name} said: ${data.transcript}`);
});
Send an action to the bot
Parameter | Default | Description |
---|---|---|
action | required (string) | Action name. Refer to the Realtime Core Concepts for all available actions. |
data | conditionally required (depending on the action) | Data to send alongside the action. Refer to the Realtime Core Concepts for required data per action. The required data to be sent is the data portion of each action in that document. |
void
realtimeClient.send('chat-message', {
content: "Hello from my script!"
});
realtimeClient.send('stop');
Start connection with the websocket server.
void
await realtimeClient.connect();
Disconnect from the websocket server.
void
await realtimeClient.disconnect();