retell-sdk 1.0.9 → 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 CHANGED
@@ -2,8 +2,8 @@ export default class Retell {
2
2
  private apiKey;
3
3
  private ip;
4
4
  constructor(apiKey: string, ip?: string);
5
- NewConversation: () => void;
5
+ NewConversation: (options: any) => Promise<any>;
6
6
  CreatAgent: (options: any) => Promise<any>;
7
- ListAgent: (options: any) => Promise<void>;
7
+ ListAgents: (options: any) => Promise<void>;
8
8
  ListConversations: (options: any) => Promise<void>;
9
9
  }
package/dist/index.js CHANGED
@@ -4,41 +4,48 @@ var WebSocketClient = require("websocket").client;
4
4
  const axios = require("axios");
5
5
  class Retell {
6
6
  constructor(apiKey, ip) {
7
- this.NewConversation = () => {
7
+ this.NewConversation = async (options) => {
8
+ if (!options || !options.agentId) {
9
+ console.error("no agent id");
10
+ return;
11
+ }
8
12
  var client = new WebSocketClient();
9
- client.on("connectFailed", function (error) {
10
- console.log("Connect Error: " + error.toString());
11
- });
12
- client.on("connect", function (connection) {
13
- console.log("WebSocket Client Connected");
14
- connection.on("error", function (error) {
15
- console.log("Connection Error: " + error.toString());
16
- });
17
- connection.on("close", function () {
18
- console.log("echo-protocol Connection Closed");
19
- });
20
- connection.on("message", function (message) {
21
- if (message.type === "utf8") {
22
- console.log("Received: '" + message.utf8Data + "'");
23
- }
24
- connection.send("12345");
25
- });
26
- function sendNumber() {
27
- if (connection.connected) {
28
- var number = Math.round(Math.random() * 0xffffff);
29
- // connection.sendUTF(number.toString());
30
- connection.sendUTF("12345");
31
- setTimeout(sendNumber, 1000);
32
- }
33
- }
34
- sendNumber();
35
- });
36
- 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://" +
37
41
  this.ip +
38
42
  "/create-socket?" +
39
- "apiKey=eff4cfdb-e3d5-476c-8056-7b355a408c25" +
43
+ "apiKey=" +
44
+ this.apiKey +
40
45
  "&" +
41
- "agentId=OHRGI1IspUS3Q9SFjaZrcwbN3PwEbC2N", "echo-protocol");
46
+ "agentId=" +
47
+ options.agentId, "echo-protocol");
48
+ return client;
42
49
  };
43
50
  this.CreatAgent = async (options) => {
44
51
  if (!options || !options.voiceId) {
@@ -64,11 +71,7 @@ class Retell {
64
71
  console.log(response.data);
65
72
  return response.data;
66
73
  };
67
- this.ListAgent = async (options) => {
68
- if (!options || !options.agentId) {
69
- console.error("no agentId");
70
- return;
71
- }
74
+ this.ListAgents = async (options) => {
72
75
  let response = await axios({
73
76
  url: "http://" + this.ip + "/list-agents",
74
77
  method: "POST",
@@ -83,10 +86,6 @@ class Retell {
83
86
  console.log(response.data);
84
87
  };
85
88
  this.ListConversations = async (options) => {
86
- if (!options || !options.agentId) {
87
- console.error("no agentId");
88
- return;
89
- }
90
89
  let response = await axios({
91
90
  url: "http://" + this.ip + "/list-conversations",
92
91
  method: "POST",
@@ -100,7 +99,7 @@ class Retell {
100
99
  });
101
100
  console.log(response.data);
102
101
  };
103
- this.ip = ip !== null && ip !== void 0 ? ip : "localhost:3000";
102
+ this.ip = ip !== null && ip !== void 0 ? ip : "localhost:3001";
104
103
  this.apiKey = apiKey;
105
104
  }
106
105
  }
package/index.ts CHANGED
@@ -6,50 +6,57 @@ export default class Retell {
6
6
  private ip: string;
7
7
 
8
8
  constructor(apiKey: string, ip?: string) {
9
- this.ip = ip ?? "localhost:3000";
9
+ this.ip = ip ?? "localhost:3001";
10
10
  this.apiKey = apiKey;
11
11
  }
12
12
 
13
- NewConversation = () => {
13
+ NewConversation = async (options: any) => {
14
+ if (!options || !options.agentId) {
15
+ console.error("no agent id");
16
+ return;
17
+ }
14
18
  var client = new WebSocketClient();
15
- client.on("connectFailed", function (error: any) {
16
- console.log("Connect Error: " + error.toString());
17
- });
19
+ // client.on("connectFailed", function (error: any) {
20
+ // console.log("Connect Error: " + error.toString());
21
+ // });
18
22
 
19
- client.on("connect", function (connection: any) {
20
- console.log("WebSocket Client Connected");
21
- connection.on("error", function (error: any) {
22
- console.log("Connection Error: " + error.toString());
23
- });
24
- connection.on("close", function () {
25
- console.log("echo-protocol Connection Closed");
26
- });
27
- connection.on("message", function (message: any) {
28
- if (message.type === "utf8") {
29
- console.log("Received: '" + message.utf8Data + "'");
30
- }
31
- connection.send("12345");
32
- });
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
+ // });
33
37
 
34
- function sendNumber() {
35
- if (connection.connected) {
36
- var number = Math.round(Math.random() * 0xffffff);
37
- // connection.sendUTF(number.toString());
38
- connection.sendUTF("12345");
39
- setTimeout(sendNumber, 1000);
40
- }
41
- }
42
- sendNumber();
43
- });
44
- 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(
45
49
  "ws://" +
46
50
  this.ip +
47
51
  "/create-socket?" +
48
- "apiKey=eff4cfdb-e3d5-476c-8056-7b355a408c25" +
52
+ "apiKey=" +
53
+ this.apiKey +
49
54
  "&" +
50
- "agentId=OHRGI1IspUS3Q9SFjaZrcwbN3PwEbC2N",
55
+ "agentId=" +
56
+ options.agentId,
51
57
  "echo-protocol"
52
58
  );
59
+ return client;
53
60
  };
54
61
 
55
62
  CreatAgent = async (options: any) => {
@@ -76,11 +83,7 @@ export default class Retell {
76
83
  return response.data;
77
84
  };
78
85
 
79
- ListAgent = async (options: any) => {
80
- if (!options || !options.agentId) {
81
- console.error("no agentId");
82
- return;
83
- }
86
+ ListAgents = async (options: any) => {
84
87
  let response = await axios({
85
88
  url: "http://" + this.ip + "/list-agents",
86
89
  method: "POST",
@@ -96,10 +99,6 @@ export default class Retell {
96
99
  };
97
100
 
98
101
  ListConversations = async (options: any) => {
99
- if (!options || !options.agentId) {
100
- console.error("no agentId");
101
- return;
102
- }
103
102
  let response = await axios({
104
103
  url: "http://" + this.ip + "/list-conversations",
105
104
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retell-sdk",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "retell sdk",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",