@telnyx/ai-agent-widget 0.33.9-beta.0 → 0.33.9-beta.1
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 +46 -0
- package/dist/bundle.min.js +27 -27
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -47,6 +47,52 @@ You can customize the call options by adding attributes to the `<telnyx-ai-agent
|
|
|
47
47
|
- [`call-caller-name`](https://developers.telnyx.com/development/webrtc/js-sdk/interfaces/icalloptions#callername)
|
|
48
48
|
- [`call-custom-headers`](https://developers.telnyx.com/development/webrtc/js-sdk/interfaces/icalloptions#customheaders)
|
|
49
49
|
- [`call-audio`](https://developers.telnyx.com/development/webrtc/js-sdk/interfaces/icalloptions#audio)
|
|
50
|
+
- `chat-mode` — enable text-only mode (no microphone). See [Chat Mode](#chat-mode) below.
|
|
51
|
+
|
|
52
|
+
### Chat Mode
|
|
53
|
+
|
|
54
|
+
Enable text-only interaction (no microphone) with the `chat-mode` attribute. When enabled:
|
|
55
|
+
|
|
56
|
+
- No microphone permission is requested — the WebRTC peer negotiates audio as `recvonly`
|
|
57
|
+
- The conversation auto-starts immediately after the client connects (no "Start Call" button)
|
|
58
|
+
- The widget starts in the expanded state to show the transcript
|
|
59
|
+
- The audio visualizer, mute button, and `<audio>` element are hidden
|
|
60
|
+
- Agent audio tracks are disabled so no speech is played back
|
|
61
|
+
- The user interacts via `sendConversationMessage()` (text input in the transcript UI)
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<telnyx-ai-agent agent-id="assistant-xxx" chat-mode></telnyx-ai-agent>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Toggling chat mode mid-conversation
|
|
68
|
+
|
|
69
|
+
The `chat-mode` attribute is a **watched attribute** — changing it at runtime triggers a full client teardown and recreation. Toggling from voice to chat mode (or vice versa) **destroys the current WebRTC session** and starts a new one:
|
|
70
|
+
|
|
71
|
+
- The active call is hung up
|
|
72
|
+
- The underlying WebRTC connection is disconnected
|
|
73
|
+
- A new `TelnyxAIAgent` client is created with the updated `chatMode` value
|
|
74
|
+
- A fresh connection is established and a new conversation begins
|
|
75
|
+
|
|
76
|
+
This means the transcript and conversation context are **not preserved** across a toggle. If you need to maintain conversation continuity, consider using the `conversation-id` attribute so the AI agent can resume context on the new session:
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<telnyx-ai-agent
|
|
80
|
+
agent-id="assistant-xxx"
|
|
81
|
+
conversation-id="my-conversation-123"
|
|
82
|
+
></telnyx-ai-agent>
|
|
83
|
+
|
|
84
|
+
<script>
|
|
85
|
+
const widget = document.querySelector('telnyx-ai-agent');
|
|
86
|
+
|
|
87
|
+
// Toggle to chat mode — destroys the current session and starts fresh
|
|
88
|
+
widget.setAttribute('chat-mode', '');
|
|
89
|
+
|
|
90
|
+
// Toggle back to voice mode — another full teardown/reconnect
|
|
91
|
+
widget.removeAttribute('chat-mode');
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
After a conversation ends in chat mode, the widget will **not** auto-restart even if `chat-mode` remains set. The user must interact again or you must remove and re-add the element.
|
|
50
96
|
|
|
51
97
|
### Region
|
|
52
98
|
|