retell-sdk 1.0.10 → 1.0.11
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/dist/index.d.ts +1 -1
- package/dist/index.js +29 -29
- package/index.ts +29 -29
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export default class Retell {
|
|
|
2
2
|
private apiKey;
|
|
3
3
|
private ip;
|
|
4
4
|
constructor(apiKey: string, ip?: string);
|
|
5
|
-
NewConversation: (options: any) => any
|
|
5
|
+
NewConversation: (options: any) => Promise<any>;
|
|
6
6
|
CreatAgent: (options: any) => Promise<any>;
|
|
7
7
|
ListAgents: (options: any) => Promise<void>;
|
|
8
8
|
ListConversations: (options: any) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -4,40 +4,40 @@ var WebSocketClient = require("websocket").client;
|
|
|
4
4
|
const axios = require("axios");
|
|
5
5
|
class Retell {
|
|
6
6
|
constructor(apiKey, ip) {
|
|
7
|
-
this.NewConversation = (options) => {
|
|
7
|
+
this.NewConversation = async (options) => {
|
|
8
8
|
if (!options || !options.agentId) {
|
|
9
9
|
console.error("no agent id");
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
var client = new WebSocketClient();
|
|
13
|
-
client.on("connectFailed", function (error) {
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
client.on("connect", function (connection) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
client.connect("ws://" +
|
|
13
|
+
// client.on("connectFailed", function (error: any) {
|
|
14
|
+
// console.log("Connect Error: " + error.toString());
|
|
15
|
+
// });
|
|
16
|
+
// client.on("connect", function (connection: any) {
|
|
17
|
+
// console.log("WebSocket Client Connected");
|
|
18
|
+
// connection.on("error", function (error: any) {
|
|
19
|
+
// console.log("Connection Error: " + error.toString());
|
|
20
|
+
// });
|
|
21
|
+
// connection.on("close", function () {
|
|
22
|
+
// console.log("echo-protocol Connection Closed");
|
|
23
|
+
// });
|
|
24
|
+
// connection.on("message", function (message: any) {
|
|
25
|
+
// if (message.type === "utf8") {
|
|
26
|
+
// console.log("Received: '" + message.utf8Data + "'");
|
|
27
|
+
// }
|
|
28
|
+
// connection.send("12345");
|
|
29
|
+
// });
|
|
30
|
+
// function sendNumber() {
|
|
31
|
+
// if (connection.connected) {
|
|
32
|
+
// var number = Math.round(Math.random() * 0xffffff);
|
|
33
|
+
// // connection.sendUTF(number.toString());
|
|
34
|
+
// connection.sendUTF("12345");
|
|
35
|
+
// setTimeout(sendNumber, 1000);
|
|
36
|
+
// }
|
|
37
|
+
// }
|
|
38
|
+
// sendNumber();
|
|
39
|
+
// });
|
|
40
|
+
await client.connect("ws://" +
|
|
41
41
|
this.ip +
|
|
42
42
|
"/create-socket?" +
|
|
43
43
|
"apiKey=" +
|
package/index.ts
CHANGED
|
@@ -10,42 +10,42 @@ export default class Retell {
|
|
|
10
10
|
this.apiKey = apiKey;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
NewConversation = (options: any) => {
|
|
13
|
+
NewConversation = async (options: any) => {
|
|
14
14
|
if (!options || !options.agentId) {
|
|
15
15
|
console.error("no agent id");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
var client = new WebSocketClient();
|
|
19
|
-
client.on("connectFailed", function (error: any) {
|
|
20
|
-
|
|
21
|
-
});
|
|
19
|
+
// client.on("connectFailed", function (error: any) {
|
|
20
|
+
// console.log("Connect Error: " + error.toString());
|
|
21
|
+
// });
|
|
22
22
|
|
|
23
|
-
client.on("connect", function (connection: any) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
// client.on("connect", function (connection: any) {
|
|
24
|
+
// console.log("WebSocket Client Connected");
|
|
25
|
+
// connection.on("error", function (error: any) {
|
|
26
|
+
// console.log("Connection Error: " + error.toString());
|
|
27
|
+
// });
|
|
28
|
+
// connection.on("close", function () {
|
|
29
|
+
// console.log("echo-protocol Connection Closed");
|
|
30
|
+
// });
|
|
31
|
+
// connection.on("message", function (message: any) {
|
|
32
|
+
// if (message.type === "utf8") {
|
|
33
|
+
// console.log("Received: '" + message.utf8Data + "'");
|
|
34
|
+
// }
|
|
35
|
+
// connection.send("12345");
|
|
36
|
+
// });
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
client.connect(
|
|
38
|
+
// function sendNumber() {
|
|
39
|
+
// if (connection.connected) {
|
|
40
|
+
// var number = Math.round(Math.random() * 0xffffff);
|
|
41
|
+
// // connection.sendUTF(number.toString());
|
|
42
|
+
// connection.sendUTF("12345");
|
|
43
|
+
// setTimeout(sendNumber, 1000);
|
|
44
|
+
// }
|
|
45
|
+
// }
|
|
46
|
+
// sendNumber();
|
|
47
|
+
// });
|
|
48
|
+
await client.connect(
|
|
49
49
|
"ws://" +
|
|
50
50
|
this.ip +
|
|
51
51
|
"/create-socket?" +
|