@activepieces/piece-chatsistant 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 ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-chatsistant
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-chatsistant` to build the library.
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@activepieces/piece-chatsistant",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@sinclair/typebox": "0.34.11",
9
+ "axios": "1.8.3",
10
+ "axios-retry": "4.4.1",
11
+ "deepmerge-ts": "7.1.0",
12
+ "mime-types": "2.1.35",
13
+ "nanoid": "3.3.8",
14
+ "semver": "7.6.0",
15
+ "socket.io-client": "4.8.1",
16
+ "tslib": "^2.3.0",
17
+ "zod": "3.25.76",
18
+ "@activepieces/pieces-common": "0.8.1",
19
+ "@activepieces/pieces-framework": "0.20.2",
20
+ "@activepieces/shared": "0.25.2"
21
+ },
22
+ "resolutions": {
23
+ "rollup": "npm:@rollup/wasm-node"
24
+ }
25
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const chatsistant: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chatsistant = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const send_message_1 = require("./lib/actions/send-message");
7
+ const form_submission_1 = require("./lib/triggers/form-submission");
8
+ const auth_1 = require("./lib/common/auth");
9
+ const pieces_common_1 = require("@activepieces/pieces-common");
10
+ exports.chatsistant = (0, pieces_framework_1.createPiece)({
11
+ displayName: 'Chatsistant',
12
+ auth: auth_1.chatsistantAuth,
13
+ minimumSupportedRelease: '0.36.1',
14
+ logoUrl: 'https://cdn.activepieces.com/pieces/chatsistant.png',
15
+ authors: ['sanket-a11y'],
16
+ actions: [
17
+ send_message_1.sendMessage,
18
+ (0, pieces_common_1.createCustomApiCallAction)({
19
+ baseUrl: () => 'https://app.chatsistant.com/api/v1',
20
+ auth: auth_1.chatsistantAuth,
21
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
22
+ return {
23
+ Authorization: `Bearer ${auth}`,
24
+ };
25
+ }),
26
+ }),
27
+ ],
28
+ triggers: [form_submission_1.formSubmission],
29
+ });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/chatsistant/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,6DAAyD;AACzD,oEAAgE;AAChE,4CAAoD;AACpD,+DAAwE;AAE3D,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACrC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,sBAAe;IACrB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,qDAAqD;IAC9D,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,OAAO,EAAE;QACP,0BAAW;QACX,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,oCAAoC;YACnD,IAAI,EAAE,sBAAe;YACrB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,aAAa,EAAE,UAAU,IAAI,EAAE;iBAChC,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,gCAAc,CAAC;CAC3B,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const sendMessage: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ chatbot_uuid: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ query: import("@activepieces/pieces-framework").LongTextProperty<true>;
4
+ session_uuid: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ }>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendMessage = 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 auth_1 = require("../common/auth");
8
+ const client_1 = require("../common/client");
9
+ exports.sendMessage = (0, pieces_framework_1.createAction)({
10
+ auth: auth_1.chatsistantAuth,
11
+ name: 'sendMessage',
12
+ displayName: 'Send Message',
13
+ description: 'Send a message to a chatbot session',
14
+ props: {
15
+ chatbot_uuid: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Chatbot UUID',
17
+ description: 'The UUID of the chatbot to send the message to',
18
+ required: true,
19
+ }),
20
+ query: pieces_framework_1.Property.LongText({
21
+ displayName: 'Message',
22
+ description: 'The message to send to the chatbot',
23
+ required: true,
24
+ }),
25
+ session_uuid: pieces_framework_1.Property.ShortText({
26
+ displayName: 'Session UUID',
27
+ description: 'The UUID of the session to send the message to',
28
+ required: false,
29
+ }),
30
+ },
31
+ run(_a) {
32
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
33
+ const { chatbot_uuid, session_uuid, query } = propsValue;
34
+ if (!session_uuid) {
35
+ const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, `/chatbot/${chatbot_uuid}/session/create`, {});
36
+ const session_id = response.uuid;
37
+ const messageResponse = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, `/session/${session_id}/message/stream`, {
38
+ query,
39
+ });
40
+ return messageResponse;
41
+ }
42
+ else {
43
+ const response = yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.POST, `/session/${session_uuid}/message/stream`, {
44
+ query,
45
+ });
46
+ return response;
47
+ }
48
+ });
49
+ },
50
+ });
51
+ //# sourceMappingURL=send-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-message.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chatsistant/src/lib/actions/send-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,yCAAiD;AACjD,6CAA+C;AAElC,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,qCAAqC;IAClD,KAAK,EAAE;QACL,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,UAAU,CAAC;YAEzD,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAI,EACJ,0BAAU,CAAC,IAAI,EACf,YAAY,YAAY,iBAAiB,EACzC,EAAE,CACH,CAAC;gBACF,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC;gBACjC,MAAM,eAAe,GAAG,MAAM,IAAA,oBAAW,EACvC,IAAI,EACJ,0BAAU,CAAC,IAAI,EACf,YAAY,UAAU,iBAAiB,EACvC;oBACE,KAAK;iBACN,CACF,CAAC;gBACF,OAAO,eAAe,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAI,EACJ,0BAAU,CAAC,IAAI,EACf,YAAY,YAAY,iBAAiB,EACzC;oBACE,KAAK;iBACN,CACF,CAAC;gBAEF,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const chatsistantAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chatsistantAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const client_1 = require("./client");
8
+ exports.chatsistantAuth = pieces_framework_1.PieceAuth.SecretText({
9
+ displayName: 'Chatsistant API Key',
10
+ description: `
11
+ To get your API Key:
12
+
13
+ 1. Go to [Chatsistant platform](https://app.chatsistant.com/)
14
+ 2. Sign up or log in to your account
15
+ 3. Click on the "Account" menu in the navigation bar
16
+ 4. Navigate to the "API Keys" section
17
+ 5. Click "Generate new key"
18
+ 6. Enter a description for your key and click "Generate"
19
+ 7. Copy and save your API key securely
20
+ `,
21
+ required: true,
22
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
23
+ if (auth) {
24
+ try {
25
+ yield (0, client_1.makeRequest)(auth, pieces_common_1.HttpMethod.GET, '/chatbots', {});
26
+ return {
27
+ valid: true,
28
+ };
29
+ }
30
+ catch (error) {
31
+ return {
32
+ valid: false,
33
+ error: 'Invalid Api Key',
34
+ };
35
+ }
36
+ }
37
+ return {
38
+ valid: false,
39
+ error: 'Invalid Api Key',
40
+ };
41
+ }),
42
+ });
43
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chatsistant/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA2D;AAC3D,qCAAuC;AAE1B,QAAA,eAAe,GAAG,4BAAS,CAAC,UAAU,CAAC;IAClD,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE;;;;;;;;;;CAUd;IACC,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAA,oBAAW,EAAC,IAAI,EAAE,0BAAU,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;gBACzD,OAAO;oBACL,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,iBAAiB;iBACzB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,iBAAiB;SACzB,CAAC;IACJ,CAAC,CAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { HttpMethod } from '@activepieces/pieces-common';
2
+ export declare const BASE_URL = "https://app.chatsistant.com/api/v1";
3
+ export declare function makeRequest(api_key: string, method: HttpMethod, path: string, body?: unknown): Promise<any>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = void 0;
4
+ exports.makeRequest = makeRequest;
5
+ const tslib_1 = require("tslib");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ exports.BASE_URL = `https://app.chatsistant.com/api/v1`;
8
+ function makeRequest(api_key, method, path, body) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ try {
11
+ const response = yield pieces_common_1.httpClient.sendRequest({
12
+ method,
13
+ url: `${exports.BASE_URL}${path}`,
14
+ headers: {
15
+ Authorization: `Bearer ${api_key}`,
16
+ 'Content-Type': 'application/json',
17
+ },
18
+ body,
19
+ });
20
+ return response.body;
21
+ }
22
+ catch (error) {
23
+ throw new Error(`Unexpected error: ${error.message || String(error)}`);
24
+ }
25
+ });
26
+ }
27
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chatsistant/src/lib/common/client.ts"],"names":[],"mappings":";;;AAIA,kCAoBC;;AAxBD,+DAAqE;AAExD,QAAA,QAAQ,GAAG,oCAAoC,CAAC;AAE7D,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAkB,EAClB,IAAY,EACZ,IAAc;;QAEd,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM;gBACN,GAAG,EAAE,GAAG,gBAAQ,GAAG,IAAI,EAAE;gBACzB,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,OAAO,EAAE;oBAClC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI;aACL,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CAAA"}
@@ -0,0 +1,8 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const formSubmission: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
3
+ markdown: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
4
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
5
+ markdown: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
6
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
7
+ markdown: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
8
+ }>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formSubmission = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const auth_1 = require("../common/auth");
7
+ exports.formSubmission = (0, pieces_framework_1.createTrigger)({
8
+ auth: auth_1.chatsistantAuth,
9
+ name: 'formSubmission',
10
+ displayName: 'form submission',
11
+ description: 'Triggered when a form is submitted',
12
+ props: {
13
+ markdown: pieces_framework_1.Property.MarkDown({
14
+ value: `## Chatsistant Webhook Setup
15
+ To use this trigger, you need to manually set up a webhook in your Chatsistant account:
16
+
17
+ 1. Login to your Chatsistant account.
18
+ 2. Navigate to **Customizations** tab on the left navigation menu.
19
+ 3. Scroll down to **Webhook** and click to expand it.
20
+ 4. Select the **Form Submission** event and specify the following URL:
21
+ \`\`\`text
22
+ {{webhookUrl}}
23
+ \`\`\`
24
+ 5. Click Save to register the webhook.
25
+ `,
26
+ }),
27
+ },
28
+ sampleData: {
29
+ Email: 'test@gmail.com',
30
+ name: 'Test User',
31
+ session_uuid: 'cf014deb3b3b438d935f1ee7042ff66f',
32
+ },
33
+ type: pieces_framework_1.TriggerStrategy.WEBHOOK,
34
+ onEnable(context) {
35
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ // implement webhook creation logic
37
+ });
38
+ },
39
+ onDisable(context) {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ // implement webhook deletion logic
42
+ });
43
+ },
44
+ run(context) {
45
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
46
+ return [context.payload.body];
47
+ });
48
+ },
49
+ });
50
+ //# sourceMappingURL=form-submission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-submission.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/chatsistant/src/lib/triggers/form-submission.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,yCAAiD;AAEpC,QAAA,cAAc,GAAG,IAAA,gCAAa,EAAC;IAC1C,IAAI,EAAE,sBAAe;IACrB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,oCAAoC;IACjD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,KAAK,EAAE;;;;;;;;;;;aAWA;SACR,CAAC;KACH;IACD,UAAU,EAAE;QACV,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,WAAW;QACjB,YAAY,EAAE,kCAAkC;KACjD;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ,CAAC,OAAO;;YACpB,mCAAmC;QACrC,CAAC;KAAA;IACK,SAAS,CAAC,OAAO;;YACrB,mCAAmC;QACrC,CAAC;KAAA;IACK,GAAG,CAAC,OAAO;;YACf,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;KAAA;CACF,CAAC,CAAC"}