retell-sdk 1.0.1 → 1.0.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.
- package/dist/index.js +90 -0
- package/index.ts +100 -0
- package/package.json +11 -4
- package/tsconfig.json +13 -0
- package/index.js +0 -4
- package/test-directory/test.js +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var WebSocketClient = require("websocket").client;
|
|
4
|
+
const axios = require("axios");
|
|
5
|
+
class Retell {
|
|
6
|
+
constructor(ip, apiKey) {
|
|
7
|
+
this.NewConversation = () => {
|
|
8
|
+
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://" +
|
|
37
|
+
this.ip +
|
|
38
|
+
"/create-socket?" +
|
|
39
|
+
"apiKey=eff4cfdb-e3d5-476c-8056-7b355a408c25" +
|
|
40
|
+
"&" +
|
|
41
|
+
"agentId=OHRGI1IspUS3Q9SFjaZrcwbN3PwEbC2N", "echo-protocol");
|
|
42
|
+
};
|
|
43
|
+
this.CreatAgent = async (options) => {
|
|
44
|
+
let response = await axios({
|
|
45
|
+
url: "http://" + this.ip + "/create-agent",
|
|
46
|
+
method: "POST",
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-type": "application/json",
|
|
49
|
+
},
|
|
50
|
+
data: {
|
|
51
|
+
apiKey: this.apiKey,
|
|
52
|
+
voiceId: options.voiceId,
|
|
53
|
+
prompt: options.prompt,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
console.log(response.data);
|
|
57
|
+
};
|
|
58
|
+
this.ListAgent = async (options) => {
|
|
59
|
+
let response = await axios({
|
|
60
|
+
url: "http://" + this.ip + "/list-agents",
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: {
|
|
63
|
+
"Content-type": "application/json",
|
|
64
|
+
},
|
|
65
|
+
data: {
|
|
66
|
+
apiKey: this.apiKey,
|
|
67
|
+
agentId: options.agentId,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
console.log(response.data);
|
|
71
|
+
};
|
|
72
|
+
this.ListConversations = async (options) => {
|
|
73
|
+
let response = await axios({
|
|
74
|
+
url: "http://" + this.ip + "/list-conversations",
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: {
|
|
77
|
+
"Content-type": "application/json",
|
|
78
|
+
},
|
|
79
|
+
data: {
|
|
80
|
+
apiKey: this.apiKey,
|
|
81
|
+
eventId: options.eventId,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
console.log(response.data);
|
|
85
|
+
};
|
|
86
|
+
this.ip = ip;
|
|
87
|
+
this.apiKey = apiKey;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.default = Retell;
|
package/index.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var WebSocketClient = require("websocket").client;
|
|
2
|
+
const axios = require("axios");
|
|
3
|
+
|
|
4
|
+
export default class Retell {
|
|
5
|
+
ip;
|
|
6
|
+
apiKey;
|
|
7
|
+
|
|
8
|
+
constructor(ip: string, apiKey: string) {
|
|
9
|
+
this.ip = ip;
|
|
10
|
+
this.apiKey = apiKey;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
NewConversation = () => {
|
|
14
|
+
var client = new WebSocketClient();
|
|
15
|
+
client.on("connectFailed", function (error: any) {
|
|
16
|
+
console.log("Connect Error: " + error.toString());
|
|
17
|
+
});
|
|
18
|
+
|
|
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
|
+
});
|
|
33
|
+
|
|
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(
|
|
45
|
+
"ws://" +
|
|
46
|
+
this.ip +
|
|
47
|
+
"/create-socket?" +
|
|
48
|
+
"apiKey=eff4cfdb-e3d5-476c-8056-7b355a408c25" +
|
|
49
|
+
"&" +
|
|
50
|
+
"agentId=OHRGI1IspUS3Q9SFjaZrcwbN3PwEbC2N",
|
|
51
|
+
"echo-protocol"
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
CreatAgent = async (options: any) => {
|
|
56
|
+
let response = await axios({
|
|
57
|
+
url: "http://" + this.ip + "/create-agent",
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-type": "application/json",
|
|
61
|
+
},
|
|
62
|
+
data: {
|
|
63
|
+
apiKey: this.apiKey,
|
|
64
|
+
voiceId: options.voiceId,
|
|
65
|
+
prompt: options.prompt,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
console.log(response.data);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
ListAgent = async (options: any) => {
|
|
72
|
+
let response = await axios({
|
|
73
|
+
url: "http://" + this.ip + "/list-agents",
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: {
|
|
76
|
+
"Content-type": "application/json",
|
|
77
|
+
},
|
|
78
|
+
data: {
|
|
79
|
+
apiKey: this.apiKey,
|
|
80
|
+
agentId: options.agentId,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
console.log(response.data);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
ListConversations = async (options: any) => {
|
|
87
|
+
let response = await axios({
|
|
88
|
+
url: "http://" + this.ip + "/list-conversations",
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: {
|
|
91
|
+
"Content-type": "application/json",
|
|
92
|
+
},
|
|
93
|
+
data: {
|
|
94
|
+
apiKey: this.apiKey,
|
|
95
|
+
eventId: options.eventId,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
console.log(response.data);
|
|
99
|
+
};
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retell-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "retell sdk",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"build": "tsc && tsc --declaration",
|
|
8
|
+
"start": "npm run build && node dist/index.js",
|
|
7
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
10
|
},
|
|
9
|
-
"author": "",
|
|
11
|
+
"author": "retell",
|
|
10
12
|
"license": "ISC",
|
|
11
13
|
"dependencies": {
|
|
12
|
-
"
|
|
14
|
+
"axios": "^1.6.2",
|
|
15
|
+
"retell-sdk": "^1.0.1",
|
|
16
|
+
"websocket": "^1.0.34"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^20.10.4"
|
|
13
20
|
}
|
|
14
21
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"strictPropertyInitialization": false,
|
|
5
|
+
"strictNullChecks": false,
|
|
6
|
+
"rootDir": "./",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"target": "ES2017",
|
|
9
|
+
"module": "commonjs",
|
|
10
|
+
"esModuleInterop": true
|
|
11
|
+
},
|
|
12
|
+
"exclude": ["node_modules", "server/deprecated"]
|
|
13
|
+
}
|
package/index.js
DELETED
package/test-directory/test.js
DELETED
|
File without changes
|