@whereby.com/assistant-sdk 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -16
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Assistants require [FFmpeg](https://ffmpeg.org/download.html) to be installed an
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
-
In order to use assistants, you must first create an assistant in your Whereby dashboard. This will give you an API key which you can then pass into your Assistant to allow it to join rooms. See here for more details -
|
|
30
|
+
In order to use assistants, you must first create an assistant in your Whereby dashboard. This will give you an API key which you can then pass into your Assistant to allow it to join rooms. See here for more details - [Assistants Documentation](https://docs.whereby.com/reference/assistant-sdk-reference)
|
|
31
31
|
|
|
32
32
|
### Getting started
|
|
33
33
|
|
|
@@ -39,18 +39,19 @@ async function main() {
|
|
|
39
39
|
// Create an assistant instance
|
|
40
40
|
const assistant = new Assistant({
|
|
41
41
|
roomUrl: "https://your-subdwhereby.com/your-room", // Room URL to join
|
|
42
|
-
startCombinedAudioStream: true, // Enable combined audio stream
|
|
43
42
|
});
|
|
44
43
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
44
|
+
// Join the room
|
|
45
|
+
try {
|
|
46
|
+
await assistant.joinRoom(roomUrl);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("Failed to join room:", error);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// To receive all audio data from the call:
|
|
53
|
+
// You can now use the audio data in a transcription service, save to file, etc.
|
|
54
|
+
const combinedAudioSink = assistant.getCombinedAudioSink();
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
main();
|
|
@@ -87,9 +88,11 @@ Typical usage:
|
|
|
87
88
|
import "@whereby.com/assistant-sdk/polyfills"; // Required to run in Node.js
|
|
88
89
|
import { Assistant, Trigger, TRIGGER_EVENT_SUCCESS, AUDIO_STREAM_READY } from "@whereby.com/assistant-sdk";
|
|
89
90
|
|
|
91
|
+
let hasJoinedRoom = false;
|
|
92
|
+
|
|
90
93
|
const trigger = new Trigger({
|
|
91
94
|
webhookTriggers: {
|
|
92
|
-
"room.client.joined": () =>
|
|
95
|
+
"room.client.joined": () => !hasJoinedRoom, // Start an assistant when first client joins
|
|
93
96
|
},
|
|
94
97
|
port: 3000, // Port to listen on
|
|
95
98
|
});
|
|
@@ -102,11 +105,14 @@ trigger.on(TRIGGER_EVENT_SuCCESS, async ({ roomUrl }) => {
|
|
|
102
105
|
assistantKey: "your-assistant-key",
|
|
103
106
|
});
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
try {
|
|
109
|
+
await assistant.joinRoom(roomUrl);
|
|
110
|
+
hasJoinedRoom = true;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error("Failed to join room:", error);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
106
115
|
|
|
107
|
-
assistant.on(AUDIO_STREAM_READY, (stream) => {
|
|
108
|
-
console.log("Combined audio stream is ready:", stream);
|
|
109
|
-
});
|
|
110
116
|
});
|
|
111
117
|
|
|
112
118
|
trigger.start();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@whereby.com/assistant-sdk",
|
|
3
3
|
"description": "Assistant SDK for whereby.com",
|
|
4
4
|
"author": "Whereby AS",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"prettier": "^3.5.3",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
53
|
"@whereby.com/eslint-config": "0.1.0",
|
|
54
|
-
"@whereby.com/jest-config": "0.1.0",
|
|
55
54
|
"@whereby.com/prettier-config": "0.1.0",
|
|
56
|
-
"@whereby.com/
|
|
57
|
-
"@whereby.com/
|
|
55
|
+
"@whereby.com/tsconfig": "0.1.0",
|
|
56
|
+
"@whereby.com/jest-config": "0.1.0",
|
|
57
|
+
"@whereby.com/rollup-config": "0.1.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@roamhq/wrtc": "github:whereby/node-webrtc#patch/rtc_audio_source",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"express": "5.1.0",
|
|
65
65
|
"uuid": "^11.0.3",
|
|
66
66
|
"ws": "^8.18.0",
|
|
67
|
-
"@whereby.com/core": "1.2.
|
|
67
|
+
"@whereby.com/core": "1.2.2"
|
|
68
68
|
},
|
|
69
69
|
"prettier": "@whereby.com/prettier-config",
|
|
70
70
|
"scripts": {
|