@signalwire/sdk 2.0.0 → 2.0.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/package.json +1 -1
- package/src/AgentBase.ts +113 -4
- package/src/AgentServer.ts +31 -4
- package/src/ContextBuilder.ts +33 -2
- package/src/DataMap.ts +30 -2
- package/src/FunctionResult.ts +40 -3
- package/src/PomBuilder.ts +29 -1
- package/src/SWMLService.ts +38 -6
- package/src/ServerlessAdapter.ts +20 -1
- package/src/SwmlBuilder.ts +26 -1
- package/src/TypeInference.ts +27 -9
- package/src/WebService.ts +27 -5
- package/src/index.ts +73 -7
- package/src/livewire/index.ts +343 -41
- package/src/prefabs/ConciergeAgent.ts +22 -0
- package/src/prefabs/FAQBotAgent.ts +32 -1
- package/src/prefabs/InfoGathererAgent.ts +41 -1
- package/src/prefabs/ReceptionistAgent.ts +30 -1
- package/src/prefabs/SurveyAgent.ts +26 -1
- package/src/relay/Action.ts +174 -6
- package/src/relay/Call.ts +459 -43
- package/src/relay/Deferred.ts +27 -4
- package/src/relay/Message.ts +54 -3
- package/src/relay/RelayClient.ts +167 -18
- package/src/relay/RelayError.ts +7 -1
- package/src/relay/RelayEvent.ts +52 -0
- package/src/rest/HttpClient.ts +61 -0
- package/src/rest/RestError.ts +14 -0
- package/src/rest/base/BaseResource.ts +16 -3
- package/src/rest/base/CrudResource.ts +52 -5
- package/src/rest/base/CrudWithAddresses.ts +12 -1
- package/src/rest/index.ts +30 -0
- package/src/rest/namespaces/addresses.ts +33 -1
- package/src/rest/namespaces/calling.ts +348 -1
- package/src/rest/namespaces/chat.ts +13 -2
- package/src/rest/namespaces/compat.ts +469 -9
- package/src/rest/namespaces/datasphere.ts +48 -5
- package/src/rest/namespaces/fabric.ts +197 -2
- package/src/rest/namespaces/imported-numbers.ts +13 -2
- package/src/rest/namespaces/logs.ts +68 -1
- package/src/rest/namespaces/lookup.ts +19 -2
- package/src/rest/namespaces/mfa.ts +35 -4
- package/src/rest/namespaces/number-groups.ts +35 -5
- package/src/rest/namespaces/phone-numbers.ts +35 -3
- package/src/rest/namespaces/project.ts +30 -1
- package/src/rest/namespaces/pubsub.ts +13 -2
- package/src/rest/namespaces/queues.ts +29 -4
- package/src/rest/namespaces/recordings.ts +26 -1
- package/src/rest/namespaces/registry.ts +100 -1
- package/src/rest/namespaces/short-codes.ts +27 -1
- package/src/rest/namespaces/sip-profile.ts +18 -3
- package/src/rest/namespaces/verified-callers.ts +22 -3
- package/src/rest/namespaces/video.ts +168 -1
- package/src/rest/pagination.ts +22 -8
- package/src/skills/SkillBase.ts +37 -2
- package/src/skills/SkillManager.ts +8 -4
- package/src/skills/builtin/api_ninjas_trivia.ts +5 -0
- package/src/skills/builtin/ask_claude.ts +5 -0
- package/src/skills/builtin/claude_skills.ts +5 -0
- package/src/skills/builtin/custom_skills.ts +15 -0
- package/src/skills/builtin/datasphere.ts +9 -0
- package/src/skills/builtin/datasphere_serverless.ts +8 -0
- package/src/skills/builtin/datetime.ts +7 -0
- package/src/skills/builtin/google_maps.ts +5 -0
- package/src/skills/builtin/info_gatherer.ts +10 -0
- package/src/skills/builtin/joke.ts +5 -0
- package/src/skills/builtin/math.ts +7 -0
- package/src/skills/builtin/mcp_gateway.ts +8 -0
- package/src/skills/builtin/native_vector_search.ts +9 -0
- package/src/skills/builtin/play_background_file.ts +9 -0
- package/src/skills/builtin/spider.ts +5 -0
- package/src/skills/builtin/swml_transfer.ts +10 -0
- package/src/skills/builtin/weather_api.ts +7 -0
- package/src/skills/builtin/web_search.ts +9 -0
- package/src/skills/builtin/wikipedia_search.ts +5 -0
|
@@ -9,7 +9,35 @@
|
|
|
9
9
|
import type { HttpClient } from '../HttpClient.js';
|
|
10
10
|
import { BaseResource } from '../base/BaseResource.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* REST call control — all 37 commands dispatched via a single POST endpoint.
|
|
14
|
+
*
|
|
15
|
+
* Access via `client.calling.*`. Every method issues one command against a live
|
|
16
|
+
* call by ID and returns the platform's JSON response.
|
|
17
|
+
*
|
|
18
|
+
* Every command method shares the same shape:
|
|
19
|
+
*
|
|
20
|
+
* - First argument (when present) is the target call's ID.
|
|
21
|
+
* - Second argument is a platform-shaped `params` object — see the
|
|
22
|
+
* [Calling API reference](https://developer.signalwire.com/rest/signalwire-rest/endpoints/calling/)
|
|
23
|
+
* for the fields each command accepts.
|
|
24
|
+
* - The method returns the JSON-decoded platform response.
|
|
25
|
+
* - Throws {@link RestError} on any non-2xx HTTP response.
|
|
26
|
+
*
|
|
27
|
+
* @example Play audio on an active call
|
|
28
|
+
* ```ts
|
|
29
|
+
* await client.calling.play(callId, {
|
|
30
|
+
* play: [{ type: 'audio', url: 'https://cdn.example.com/hold.mp3' }],
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Start and stop recording
|
|
35
|
+
* ```ts
|
|
36
|
+
* const rec = await client.calling.record(callId, { record: { audio: {} } });
|
|
37
|
+
* // ... later ...
|
|
38
|
+
* await client.calling.recordStop(callId, { control_id: rec.control_id });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
13
41
|
export class CallingNamespace extends BaseResource {
|
|
14
42
|
constructor(http: HttpClient) {
|
|
15
43
|
super(http, '/api/calling/calls');
|
|
@@ -24,163 +52,482 @@ export class CallingNamespace extends BaseResource {
|
|
|
24
52
|
}
|
|
25
53
|
|
|
26
54
|
// Call lifecycle
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Place an outbound call.
|
|
58
|
+
*
|
|
59
|
+
* @param params - Platform-shaped dial parameters (from, to, timeout, etc.).
|
|
60
|
+
* Defaults to `{}`.
|
|
61
|
+
* @returns The dial command response, typically containing a new `call_id`.
|
|
62
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
63
|
+
*/
|
|
27
64
|
async dial(params: any = {}): Promise<any> {
|
|
28
65
|
return this._execute('dial', undefined, params);
|
|
29
66
|
}
|
|
30
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Update properties on an in-progress call.
|
|
70
|
+
*
|
|
71
|
+
* @param params - Platform-shaped update parameters. Defaults to `{}`.
|
|
72
|
+
* @returns The platform's response.
|
|
73
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
74
|
+
*/
|
|
31
75
|
async update(params: any = {}): Promise<any> {
|
|
32
76
|
return this._execute('update', undefined, params);
|
|
33
77
|
}
|
|
34
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Gracefully end a call.
|
|
81
|
+
*
|
|
82
|
+
* @param callId - Target call's ID.
|
|
83
|
+
* @param params - Platform-shaped end parameters. Defaults to `{}`.
|
|
84
|
+
* @returns The platform's response.
|
|
85
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
86
|
+
*/
|
|
35
87
|
async end(callId: string, params: any = {}): Promise<any> {
|
|
36
88
|
return this._execute('calling.end', callId, params);
|
|
37
89
|
}
|
|
38
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Transfer a call to another destination.
|
|
93
|
+
*
|
|
94
|
+
* @param callId - Target call's ID.
|
|
95
|
+
* @param params - Platform-shaped transfer parameters (`to`, `from`, etc.).
|
|
96
|
+
* Defaults to `{}`.
|
|
97
|
+
* @returns The platform's response.
|
|
98
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
99
|
+
*/
|
|
39
100
|
async transfer(callId: string, params: any = {}): Promise<any> {
|
|
40
101
|
return this._execute('calling.transfer', callId, params);
|
|
41
102
|
}
|
|
42
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Drop one leg from a call without ending the other.
|
|
106
|
+
*
|
|
107
|
+
* @param callId - Target call's ID.
|
|
108
|
+
* @param params - Platform-shaped disconnect parameters. Defaults to `{}`.
|
|
109
|
+
* @returns The platform's response.
|
|
110
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
111
|
+
*/
|
|
43
112
|
async disconnect(callId: string, params: any = {}): Promise<any> {
|
|
44
113
|
return this._execute('calling.disconnect', callId, params);
|
|
45
114
|
}
|
|
46
115
|
|
|
47
116
|
// Play
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Start media playback on a call.
|
|
120
|
+
*
|
|
121
|
+
* @param callId - Target call's ID.
|
|
122
|
+
* @param params - Playback parameters — see `Play` action schema. Defaults to `{}`.
|
|
123
|
+
* @returns The play command response, containing a `control_id` used to
|
|
124
|
+
* pause / resume / stop the playback later.
|
|
125
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
126
|
+
*/
|
|
48
127
|
async play(callId: string, params: any = {}): Promise<any> {
|
|
49
128
|
return this._execute('calling.play', callId, params);
|
|
50
129
|
}
|
|
51
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Pause active playback.
|
|
133
|
+
*
|
|
134
|
+
* @param callId - Target call's ID.
|
|
135
|
+
* @param params - Must include `control_id` from the matching `play()` call.
|
|
136
|
+
* Defaults to `{}`.
|
|
137
|
+
* @returns The platform's response.
|
|
138
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
139
|
+
*/
|
|
52
140
|
async playPause(callId: string, params: any = {}): Promise<any> {
|
|
53
141
|
return this._execute('calling.play.pause', callId, params);
|
|
54
142
|
}
|
|
55
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Resume paused playback.
|
|
146
|
+
*
|
|
147
|
+
* @param callId - Target call's ID.
|
|
148
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
149
|
+
* @returns The platform's response.
|
|
150
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
151
|
+
*/
|
|
56
152
|
async playResume(callId: string, params: any = {}): Promise<any> {
|
|
57
153
|
return this._execute('calling.play.resume', callId, params);
|
|
58
154
|
}
|
|
59
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Stop active playback.
|
|
158
|
+
*
|
|
159
|
+
* @param callId - Target call's ID.
|
|
160
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
161
|
+
* @returns The platform's response.
|
|
162
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
163
|
+
*/
|
|
60
164
|
async playStop(callId: string, params: any = {}): Promise<any> {
|
|
61
165
|
return this._execute('calling.play.stop', callId, params);
|
|
62
166
|
}
|
|
63
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Adjust the playback volume.
|
|
170
|
+
*
|
|
171
|
+
* @param callId - Target call's ID.
|
|
172
|
+
* @param params - `control_id` plus `volume` (integer dB). Defaults to `{}`.
|
|
173
|
+
* @returns The platform's response.
|
|
174
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
175
|
+
*/
|
|
64
176
|
async playVolume(callId: string, params: any = {}): Promise<any> {
|
|
65
177
|
return this._execute('calling.play.volume', callId, params);
|
|
66
178
|
}
|
|
67
179
|
|
|
68
180
|
// Record
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Start recording a call.
|
|
184
|
+
*
|
|
185
|
+
* @param callId - Target call's ID.
|
|
186
|
+
* @param params - Recording parameters (`record` config, callbacks, etc.).
|
|
187
|
+
* Defaults to `{}`.
|
|
188
|
+
* @returns The record command response containing a `control_id`.
|
|
189
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
190
|
+
*/
|
|
69
191
|
async record(callId: string, params: any = {}): Promise<any> {
|
|
70
192
|
return this._execute('calling.record', callId, params);
|
|
71
193
|
}
|
|
72
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Pause an active recording.
|
|
197
|
+
*
|
|
198
|
+
* @param callId - Target call's ID.
|
|
199
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
200
|
+
* @returns The platform's response.
|
|
201
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
202
|
+
*/
|
|
73
203
|
async recordPause(callId: string, params: any = {}): Promise<any> {
|
|
74
204
|
return this._execute('calling.record.pause', callId, params);
|
|
75
205
|
}
|
|
76
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Resume a paused recording.
|
|
209
|
+
*
|
|
210
|
+
* @param callId - Target call's ID.
|
|
211
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
212
|
+
* @returns The platform's response.
|
|
213
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
214
|
+
*/
|
|
77
215
|
async recordResume(callId: string, params: any = {}): Promise<any> {
|
|
78
216
|
return this._execute('calling.record.resume', callId, params);
|
|
79
217
|
}
|
|
80
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Stop and finalise a recording.
|
|
221
|
+
*
|
|
222
|
+
* @param callId - Target call's ID.
|
|
223
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
224
|
+
* @returns The final recording metadata.
|
|
225
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
226
|
+
*/
|
|
81
227
|
async recordStop(callId: string, params: any = {}): Promise<any> {
|
|
82
228
|
return this._execute('calling.record.stop', callId, params);
|
|
83
229
|
}
|
|
84
230
|
|
|
85
231
|
// Collect
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Collect DTMF / speech input from the caller.
|
|
235
|
+
*
|
|
236
|
+
* @param callId - Target call's ID.
|
|
237
|
+
* @param params - Collect configuration (`digits`, `speech`, timeouts, etc.).
|
|
238
|
+
* Defaults to `{}`.
|
|
239
|
+
* @returns The collect command response containing a `control_id`.
|
|
240
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
241
|
+
*/
|
|
86
242
|
async collect(callId: string, params: any = {}): Promise<any> {
|
|
87
243
|
return this._execute('calling.collect', callId, params);
|
|
88
244
|
}
|
|
89
245
|
|
|
246
|
+
/**
|
|
247
|
+
* Stop an in-progress collect operation.
|
|
248
|
+
*
|
|
249
|
+
* @param callId - Target call's ID.
|
|
250
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
251
|
+
* @returns The platform's response.
|
|
252
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
253
|
+
*/
|
|
90
254
|
async collectStop(callId: string, params: any = {}): Promise<any> {
|
|
91
255
|
return this._execute('calling.collect.stop', callId, params);
|
|
92
256
|
}
|
|
93
257
|
|
|
258
|
+
/**
|
|
259
|
+
* Start input timers for a collect operation (useful when `initial_timeout`
|
|
260
|
+
* should be reset after media finishes playing).
|
|
261
|
+
*
|
|
262
|
+
* @param callId - Target call's ID.
|
|
263
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
264
|
+
* @returns The platform's response.
|
|
265
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
266
|
+
*/
|
|
94
267
|
async collectStartInputTimers(callId: string, params: any = {}): Promise<any> {
|
|
95
268
|
return this._execute('calling.collect.start_input_timers', callId, params);
|
|
96
269
|
}
|
|
97
270
|
|
|
98
271
|
// Detect
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Run answering-machine / fax / DTMF detection.
|
|
275
|
+
*
|
|
276
|
+
* @param callId - Target call's ID.
|
|
277
|
+
* @param params - Detect configuration. Defaults to `{}`.
|
|
278
|
+
* @returns The detect command response containing a `control_id`.
|
|
279
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
280
|
+
*/
|
|
99
281
|
async detect(callId: string, params: any = {}): Promise<any> {
|
|
100
282
|
return this._execute('calling.detect', callId, params);
|
|
101
283
|
}
|
|
102
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Stop an active detect operation.
|
|
287
|
+
*
|
|
288
|
+
* @param callId - Target call's ID.
|
|
289
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
290
|
+
* @returns The platform's response.
|
|
291
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
292
|
+
*/
|
|
103
293
|
async detectStop(callId: string, params: any = {}): Promise<any> {
|
|
104
294
|
return this._execute('calling.detect.stop', callId, params);
|
|
105
295
|
}
|
|
106
296
|
|
|
107
297
|
// Tap
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Start a media tap (mirror audio to an external URI).
|
|
301
|
+
*
|
|
302
|
+
* @param callId - Target call's ID.
|
|
303
|
+
* @param params - Tap configuration (`uri`, `direction`, `codec`, etc.).
|
|
304
|
+
* Defaults to `{}`.
|
|
305
|
+
* @returns The tap command response containing a `control_id`.
|
|
306
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
307
|
+
*/
|
|
108
308
|
async tap(callId: string, params: any = {}): Promise<any> {
|
|
109
309
|
return this._execute('calling.tap', callId, params);
|
|
110
310
|
}
|
|
111
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Stop an active media tap.
|
|
314
|
+
*
|
|
315
|
+
* @param callId - Target call's ID.
|
|
316
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
317
|
+
* @returns The platform's response.
|
|
318
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
319
|
+
*/
|
|
112
320
|
async tapStop(callId: string, params: any = {}): Promise<any> {
|
|
113
321
|
return this._execute('calling.tap.stop', callId, params);
|
|
114
322
|
}
|
|
115
323
|
|
|
116
324
|
// Stream
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Start an outbound media stream (typically to a WebSocket endpoint).
|
|
328
|
+
*
|
|
329
|
+
* @param callId - Target call's ID.
|
|
330
|
+
* @param params - Stream configuration. Defaults to `{}`.
|
|
331
|
+
* @returns The stream command response containing a `control_id`.
|
|
332
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
333
|
+
*/
|
|
117
334
|
async stream(callId: string, params: any = {}): Promise<any> {
|
|
118
335
|
return this._execute('calling.stream', callId, params);
|
|
119
336
|
}
|
|
120
337
|
|
|
338
|
+
/**
|
|
339
|
+
* Stop an outbound media stream.
|
|
340
|
+
*
|
|
341
|
+
* @param callId - Target call's ID.
|
|
342
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
343
|
+
* @returns The platform's response.
|
|
344
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
345
|
+
*/
|
|
121
346
|
async streamStop(callId: string, params: any = {}): Promise<any> {
|
|
122
347
|
return this._execute('calling.stream.stop', callId, params);
|
|
123
348
|
}
|
|
124
349
|
|
|
125
350
|
// Denoise
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Enable noise reduction on the call.
|
|
354
|
+
*
|
|
355
|
+
* @param callId - Target call's ID.
|
|
356
|
+
* @param params - Denoise configuration. Defaults to `{}`.
|
|
357
|
+
* @returns The platform's response.
|
|
358
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
359
|
+
*/
|
|
126
360
|
async denoise(callId: string, params: any = {}): Promise<any> {
|
|
127
361
|
return this._execute('calling.denoise', callId, params);
|
|
128
362
|
}
|
|
129
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Disable noise reduction.
|
|
366
|
+
*
|
|
367
|
+
* @param callId - Target call's ID.
|
|
368
|
+
* @param params - Platform-shaped parameters. Defaults to `{}`.
|
|
369
|
+
* @returns The platform's response.
|
|
370
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
371
|
+
*/
|
|
130
372
|
async denoiseStop(callId: string, params: any = {}): Promise<any> {
|
|
131
373
|
return this._execute('calling.denoise.stop', callId, params);
|
|
132
374
|
}
|
|
133
375
|
|
|
134
376
|
// Transcribe
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Start real-time transcription on the call.
|
|
380
|
+
*
|
|
381
|
+
* @param callId - Target call's ID.
|
|
382
|
+
* @param params - Transcription configuration. Defaults to `{}`.
|
|
383
|
+
* @returns The transcribe command response containing a `control_id`.
|
|
384
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
385
|
+
*/
|
|
135
386
|
async transcribe(callId: string, params: any = {}): Promise<any> {
|
|
136
387
|
return this._execute('calling.transcribe', callId, params);
|
|
137
388
|
}
|
|
138
389
|
|
|
390
|
+
/**
|
|
391
|
+
* Stop real-time transcription.
|
|
392
|
+
*
|
|
393
|
+
* @param callId - Target call's ID.
|
|
394
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
395
|
+
* @returns The final transcription metadata.
|
|
396
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
397
|
+
*/
|
|
139
398
|
async transcribeStop(callId: string, params: any = {}): Promise<any> {
|
|
140
399
|
return this._execute('calling.transcribe.stop', callId, params);
|
|
141
400
|
}
|
|
142
401
|
|
|
143
402
|
// AI
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Send a message into an active AI agent session.
|
|
406
|
+
*
|
|
407
|
+
* @param callId - Target call's ID.
|
|
408
|
+
* @param params - AI message payload. Defaults to `{}`.
|
|
409
|
+
* @returns The platform's response.
|
|
410
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
411
|
+
*/
|
|
144
412
|
async aiMessage(callId: string, params: any = {}): Promise<any> {
|
|
145
413
|
return this._execute('calling.ai_message', callId, params);
|
|
146
414
|
}
|
|
147
415
|
|
|
416
|
+
/**
|
|
417
|
+
* Put the AI session on hold (pause turn-taking).
|
|
418
|
+
*
|
|
419
|
+
* @param callId - Target call's ID.
|
|
420
|
+
* @param params - Platform-shaped parameters. Defaults to `{}`.
|
|
421
|
+
* @returns The platform's response.
|
|
422
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
423
|
+
*/
|
|
148
424
|
async aiHold(callId: string, params: any = {}): Promise<any> {
|
|
149
425
|
return this._execute('calling.ai_hold', callId, params);
|
|
150
426
|
}
|
|
151
427
|
|
|
428
|
+
/**
|
|
429
|
+
* Resume an AI session that was on hold.
|
|
430
|
+
*
|
|
431
|
+
* @param callId - Target call's ID.
|
|
432
|
+
* @param params - Platform-shaped parameters. Defaults to `{}`.
|
|
433
|
+
* @returns The platform's response.
|
|
434
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
435
|
+
*/
|
|
152
436
|
async aiUnhold(callId: string, params: any = {}): Promise<any> {
|
|
153
437
|
return this._execute('calling.ai_unhold', callId, params);
|
|
154
438
|
}
|
|
155
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Terminate the active AI session on a call.
|
|
442
|
+
*
|
|
443
|
+
* @param callId - Target call's ID.
|
|
444
|
+
* @param params - Platform-shaped parameters. Defaults to `{}`.
|
|
445
|
+
* @returns The platform's response.
|
|
446
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
447
|
+
*/
|
|
156
448
|
async aiStop(callId: string, params: any = {}): Promise<any> {
|
|
157
449
|
return this._execute('calling.ai.stop', callId, params);
|
|
158
450
|
}
|
|
159
451
|
|
|
160
452
|
// Live transcribe / translate
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Start live transcription that emits events as speech is recognised.
|
|
456
|
+
*
|
|
457
|
+
* @param callId - Target call's ID.
|
|
458
|
+
* @param params - Configuration (languages, model, partials, etc.).
|
|
459
|
+
* Defaults to `{}`.
|
|
460
|
+
* @returns The platform's response.
|
|
461
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
462
|
+
*/
|
|
161
463
|
async liveTranscribe(callId: string, params: any = {}): Promise<any> {
|
|
162
464
|
return this._execute('calling.live_transcribe', callId, params);
|
|
163
465
|
}
|
|
164
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Start live translation between two languages.
|
|
469
|
+
*
|
|
470
|
+
* @param callId - Target call's ID.
|
|
471
|
+
* @param params - Configuration (`source_lang`, `target_lang`, etc.).
|
|
472
|
+
* Defaults to `{}`.
|
|
473
|
+
* @returns The platform's response.
|
|
474
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
475
|
+
*/
|
|
165
476
|
async liveTranslate(callId: string, params: any = {}): Promise<any> {
|
|
166
477
|
return this._execute('calling.live_translate', callId, params);
|
|
167
478
|
}
|
|
168
479
|
|
|
169
480
|
// Fax
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Stop a send-fax operation mid-stream.
|
|
484
|
+
*
|
|
485
|
+
* @param callId - Target call's ID.
|
|
486
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
487
|
+
* @returns The platform's response.
|
|
488
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
489
|
+
*/
|
|
170
490
|
async sendFaxStop(callId: string, params: any = {}): Promise<any> {
|
|
171
491
|
return this._execute('calling.send_fax.stop', callId, params);
|
|
172
492
|
}
|
|
173
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Stop a receive-fax operation mid-stream.
|
|
496
|
+
*
|
|
497
|
+
* @param callId - Target call's ID.
|
|
498
|
+
* @param params - Must include `control_id`. Defaults to `{}`.
|
|
499
|
+
* @returns The platform's response.
|
|
500
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
501
|
+
*/
|
|
174
502
|
async receiveFaxStop(callId: string, params: any = {}): Promise<any> {
|
|
175
503
|
return this._execute('calling.receive_fax.stop', callId, params);
|
|
176
504
|
}
|
|
177
505
|
|
|
178
506
|
// SIP
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Send a SIP REFER to transfer a call outside the platform.
|
|
510
|
+
*
|
|
511
|
+
* @param callId - Target call's ID.
|
|
512
|
+
* @param params - REFER parameters (`refer_to`, etc.). Defaults to `{}`.
|
|
513
|
+
* @returns The platform's response.
|
|
514
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
515
|
+
*/
|
|
179
516
|
async refer(callId: string, params: any = {}): Promise<any> {
|
|
180
517
|
return this._execute('calling.refer', callId, params);
|
|
181
518
|
}
|
|
182
519
|
|
|
183
520
|
// Custom events
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Emit a custom user event on the call for your webhooks.
|
|
524
|
+
*
|
|
525
|
+
* @param callId - Target call's ID.
|
|
526
|
+
* @param params - Event payload — freeform data delivered to your webhook.
|
|
527
|
+
* Defaults to `{}`.
|
|
528
|
+
* @returns The platform's response.
|
|
529
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
530
|
+
*/
|
|
184
531
|
async userEvent(callId: string, params: any = {}): Promise<any> {
|
|
185
532
|
return this._execute('calling.user_event', callId, params);
|
|
186
533
|
}
|
|
@@ -7,13 +7,24 @@
|
|
|
7
7
|
import type { HttpClient } from '../HttpClient.js';
|
|
8
8
|
import { BaseResource } from '../base/BaseResource.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Chat token generation.
|
|
12
|
+
*
|
|
13
|
+
* Access via `client.chat.*`. Issues short-lived tokens that end-user clients
|
|
14
|
+
* use to join chat channels.
|
|
15
|
+
*/
|
|
11
16
|
export class ChatResource extends BaseResource {
|
|
12
17
|
constructor(http: HttpClient) {
|
|
13
18
|
super(http, '/api/chat/tokens');
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Generate a short-lived Chat token.
|
|
23
|
+
*
|
|
24
|
+
* @param body - Token payload (e.g. `{ room_name, user_name, permissions }`).
|
|
25
|
+
* @returns The token record, typically `{ token: "eyJ..." }`.
|
|
26
|
+
* @throws {RestError} On any non-2xx HTTP response.
|
|
27
|
+
*/
|
|
17
28
|
async createToken(body: any): Promise<any> {
|
|
18
29
|
return this._http.post(this._basePath, body);
|
|
19
30
|
}
|