Skip to content

Commit 8087a5a

Browse files
committed
Added actions
1 parent 49771c3 commit 8087a5a

File tree

7 files changed

+286
-59
lines changed

7 files changed

+286
-59
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-create-chatbot",
5+
name: "Create Chatbot",
6+
description: "Create a chatbot with the specified properties. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotCreate)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chatbotName: {
12+
propDefinition: [
13+
app,
14+
"chatbotName",
15+
],
16+
},
17+
sourceText: {
18+
propDefinition: [
19+
app,
20+
"sourceText",
21+
],
22+
},
23+
urlsToScrape: {
24+
propDefinition: [
25+
app,
26+
"urlsToScrape",
27+
],
28+
},
29+
customBackend: {
30+
propDefinition: [
31+
app,
32+
"customBackend",
33+
],
34+
},
35+
model: {
36+
propDefinition: [
37+
app,
38+
"model",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.createChatbot({
45+
$,
46+
data: {
47+
chatbotName: this.chatbotName,
48+
sourceText: this.sourceText,
49+
urlsToScrape: this.urlsToScrape,
50+
customBackend: this.customBackend,
51+
model: this.model,
52+
},
53+
});
54+
55+
$.export("$summary", `Successfully created Chatbot with ID '${response.chatbotId}'`);
56+
57+
return response;
58+
},
59+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-delete-chatbot",
5+
name: "Delete Chatbot",
6+
description: "Delete a chatbot with the specified ID. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/chatbotDelete)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chatbotId: {
12+
propDefinition: [
13+
app,
14+
"chatbotId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteChatbot({
21+
$,
22+
chatbotId: this.chatbotId,
23+
});
24+
25+
$.export("$summary", `Successfully deleted Chatbot with ID '${this.chatbotId}'`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../chat_data.app.mjs";
2+
3+
export default {
4+
key: "chat_data-get-chatbot-status",
5+
name: "Get Chatbot Status",
6+
description: "Get status of the Chatbot with the specified ID. [See the documentation](https://www.chat-data.com/api-reference#tag/Chatbot-Operations/operation/GetChatbotStatus)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
chatbotId: {
12+
propDefinition: [
13+
app,
14+
"chatbotId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.getChatbotStatus({
21+
$,
22+
chatbotId: this.chatbotId,
23+
});
24+
25+
$.export("$summary", `Successfully retrieved status of the Chatbot with ID '${this.chatbotId}'`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,107 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "chat_data",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
chatbotId: {
9+
type: "string",
10+
label: "Employee ID",
11+
description: "ID of the Employee",
12+
async options() {
13+
const response = await this.getChatbots();
14+
15+
const chatbotIds = response.chatbots;
16+
17+
return chatbotIds.map(({
18+
chatbotId, chatbotName,
19+
}) => ({
20+
value: chatbotId,
21+
label: chatbotName,
22+
}));
23+
},
24+
},
25+
chatbotName: {
26+
type: "string",
27+
label: "Chatbot Name",
28+
description: "Name of the Chatbot",
29+
},
30+
sourceText: {
31+
type: "string",
32+
label: "Source Text",
33+
description: "Text data for the chatbot, subject to character limits based on your plan. Relevant only if the model is custom-data-upload",
34+
optional: true,
35+
},
36+
urlsToScrape: {
37+
type: "string[]",
38+
label: "URLs to Scrape",
39+
description: "A list of URLs is for text content extraction by Chat Data, i.e.: `https://www.chat-data.com`. Relevant only if the model is custom-data-upload",
40+
optional: true,
41+
},
42+
customBackend: {
43+
type: "string",
44+
label: "Custom Backend",
45+
description: "The URL of a customized backend for the chatbot",
46+
optional: true,
47+
},
48+
model: {
49+
type: "string",
50+
label: "Model",
51+
description: "The chatbot defaults to `custom-data-upload` if the model parameter is not provided",
52+
optional: true,
53+
options: constants.CHATBOT_MODELS,
54+
},
55+
},
556
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
57+
_baseUrl() {
58+
return "https://api.chat-data.com/api/v2";
59+
},
60+
async _makeRequest(opts = {}) {
61+
const {
62+
$ = this,
63+
path,
64+
headers,
65+
...otherOpts
66+
} = opts;
67+
return axios($, {
68+
...otherOpts,
69+
url: this._baseUrl() + path,
70+
headers: {
71+
...headers,
72+
Authorization: `Bearer ${this.$auth.api_key}`,
73+
},
74+
});
75+
},
76+
async createChatbot(args = {}) {
77+
return this._makeRequest({
78+
path: "/create-chatbot",
79+
method: "post",
80+
...args,
81+
});
82+
},
83+
async getChatbotStatus({
84+
chatbotId, ...args
85+
}) {
86+
return this._makeRequest({
87+
path: `/chatbot/status/${chatbotId}/`,
88+
...args,
89+
});
90+
},
91+
async deleteChatbot({
92+
chatbotId, ...args
93+
}) {
94+
return this._makeRequest({
95+
path: `/delete-chatbot/${chatbotId}/`,
96+
method: "delete",
97+
...args,
98+
});
99+
},
100+
async getChatbots(args = {}) {
101+
return this._makeRequest({
102+
path: "/get-chatbots",
103+
...args,
104+
});
9105
},
10106
},
11-
};
107+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
CHATBOT_MODELS: [
3+
"custom-data-upload",
4+
"medical-chat-human",
5+
"medical-chat-vet",
6+
"custom-model",
7+
],
8+
};

components/chat_data/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/chat_data",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Chat Data Components",
55
"main": "chat_data.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)