retell-sdk 2.2.1 → 2.2.3

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.
Files changed (71) hide show
  1. package/README.md +3 -433
  2. package/example.d.ts +2 -0
  3. package/example.d.ts.map +1 -0
  4. package/example.js +96 -0
  5. package/example.js.map +1 -0
  6. package/models/components/agent.d.ts +193 -24
  7. package/models/components/agent.d.ts.map +1 -1
  8. package/models/components/agent.js +189 -27
  9. package/models/components/agent.js.map +1 -1
  10. package/models/components/index.d.ts +0 -1
  11. package/models/components/index.d.ts.map +1 -1
  12. package/models/components/index.js +0 -1
  13. package/models/components/index.js.map +1 -1
  14. package/models/operations/createagent.d.ts +14 -34
  15. package/models/operations/createagent.d.ts.map +1 -1
  16. package/models/operations/createagent.js +12 -32
  17. package/models/operations/createagent.js.map +1 -1
  18. package/models/operations/createphonecall.d.ts +12 -6
  19. package/models/operations/createphonecall.d.ts.map +1 -1
  20. package/models/operations/createphonecall.js +8 -8
  21. package/models/operations/createphonecall.js.map +1 -1
  22. package/models/operations/createphonenumber.d.ts +1 -1
  23. package/models/operations/createwebcall.d.ts +16 -0
  24. package/models/operations/createwebcall.d.ts.map +1 -0
  25. package/models/operations/createwebcall.js +3 -0
  26. package/models/operations/createwebcall.js.map +1 -0
  27. package/models/operations/index.d.ts +1 -0
  28. package/models/operations/index.d.ts.map +1 -1
  29. package/models/operations/index.js +1 -0
  30. package/models/operations/index.js.map +1 -1
  31. package/models/operations/listagents.d.ts +3 -3
  32. package/models/operations/listagents.d.ts.map +1 -1
  33. package/models/operations/listagents.js +4 -4
  34. package/models/operations/listagents.js.map +1 -1
  35. package/models/operations/listcalls.d.ts +3 -3
  36. package/models/operations/listcalls.d.ts.map +1 -1
  37. package/models/operations/listcalls.js +4 -4
  38. package/models/operations/listcalls.js.map +1 -1
  39. package/models/operations/listphonenumbers.d.ts +3 -3
  40. package/models/operations/listphonenumbers.d.ts.map +1 -1
  41. package/models/operations/listphonenumbers.js +4 -4
  42. package/models/operations/listphonenumbers.js.map +1 -1
  43. package/models/operations/updateagent.d.ts +42 -3
  44. package/models/operations/updateagent.d.ts.map +1 -1
  45. package/models/operations/updateagent.js +43 -5
  46. package/models/operations/updateagent.js.map +1 -1
  47. package/package.json +1 -1
  48. package/sdk/liveClient.d.ts +2 -4
  49. package/sdk/liveClient.d.ts.map +1 -1
  50. package/sdk/liveClient.js +9 -5
  51. package/sdk/liveClient.js.map +1 -1
  52. package/sdk/sdk.d.ts +2 -6
  53. package/sdk/sdk.d.ts.map +1 -1
  54. package/sdk/sdk.js +10 -10
  55. package/sdk/sdk.js.map +1 -1
  56. package/src/example.ts +102 -0
  57. package/src/models/components/agent.ts +382 -52
  58. package/src/models/components/index.ts +0 -1
  59. package/src/models/operations/createagent.ts +30 -66
  60. package/src/models/operations/createphonecall.ts +20 -14
  61. package/src/models/operations/createphonenumber.ts +1 -1
  62. package/src/models/operations/createwebcall.ts +16 -0
  63. package/src/models/operations/index.ts +1 -0
  64. package/src/models/operations/listagents.ts +7 -7
  65. package/src/models/operations/listcalls.ts +7 -7
  66. package/src/models/operations/listphonenumbers.ts +7 -7
  67. package/src/models/operations/updateagent.ts +87 -7
  68. package/src/sdk/liveClient.ts +11 -8
  69. package/src/sdk/sdk.ts +10 -17
  70. package/docs/sdks/retellclient/README.md +0 -713
  71. package/src/models/components/agentnodefaultnorequired.ts +0 -121
package/README.md CHANGED
@@ -6,442 +6,12 @@
6
6
  </a>
7
7
  </div>
8
8
 
9
- <!-- Start SDK Installation [installation] -->
10
9
  ## SDK Installation
11
10
 
12
- ### NPM
13
-
14
11
  ```bash
15
- npm i retell-sdk
16
- ```
17
-
18
- <!-- End SDK Installation [installation] -->
19
-
20
- <!-- Start SDK Example Usage [usage] -->
21
- ## SDK Example Usage
22
-
23
- ### Create a new voice AI agent
24
-
25
- Create a new agent
26
-
27
- ```typescript
28
- import { RetellClient } from "retell-sdk";
29
-
30
- async function run() {
31
- const sdk = new RetellClient({
32
- apiKey: "YOUR_API_KEY",
33
- });
34
-
35
- const res = await sdk.createAgent({
36
- agentName: "Jarvis",
37
- beginMessage: "Hello there, how can I help you?",
38
- enableBeginMessage: true,
39
- enableEndCall: true,
40
- enableEndMessage: false,
41
- endMessage: "Hope you have a good day, goodbye.",
42
- prompt: "You are a marketing assistant. You help come up with creative content ideas and content like marketing emails, blog posts, tweets, ad copy and product descriptions. You respond concisely, with filler words in it.",
43
- voiceId: "11labs-Ryan",
44
- });
45
-
46
- if (res?.statusCode !== 200) {
47
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
48
- }
49
-
50
- // handle response
51
- }
52
-
53
- run();
54
-
55
- ```
56
-
57
- ### Create an outbound phone call
58
-
59
- Initiate an outbound phone call.
60
-
61
- ```typescript
62
- import { RetellClient } from "retell-sdk";
63
-
64
- async function run() {
65
- const sdk = new RetellClient({
66
- apiKey: "YOUR_API_KEY",
67
- });
68
-
69
- const res = await sdk.createPhoneCall({
70
- agentPromptParams: [
71
- {
72
- name: "username",
73
- value: "Adam",
74
- },
75
- ],
76
- phoneNumber: {
77
- from: "+14159095857",
78
- to: "+14159095858",
79
- },
80
- });
81
-
82
- if (res?.statusCode !== 200) {
83
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
84
- }
85
-
86
- // handle response
87
- }
88
-
89
- run();
90
-
91
- ```
92
-
93
- ### Create a web call
94
-
95
- Initiate a web call.
96
-
97
- ```typescript
98
- import { RetellClient } from "retell-sdk";
99
- // Import websocket if not running in browser
100
-
101
- async function run() {
102
- const sdk = new RetellClient({
103
- apiKey: "YOUR_API_KEY",
104
- });
105
-
106
- const liveClient = await sdk.createWebCall({
107
- agentId: "YOUR_AGENT_ID",
108
- sampleRate: 24000,
109
- agentPromptParams: [
110
- {
111
- name: "username",
112
- value: "Adam",
113
- },
114
- ],
115
- });
116
-
117
- liveClient.on("audio", (audio: Uint8Array) => {
118
- // Handle audio here
119
- });
120
- liveClient.on("close", (event) => {
121
- // Handle close here
122
- console.log(event.code);
123
- });
124
- }
125
-
126
- run();
127
-
128
- ```
129
-
130
- ### Create a new phone number
131
-
132
- Create a new phone number
133
-
134
- ```typescript
135
- import { RetellClient } from "retell-sdk";
136
-
137
- async function run() {
138
- const sdk = new RetellClient({
139
- apiKey: "YOUR_API_KEY",
140
- });
141
-
142
- const res = await sdk.createPhoneNumber({
143
- agentId: "YOUR_AGENT_ID",
144
- areaCode: 415,
145
- });
146
-
147
- if (res?.statusCode !== 200) {
148
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
149
- }
150
-
151
- // handle response
152
- }
153
-
154
- run();
155
-
156
- ```
157
-
158
- ### Delete an existing agent
159
-
160
- Delete an existing agent
161
-
162
- ```typescript
163
- import { RetellClient } from "retell-sdk";
164
-
165
- async function run() {
166
- const sdk = new RetellClient({
167
- apiKey: "YOUR_API_KEY",
168
- });
169
-
170
- const agentId = "YOUR_AGENT_ID";
171
-
172
- const res = await sdk.deleteAgent(agentId);
173
-
174
- if (res?.statusCode !== 200) {
175
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
176
- }
177
-
178
- // handle response
179
- }
180
-
181
- run();
182
-
183
- ```
184
-
185
- ### Delete a specific phone number
186
-
187
- Delete a specific phone number
188
-
189
- ```typescript
190
- import { RetellClient } from "retell-sdk";
191
-
192
- async function run() {
193
- const sdk = new RetellClient({
194
- apiKey: "YOUR_API_KEY",
195
- });
196
-
197
- const phoneNumber = "string";
198
-
199
- const res = await sdk.deletePhoneNumber(phoneNumber);
200
-
201
- if (res?.statusCode !== 200) {
202
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
203
- }
204
-
205
- // handle response
206
- }
207
-
208
- run();
209
-
210
- ```
211
-
212
- ### Retrieve details of an agent
213
-
214
- Retrieve details of a specific agent
215
-
216
- ```typescript
217
- import { RetellClient } from "retell-sdk";
218
-
219
- async function run() {
220
- const sdk = new RetellClient({
221
- apiKey: "YOUR_API_KEY",
222
- });
223
-
224
- const agentId = "16b980523634a6dc504898cda492e939";
225
-
226
- const res = await sdk.getAgent(agentId);
227
-
228
- if (res?.statusCode !== 200) {
229
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
230
- }
231
-
232
- // handle response
233
- }
234
-
235
- run();
236
-
237
- ```
238
-
239
- ### Retrieve a on-going or finished call
240
-
241
- Retrieve details of a specific call
242
-
243
- ```typescript
244
- import { RetellClient } from "retell-sdk";
245
-
246
- async function run() {
247
- const sdk = new RetellClient({
248
- apiKey: "YOUR_API_KEY",
249
- });
250
-
251
- const callId = "119c3f8e47135a29e65947eeb34cf12d";
252
-
253
- const res = await sdk.getCall(callId);
254
-
255
- if (res?.statusCode !== 200) {
256
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
257
- }
258
-
259
- // handle response
260
- }
261
-
262
- run();
263
-
264
- ```
265
-
266
- ### Retrieve info about a specific number
267
-
268
- Retrieve info about a specific number
269
-
270
- ```typescript
271
- import { RetellClient } from "retell-sdk";
272
-
273
- async function run() {
274
- const sdk = new RetellClient({
275
- apiKey: "YOUR_API_KEY",
276
- });
277
-
278
- const phoneNumber = "+14159095857";
279
-
280
- const res = await sdk.getPhoneNumber(phoneNumber);
281
-
282
- if (res?.statusCode !== 200) {
283
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
284
- }
285
-
286
- // handle response
287
- }
288
-
289
- run();
290
-
291
- ```
292
-
293
- ### List all agents
294
-
295
- List all agents
296
-
297
- ```typescript
298
- import { RetellClient } from "retell-sdk";
299
-
300
- async function run() {
301
- const sdk = new RetellClient({
302
- apiKey: "YOUR_API_KEY",
303
- });
304
-
305
- const res = await sdk.listAgents();
306
-
307
- if (res?.statusCode !== 200) {
308
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
309
- }
310
-
311
- // handle response
312
- }
313
-
314
- run();
315
-
316
- ```
317
-
318
- ### List all web or phone calls
319
-
320
- Retrieve call details
321
-
322
- ```typescript
323
- import { RetellClient } from "retell-sdk";
324
- import {} from "retell-sdk/models";
325
- import { SortOrder } from "retell-sdk/models/operations";
326
-
327
- async function run() {
328
- const sdk = new RetellClient({
329
- apiKey: "YOUR_API_KEY",
330
- });
331
-
332
- const filterCriteria = {
333
- afterEndTimestamp: 1703302428800,
334
- afterStartTimestamp: 1703302407300,
335
- agentId: ["YOUR_AGENT_ID"],
336
- beforeEndTimestamp: 1703302428899,
337
- beforeStartTimestamp: 1703302407399,
338
- callType: [CallType.InboundPhoneCall, CallType.OutboundPhoneCall],
339
- };
340
- const limit = 666195;
341
- const sortOrder = SortOrder.Descending;
342
-
343
- const res = await sdk.listCalls(filterCriteria, limit, sortOrder);
344
-
345
- if (res?.statusCode !== 200) {
346
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
347
- }
348
-
349
- // handle response
350
- }
351
-
352
- run();
353
-
12
+ npm install retell-sdk
354
13
  ```
355
14
 
356
- ### List all purchased and active phone numbers
357
-
358
- List all purchased and active phone numbers
359
-
360
- ```typescript
361
- import { RetellClient } from "retell-sdk";
362
-
363
- async function run() {
364
- const sdk = new RetellClient({
365
- apiKey: "YOUR_API_KEY",
366
- });
367
-
368
- const res = await sdk.listPhoneNumbers();
369
-
370
- if (res?.statusCode !== 200) {
371
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
372
- }
373
-
374
- // handle response
375
- }
376
-
377
- run();
378
-
379
- ```
380
-
381
- ### Update an existing agent
382
-
383
- Update an existing agent
384
-
385
- ```typescript
386
- import { RetellClient } from "retell-sdk";
15
+ ## Use SDK
387
16
 
388
- async function run() {
389
- const sdk = new RetellClient({
390
- apiKey: "YOUR_API_KEY",
391
- });
392
-
393
- const agentNoDefaultNoRequired = {
394
- agentName: "Jarvis",
395
- beginMessage: "Hello there, how can I help you.",
396
- enableBeginMessage: true,
397
- enableEndCall: true,
398
- enableEndMessage: false,
399
- endMessage: "Hope you have a good day, goodbye.",
400
- prompt: "You are a marketing assistant. You help come up with creative content ideas and content like marketing emails, blog posts, tweets, ad copy and product descriptions. You respond concisely, with filler words in it.",
401
- voiceId: "11labs-Ryan",
402
- };
403
- const agentId = "16b980523634a6dc504898cda492e939";
404
-
405
- const res = await sdk.updateAgent(agentNoDefaultNoRequired, agentId);
406
-
407
- if (res?.statusCode !== 200) {
408
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
409
- }
410
-
411
- // handle response
412
- }
413
-
414
- run();
415
-
416
- ```
417
-
418
- ### Update an existing phone number
419
-
420
- Update an existing phone number
421
-
422
- ```typescript
423
- import { RetellClient } from "retell-sdk";
424
-
425
- async function run() {
426
- const sdk = new RetellClient({
427
- apiKey: "YOUR_API_KEY",
428
- });
429
-
430
- const requestBody = {
431
- agentId: "YOUR_AGENT_ID",
432
- };
433
- const phoneNumber = "+14159095857";
434
-
435
- const res = await sdk.updatePhoneAgent(requestBody, phoneNumber);
436
-
437
- if (res?.statusCode !== 200) {
438
- throw new Error("Unexpected status code: " + res?.statusCode || "-");
439
- }
440
-
441
- // handle response
442
- }
443
-
444
- run();
445
-
446
- ```
447
- <!-- End SDK Example Usage [usage] -->
17
+ Check out [Retell AI API Documentation](https://docs.re-tell.ai/guide/sdk) for using this SDK.
package/example.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["src/example.ts"],"names":[],"mappings":""}
package/example.js ADDED
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sdk_1 = require("./sdk");
4
+ // import { CallType } from "./models/components";
5
+ // import { CallType, SortOrder } from "./models/operations";
6
+ const retell = new sdk_1.RetellClient({
7
+ // Find the key in dashboard
8
+ apiKey: "765a6620-affa-4137-a3dc-cae97cfc65cd",
9
+ serverURL: "http://localhost:3002"
10
+ });
11
+ async function main() {
12
+ // const res = await retell.createAgent({
13
+ // agentName: "testfunction",
14
+ // llmSetting: {
15
+ // provider: "retell",
16
+ // prompt: "test prompt",
17
+ // },
18
+ // voiceId: "11labs-Ryan",
19
+ // interactionSetting: {
20
+ // enableBeginMessage: true,
21
+ // beginMessage: "Hello there, how can I help you?",
22
+ // enableEndCall: true,
23
+ // enableEndMessage: false,
24
+ // endMessage: "Hope you have a good day, goodbye.",
25
+ // },
26
+ // functions: [{
27
+ // url: "http://localhost:3002/get-weather",
28
+ // description: "Get the current weather in a given location.",
29
+ // name: "get_current_weather",
30
+ // parameters: {
31
+ // type: "object",
32
+ // properties: {
33
+ // location: {
34
+ // type: "string",
35
+ // description: "The city and state, e.g. San Francisco, CA"
36
+ // },
37
+ // unit: {
38
+ // type: "string",
39
+ // enum: ["celsius", "fahrenheit"]
40
+ // }
41
+ // },
42
+ // required: ["location"]
43
+ // }
44
+ // }]
45
+ // });
46
+ // console.log(res.agent);
47
+ const res = await retell.getAgent("e2c8d51a88b935f3ca09170d9c248e8e");
48
+ console.log(res.agent);
49
+ // const res = await retell.listAgents();
50
+ // console.log(res.agents);
51
+ // const agent = await retell.updateAgent({
52
+ // agentName: "new name",
53
+ // interactionSetting: {
54
+ // enableEndCall: true,
55
+ // endMessage: "bye"
56
+ // },
57
+ // }, '5790c196cd6b7728de819c3de444d3b5');
58
+ // console.log(agent.agent);
59
+ // const res = await retell.deleteAgent('5790c196cd6b7728de819c3de444d3b5');
60
+ // console.log(res.statusCode)
61
+ // const res = await retell.createPhoneNumber({
62
+ // agentId: "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
63
+ // areaCode: 415,
64
+ // });
65
+ // res.phoneNumber
66
+ // const res = await retell.deletePhoneNumber("+14159095857");
67
+ // console.log(res.statusCode)
68
+ // const res = await retell.getCall("e208e53fe334b42a21bdf065f5b121e1");
69
+ // console.log(res.callDetail);
70
+ // const newPhoneNumber = await retell.createPhoneNumber({
71
+ // agentId: "5790c196cd6b7728de819c3de444d3b5", // Required
72
+ // // areaCode: 415, // Optional, default is 213
73
+ // });
74
+ // console.log("phone number: ", newPhoneNumber);
75
+ // const ongoingCall = await retell.createPhoneCall({
76
+ // phoneNumber: {
77
+ // from: "+12138954697", // Phone number you created
78
+ // to: "+12137134981",
79
+ // },
80
+ // });
81
+ // console.log("phone call: ", ongoingCall);
82
+ // const filterCriteria = {
83
+ // // afterEndTimestamp: 1703302428800,
84
+ // // afterStartTimestamp: 1703302407300,
85
+ // // agentId: ["oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"],
86
+ // // beforeEndTimestamp: 1703302428899,
87
+ // // beforeStartTimestamp: 1703302407399,
88
+ // callType: [CallType.InboundPhoneCall, CallType.OutboundPhoneCall],
89
+ // };
90
+ // const limit = 1;
91
+ // const sortOrder = SortOrder.Descending;
92
+ // const res = await retell.listCalls(filterCriteria, limit, sortOrder);
93
+ // console.log(res)
94
+ }
95
+ main();
96
+ //# sourceMappingURL=example.js.map
package/example.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["src/example.ts"],"names":[],"mappings":";;AAAA,+BAAqC;AACrC,kDAAkD;AAClD,6DAA6D;AAE7D,MAAM,MAAM,GAAG,IAAI,kBAAY,CAAC;IAC5B,4BAA4B;IAC5B,MAAM,EAAE,sCAAsC;IAC9C,SAAS,EAAE,uBAAuB;CACnC,CAAC,CAAC;AAEL,KAAK,UAAU,IAAI;IACf,yCAAyC;IACzC,iCAAiC;IACjC,oBAAoB;IACpB,8BAA8B;IAC9B,iCAAiC;IACjC,SAAS;IACT,8BAA8B;IAC9B,4BAA4B;IAC5B,oCAAoC;IACpC,4DAA4D;IAC5D,+BAA+B;IAC/B,mCAAmC;IACnC,4DAA4D;IAC5D,SAAS;IACT,oBAAoB;IACpB,kDAAkD;IAClD,qEAAqE;IACrE,qCAAqC;IACrC,sBAAsB;IACtB,0BAA0B;IAC1B,wBAAwB;IACxB,wBAAwB;IACxB,8BAA8B;IAC9B,wEAAwE;IACxE,eAAe;IACf,oBAAoB;IACpB,8BAA8B;IAC9B,8CAA8C;IAC9C,cAAc;IACd,aAAa;IACb,iCAAiC;IACjC,UAAU;IACV,SAAS;IACT,MAAM;IACN,0BAA0B;IAE1B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,kCAAkC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,yCAAyC;IACzC,2BAA2B;IAC3B,2CAA2C;IAC3C,6BAA6B;IAC7B,4BAA4B;IAC5B,+BAA+B;IAC/B,4BAA4B;IAC5B,WAAW;IACX,0CAA0C;IAC1C,4BAA4B;IAC5B,4EAA4E;IAC5E,8BAA8B;IAC9B,+CAA+C;IAC/C,mDAAmD;IACnD,qBAAqB;IACrB,MAAM;IACN,kBAAkB;IAClB,8DAA8D;IAC9D,8BAA8B;IAE9B,wEAAwE;IAExE,+BAA+B;IAE/B,0DAA0D;IAC1D,+DAA+D;IAC/D,oDAAoD;IACpD,QAAQ;IACR,mDAAmD;IAEnD,qDAAqD;IACrD,qBAAqB;IACrB,0DAA0D;IAC1D,4BAA4B;IAC5B,SAAS;IACT,QAAQ;IACR,8CAA8C;IAC9C,2BAA2B;IAC3B,2CAA2C;IAC3C,6CAA6C;IAC7C,wDAAwD;IACxD,4CAA4C;IAC5C,8CAA8C;IAC9C,yEAAyE;IACzE,KAAK;IACL,mBAAmB;IACnB,0CAA0C;IAE1C,wEAAwE;IACxE,mBAAmB;AACvB,CAAC;AAED,IAAI,EAAE,CAAA"}