@activepieces/piece-retune 0.0.1
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/README.md +7 -0
- package/package.json +19 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +65 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/ask-chatbot.d.ts +7 -0
- package/src/lib/actions/ask-chatbot.js +63 -0
- package/src/lib/actions/ask-chatbot.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-retune",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "^1.6.0",
|
|
7
|
+
"dayjs": "1.11.9",
|
|
8
|
+
"is-base64": "1.1.0",
|
|
9
|
+
"lodash": "4.17.21",
|
|
10
|
+
"nanoid": "3.3.6",
|
|
11
|
+
"semver": "7.5.4",
|
|
12
|
+
"@activepieces/pieces-common": "0.2.5",
|
|
13
|
+
"@activepieces/pieces-framework": "0.7.1",
|
|
14
|
+
"@activepieces/shared": "0.10.23",
|
|
15
|
+
"tslib": "1.14.1"
|
|
16
|
+
},
|
|
17
|
+
"main": "./src/index.js",
|
|
18
|
+
"type": "commonjs"
|
|
19
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const retuneAuth: import("@activepieces/pieces-framework").CustomAuthProperty<true, {
|
|
2
|
+
chatId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const retune: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<true, {
|
|
6
|
+
chatId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
+
}>>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retune = exports.retuneAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const ask_chatbot_1 = require("./lib/actions/ask-chatbot");
|
|
8
|
+
const markdownDescription = `
|
|
9
|
+
Follow these instructions to get your re:tune chat ID and API Key:
|
|
10
|
+
|
|
11
|
+
1. Visit the chatbots page: https://retune.so/chats
|
|
12
|
+
2. Once on the website, locate and click on the chatbot you want to use
|
|
13
|
+
3. From the URL, copy the chat ID you want to use;
|
|
14
|
+
e.g from this: https://retune.so/chat/acewocwe-123123-123123-123123/ your chat ID is "acewocwe-123123-123123-123123"
|
|
15
|
+
4. To get the API key, go to https://retune.so/settings
|
|
16
|
+
5. Scroll to the bottom to find "Re:tune API Keys" and copy your key below
|
|
17
|
+
`;
|
|
18
|
+
exports.retuneAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
19
|
+
description: markdownDescription,
|
|
20
|
+
required: true,
|
|
21
|
+
props: {
|
|
22
|
+
// There is no way to programmatically get the user's chatbots, so we have this
|
|
23
|
+
chatId: pieces_framework_1.Property.ShortText({
|
|
24
|
+
displayName: 'Chat ID',
|
|
25
|
+
description: 'The ID of the chat you want to use.',
|
|
26
|
+
required: true
|
|
27
|
+
}),
|
|
28
|
+
apiKey: pieces_framework_1.PieceAuth.SecretText({
|
|
29
|
+
displayName: 'API Key',
|
|
30
|
+
description: 'Your re:tune API key.',
|
|
31
|
+
required: true
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
validate: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
37
|
+
url: `https://retune.so/api/chat/${auth.auth.chatId}/threads`,
|
|
38
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
39
|
+
headers: {
|
|
40
|
+
'X-Workspace-API-Key': auth.auth.apiKey
|
|
41
|
+
},
|
|
42
|
+
body: {}
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
valid: true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
return {
|
|
50
|
+
valid: false,
|
|
51
|
+
error: 'Invalid API key'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
exports.retune = (0, pieces_framework_1.createPiece)({
|
|
57
|
+
displayName: "re:tune",
|
|
58
|
+
auth: exports.retuneAuth,
|
|
59
|
+
minimumSupportedRelease: '0.9.0',
|
|
60
|
+
logoUrl: "https://cdn.activepieces.com/pieces/retune.png",
|
|
61
|
+
authors: ['MoShizzle'],
|
|
62
|
+
actions: [ask_chatbot_1.askChatbot],
|
|
63
|
+
triggers: [],
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/retune/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAkF;AAClF,+DAAqE;AACrE,2DAAuD;AAEvD,MAAM,mBAAmB,GAAG;;;;;;;;;CAS3B,CAAC;AAEW,QAAA,UAAU,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC3C,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACH,+EAA+E;QAC/E,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACvB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YACzB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;SACjB,CAAC;KACL;IAED,QAAQ,EAAE,CAAO,IAAI,EAAE,EAAE;QACrB,IAAI;YACA,MAAM,0BAAU,CAAC,WAAW,CAEzB;gBACC,GAAG,EAAE,8BAA8B,IAAI,CAAC,IAAI,CAAC,MAAM,UAAU;gBAC7D,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,OAAO,EAAE;oBACL,qBAAqB,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM;iBAC1C;gBACD,IAAI,EAAE,EAAE;aACX,CAAC,CAAC;YACH,OAAO;gBACH,KAAK,EAAE,IAAI;aACd,CAAA;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,OAAO;gBACH,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,iBAAiB;aAC3B,CAAA;SACJ;IACL,CAAC,CAAA;CACJ,CAAC,CAAC;AAEU,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAC9B,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,kBAAU;IAChB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,gDAAgD;IACzD,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE,CAAC,wBAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const askChatbot: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<true, {
|
|
2
|
+
chatId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
}>, {
|
|
5
|
+
thread: import("@activepieces/pieces-framework").DropdownProperty<any, true>;
|
|
6
|
+
message: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.askChatbot = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const index_1 = require("../../index");
|
|
7
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
|
+
exports.askChatbot = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: index_1.retuneAuth,
|
|
10
|
+
name: 'ask_chatbot',
|
|
11
|
+
displayName: 'Ask Chatbot',
|
|
12
|
+
description: 'Sends a message to an existing thread with a chatbot.',
|
|
13
|
+
props: {
|
|
14
|
+
thread: pieces_framework_1.Property.Dropdown({
|
|
15
|
+
displayName: 'Thread',
|
|
16
|
+
description: 'The thread you want to send the message to.',
|
|
17
|
+
required: true,
|
|
18
|
+
refreshers: [],
|
|
19
|
+
options: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const options = yield pieces_common_1.httpClient.sendRequest({
|
|
21
|
+
url: `https://retune.so/api/chat/${auth.chatId}/threads`,
|
|
22
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
23
|
+
headers: {
|
|
24
|
+
'X-Workspace-API-Key': auth.apiKey
|
|
25
|
+
},
|
|
26
|
+
body: {}
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
options: options.body['threads'].map((item) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return {
|
|
32
|
+
label: (_a = item.name) !== null && _a !== void 0 ? _a : item.id,
|
|
33
|
+
value: item.id
|
|
34
|
+
};
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
}),
|
|
39
|
+
message: pieces_framework_1.Property.ShortText({
|
|
40
|
+
displayName: 'Message',
|
|
41
|
+
description: 'The message you want to send.',
|
|
42
|
+
required: true
|
|
43
|
+
})
|
|
44
|
+
},
|
|
45
|
+
run({ auth, propsValue }) {
|
|
46
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const { thread, message } = propsValue;
|
|
48
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
49
|
+
url: `https://retune.so/api/chat/${auth.chatId}/response`,
|
|
50
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
51
|
+
headers: {
|
|
52
|
+
'X-Workspace-API-Key': auth.apiKey
|
|
53
|
+
},
|
|
54
|
+
body: {
|
|
55
|
+
threadId: thread,
|
|
56
|
+
input: message
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return response.body.response.value;
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=ask-chatbot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-chatbot.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/retune/src/lib/actions/ask-chatbot.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,uCAAyC;AACzC,+DAAqE;AAExD,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,kBAAU;IAChB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,uDAAuD;IACpE,KAAK,EAAE;QACH,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,CAAO,EAAE,IAAI,EAAE,EAAE,EAAE;gBACxB,MAAM,OAAO,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;oBACzC,GAAG,EAAE,8BAA+B,IAAY,CAAC,MAAM,UAAU;oBACjE,MAAM,EAAE,0BAAU,CAAC,IAAI;oBACvB,OAAO,EAAE;wBACL,qBAAqB,EA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