@fonoster/voice 0.55.0 → 0.57.0
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 +196 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ voice
|
|
|
6
6
|
[](https://npmjs.org/package/@fonoster/voice)
|
|
7
7
|
[](https://github.com/fonoster/fonoster/blob/main/package.json)
|
|
8
8
|
|
|
9
|
-
The SDK for Fonoster
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
The session SDK for Fonoster voice applications. For every call, Fonoster's AppBridge
|
|
10
|
+
opens one signed WebSocket **session** to your app; `VoiceServer` accepts it and runs your handler
|
|
11
|
+
with the session. The protocol is in `docs/session-protocol.md`, the full SDK guide in
|
|
12
12
|
`docs/voice-sdk.md`, and runnable examples in `examples/`.
|
|
13
13
|
|
|
14
14
|
* [Installation](#installation)
|
|
@@ -61,3 +61,196 @@ Fields: `callRef`, `appRef`, `from`, `to`, `direction`, `metadata`.
|
|
|
61
61
|
Coming from the gRPC SDK (`(req, res)` handlers, `VoiceResponse`, `stream`, `sgather`, `dial`)?
|
|
62
62
|
Those are gone; see `docs/migrating-to-sessions.md`. `@fonoster/voice/session` resolves to this
|
|
63
63
|
package for one more release.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
<a name="Session"></a>
|
|
67
|
+
|
|
68
|
+
## Session
|
|
69
|
+
One call's session, built on the fonoster.session.v1 messages (voice-sdk S8). Verbs are
|
|
70
|
+
conveniences: each sends one command and resolves on the event that answers it.
|
|
71
|
+
|
|
72
|
+
**Kind**: global class
|
|
73
|
+
|
|
74
|
+
* [Session](#Session)
|
|
75
|
+
* [.midTurn](#Session+midTurn)
|
|
76
|
+
* [.turnExpired](#Session+turnExpired)
|
|
77
|
+
* [.say()](#Session+say)
|
|
78
|
+
* [.stopSay()](#Session+stopSay)
|
|
79
|
+
* [.gather()](#Session+gather)
|
|
80
|
+
* [.listen()](#Session+listen)
|
|
81
|
+
* [.subscribe()](#Session+subscribe)
|
|
82
|
+
* [.transfer()](#Session+transfer)
|
|
83
|
+
* [.completeTransfer()](#Session+completeTransfer)
|
|
84
|
+
* [.handoff()](#Session+handoff)
|
|
85
|
+
* [.hangup()](#Session+hangup)
|
|
86
|
+
* [.note()](#Session+note)
|
|
87
|
+
* [.reportUsage()](#Session+reportUsage)
|
|
88
|
+
* [.answer()](#Session+answer)
|
|
89
|
+
* [.receive()](#Session+receive)
|
|
90
|
+
* [.closed()](#Session+closed)
|
|
91
|
+
* [.command()](#Session+command)
|
|
92
|
+
* [.bargeIn()](#Session+bargeIn)
|
|
93
|
+
|
|
94
|
+
<a name="Session+midTurn"></a>
|
|
95
|
+
|
|
96
|
+
### session.midTurn
|
|
97
|
+
The caller is mid-turn: a turn.user_started with no turn.ended yet.
|
|
98
|
+
|
|
99
|
+
**Kind**: instance property of [<code>Session</code>](#Session)
|
|
100
|
+
<a name="Session+turnExpired"></a>
|
|
101
|
+
|
|
102
|
+
### session.turnExpired
|
|
103
|
+
A gather gave up on the current turn; its late turn.ended is dropped, not buffered.
|
|
104
|
+
|
|
105
|
+
**Kind**: instance property of [<code>Session</code>](#Session)
|
|
106
|
+
<a name="Session+say"></a>
|
|
107
|
+
|
|
108
|
+
### session.say()
|
|
109
|
+
Speaks text, or a stream of text pieces as one utterance, and reports what was heard.
|
|
110
|
+
|
|
111
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
112
|
+
<a name="Session+stopSay"></a>
|
|
113
|
+
|
|
114
|
+
### session.stopSay()
|
|
115
|
+
Cuts the agent off: every pending say and play resolves as interrupted.
|
|
116
|
+
|
|
117
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
118
|
+
<a name="Session+gather"></a>
|
|
119
|
+
|
|
120
|
+
### session.gather()
|
|
121
|
+
Waits for speech (turn.ended) or digits (dtmf), whichever comes first.
|
|
122
|
+
|
|
123
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
124
|
+
<a name="Session+listen"></a>
|
|
125
|
+
|
|
126
|
+
### session.listen()
|
|
127
|
+
Starts listening or changes how AppBridge listens (`listen.update`): recognition language,
|
|
128
|
+
hints, and the turn-taking patience knob (`low`, `normal` or `high`).
|
|
129
|
+
|
|
130
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
131
|
+
<a name="Session+subscribe"></a>
|
|
132
|
+
|
|
133
|
+
### session.subscribe()
|
|
134
|
+
Requests opt-in events: "turn.estimate", "transcript.partial".
|
|
135
|
+
|
|
136
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
137
|
+
<a name="Session+transfer"></a>
|
|
138
|
+
|
|
139
|
+
### session.transfer()
|
|
140
|
+
Transfers the call; resolves when AppBridge ends the session with reason transfer.
|
|
141
|
+
|
|
142
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
143
|
+
<a name="Session+completeTransfer"></a>
|
|
144
|
+
|
|
145
|
+
### session.completeTransfer()
|
|
146
|
+
Completes the pending warm transfer: the agent leaves, caller and new party stay. Resolves
|
|
147
|
+
when the session ends with reason transfer; rejects with a SessionError
|
|
148
|
+
(`transfer_not_answered`) when the new party has not answered yet, which leaves the transfer
|
|
149
|
+
pending: wait for the `transfer.answered` event and call it again.
|
|
150
|
+
|
|
151
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
152
|
+
<a name="Session+handoff"></a>
|
|
153
|
+
|
|
154
|
+
### session.handoff()
|
|
155
|
+
Hands the call to another app with a payload; resolves when this session ends.
|
|
156
|
+
|
|
157
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
158
|
+
<a name="Session+hangup"></a>
|
|
159
|
+
|
|
160
|
+
### session.hangup()
|
|
161
|
+
Hangs up; resolves when the session ends. `failure` ends the call as failed in the call record
|
|
162
|
+
(@internal: reserved for Fonoster's own apps (Autopilot); AppBridge ignores it from others).
|
|
163
|
+
|
|
164
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
165
|
+
<a name="Session+note"></a>
|
|
166
|
+
|
|
167
|
+
### session.note()
|
|
168
|
+
Adds a note to the call record (record.note).
|
|
169
|
+
|
|
170
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
171
|
+
**Internal**: Reserved for Fonoster's own apps (Autopilot); not part of the public SDK and may change.
|
|
172
|
+
<a name="Session+reportUsage"></a>
|
|
173
|
+
|
|
174
|
+
### session.reportUsage()
|
|
175
|
+
Adds model token usage to the call (usage.report, add-usage-metering).
|
|
176
|
+
|
|
177
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
178
|
+
**Internal**: Reserved for Fonoster's own Autopilot; AppBridge refuses it from other apps.
|
|
179
|
+
<a name="Session+answer"></a>
|
|
180
|
+
|
|
181
|
+
### session.answer()
|
|
182
|
+
Resolves at once: AppBridge answers the call on connect (voice-sdk S2).
|
|
183
|
+
|
|
184
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
185
|
+
<a name="Session+receive"></a>
|
|
186
|
+
|
|
187
|
+
### session.receive()
|
|
188
|
+
Feeds one frame from the socket.
|
|
189
|
+
|
|
190
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
191
|
+
<a name="Session+closed"></a>
|
|
192
|
+
|
|
193
|
+
### session.closed()
|
|
194
|
+
The socket closed.
|
|
195
|
+
|
|
196
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
197
|
+
<a name="Session+command"></a>
|
|
198
|
+
|
|
199
|
+
### session.command()
|
|
200
|
+
Sends a command whose only answer is a possible error (logged as a session error).
|
|
201
|
+
|
|
202
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
203
|
+
<a name="Session+bargeIn"></a>
|
|
204
|
+
|
|
205
|
+
### session.bargeIn()
|
|
206
|
+
The app owns interruption (appbridge B22): when the caller starts talking over an interruptible
|
|
207
|
+
say or play, the SDK cuts it off with clear; a non-interruptible one keeps playing.
|
|
208
|
+
|
|
209
|
+
**Kind**: instance method of [<code>Session</code>](#Session)
|
|
210
|
+
|
|
211
|
+
<a name="VoiceServer"></a>
|
|
212
|
+
|
|
213
|
+
## VoiceServer
|
|
214
|
+
Accepts AppBridge sessions over WebSocket and runs the handler once per session
|
|
215
|
+
(voice-sdk, "VoiceServer accepts AppBridge sessions over WebSocket").
|
|
216
|
+
|
|
217
|
+
**Kind**: global class
|
|
218
|
+
|
|
219
|
+
* [VoiceServer](#VoiceServer)
|
|
220
|
+
* [.listen()](#VoiceServer+listen)
|
|
221
|
+
* [.attach()](#VoiceServer+attach)
|
|
222
|
+
* [.handleUpgrade()](#VoiceServer+handleUpgrade)
|
|
223
|
+
|
|
224
|
+
<a name="VoiceServer+listen"></a>
|
|
225
|
+
|
|
226
|
+
### voiceServer.listen()
|
|
227
|
+
Starts a standalone server. Resolves once it is listening.
|
|
228
|
+
|
|
229
|
+
**Kind**: instance method of [<code>VoiceServer</code>](#VoiceServer)
|
|
230
|
+
<a name="VoiceServer+attach"></a>
|
|
231
|
+
|
|
232
|
+
### voiceServer.attach()
|
|
233
|
+
Mounts on an existing HTTP server (Express included): sessions arrive on `path`.
|
|
234
|
+
|
|
235
|
+
**Kind**: instance method of [<code>VoiceServer</code>](#VoiceServer)
|
|
236
|
+
<a name="VoiceServer+handleUpgrade"></a>
|
|
237
|
+
|
|
238
|
+
### voiceServer.handleUpgrade()
|
|
239
|
+
Handles one upgrade request: verifies the signature, then runs a session.
|
|
240
|
+
|
|
241
|
+
**Kind**: instance method of [<code>VoiceServer</code>](#VoiceServer)
|
|
242
|
+
|
|
243
|
+
<a name="SessionError"></a>
|
|
244
|
+
|
|
245
|
+
## SessionError
|
|
246
|
+
A command failed: AppBridge sent `error` with `relatesTo` set to the command's id.
|
|
247
|
+
|
|
248
|
+
**Kind**: global class
|
|
249
|
+
|
|
250
|
+
<a name="SessionEndedError"></a>
|
|
251
|
+
|
|
252
|
+
## SessionEndedError
|
|
253
|
+
The session ended (or a fatal error arrived) while the command was pending.
|
|
254
|
+
|
|
255
|
+
**Kind**: global class
|
|
256
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/voice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "Session SDK for Fonoster voice applications",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"generate:readme": "fonoster-readme"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fonoster/common": "^0.
|
|
21
|
-
"@fonoster/logger": "^0.
|
|
20
|
+
"@fonoster/common": "^0.57.0",
|
|
21
|
+
"@fonoster/logger": "^0.57.0",
|
|
22
22
|
"ws": "^8.18.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "68e8138df7e82c705f70d1f7293530959f3c9d3c",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@fonoster/conformance": "^0.
|
|
41
|
+
"@fonoster/conformance": "^0.57.0"
|
|
42
42
|
}
|
|
43
43
|
}
|