@talkif/webrtc-react 0.1.0 → 0.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 +39 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @talkif/webrtc-react
|
|
2
|
+
|
|
3
|
+
Headless React bindings for [`@talkif/webrtc`](https://www.npmjs.com/package/@talkif/webrtc) — talk to [Talkif](https://talkif.ai) AI voice agents over WebRTC from React.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @talkif/webrtc @talkif/webrtc-react
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { useTalkifCall } from '@talkif/webrtc-react';
|
|
11
|
+
|
|
12
|
+
function CallWidget() {
|
|
13
|
+
const { state, durationSecs, muted, start, hangup, toggleMute } = useTalkifCall({
|
|
14
|
+
config: { baseUrl: 'https://api.talkif.ai', publishableKey: 'pk_live_...' },
|
|
15
|
+
onTranscript: ({ role, content }) => console.log(role, content),
|
|
16
|
+
onTtsChunk: ({ text }) => console.log('agent (streaming):', text),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return state === 'connected' ? (
|
|
20
|
+
<>
|
|
21
|
+
<span>{durationSecs}s</span>
|
|
22
|
+
<button onClick={toggleMute}>{muted ? 'Unmute' : 'Mute'}</button>
|
|
23
|
+
<button onClick={hangup}>Hang up</button>
|
|
24
|
+
</>
|
|
25
|
+
) : (
|
|
26
|
+
<button onClick={() => start({})} disabled={state !== 'idle' && state !== 'ended' && state !== 'error'}>
|
|
27
|
+
Start call
|
|
28
|
+
</button>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`useTalkifCall` returns `{ state, callId, botId, error, durationSecs, muted, call, start, hangup, toggleMute, sendAppMessage }`. Callbacks: `onAppMessage`, `onCallEvent`, `onTranscript`, `onTtsWord`, `onTtsChunk`, `onEnded`, `onError`. One active call at a time; unmount tears everything down (mic, peer connection, timers).
|
|
34
|
+
|
|
35
|
+
Full documentation — config modes (authenticated vs public embed), the complete event reference, and error codes — lives in the [`@talkif/webrtc` README](https://www.npmjs.com/package/@talkif/webrtc) and the [GitHub repository](https://github.com/Talkif-ai/webrtc-js).
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talkif/webrtc-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React bindings for @talkif/webrtc — headless hook for Talkif voice sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=18",
|
|
28
|
-
"@talkif/webrtc": "^0.1.
|
|
28
|
+
"@talkif/webrtc": "^0.1.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "^19.1.0",
|
|
32
32
|
"react": "^19.1.0",
|
|
33
33
|
"tsup": "^8.4.0",
|
|
34
34
|
"typescript": "^5.8.3",
|
|
35
|
-
"@talkif/webrtc": "0.1.
|
|
35
|
+
"@talkif/webrtc": "0.1.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsup src/index.ts --format esm,cjs --dts --sourcemap --clean --external react,@talkif/webrtc",
|