@skillful-ai/piece-skai-adapters 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 +325 -0
- package/package.json +36 -0
- package/skillful-ai-piece-skai-adapters-0.0.1.tgz +0 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +25 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/skai-to-telegram.d.ts +3 -0
- package/src/lib/actions/skai-to-telegram.js +192 -0
- package/src/lib/actions/skai-to-telegram.js.map +1 -0
- package/src/lib/actions/skai-to-whatsapp.d.ts +3 -0
- package/src/lib/actions/skai-to-whatsapp.js +179 -0
- package/src/lib/actions/skai-to-whatsapp.js.map +1 -0
- package/src/lib/actions/telegram-to-skai.d.ts +6 -0
- package/src/lib/actions/telegram-to-skai.js +93 -0
- package/src/lib/actions/telegram-to-skai.js.map +1 -0
- package/src/lib/actions/whatsapp-to-skai.d.ts +6 -0
- package/src/lib/actions/whatsapp-to-skai.js +93 -0
- package/src/lib/actions/whatsapp-to-skai.js.map +1 -0
- package/src/lib/auth/skai.auth.d.ts +3 -0
- package/src/lib/auth/skai.auth.js +32 -0
- package/src/lib/auth/skai.auth.js.map +1 -0
- package/src/lib/common/dropdowns.d.ts +5 -0
- package/src/lib/common/dropdowns.js +61 -0
- package/src/lib/common/dropdowns.js.map +1 -0
- package/src/lib/common/skai-client.d.ts +65 -0
- package/src/lib/common/skai-client.js +173 -0
- package/src/lib/common/skai-client.js.map +1 -0
- package/src/lib/common/types/generic-message.d.ts +44 -0
- package/src/lib/common/types/generic-message.js +27 -0
- package/src/lib/common/types/generic-message.js.map +1 -0
- package/src/lib/transformers/telegram.transformer.d.ts +78 -0
- package/src/lib/transformers/telegram.transformer.js +72 -0
- package/src/lib/transformers/telegram.transformer.js.map +1 -0
- package/src/lib/transformers/whatsapp.transformer.d.ts +73 -0
- package/src/lib/transformers/whatsapp.transformer.js +136 -0
- package/src/lib/transformers/whatsapp.transformer.js.map +1 -0
- package/src/lib/triggers/skai-response-webhook.d.ts +20 -0
- package/src/lib/triggers/skai-response-webhook.js +144 -0
- package/src/lib/triggers/skai-response-webhook.js.map +1 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.skaiToWhatsApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
// WhatsApp message length limit
|
|
7
|
+
const MAX_WHATSAPP_MESSAGE_LENGTH = 4096;
|
|
8
|
+
/**
|
|
9
|
+
* Split a long message into chunks respecting WhatsApp's character limit
|
|
10
|
+
* Tries to split at natural boundaries (paragraphs, sentences, words)
|
|
11
|
+
*/
|
|
12
|
+
function splitMessage(text, maxLength = MAX_WHATSAPP_MESSAGE_LENGTH) {
|
|
13
|
+
if (text.length <= maxLength) {
|
|
14
|
+
return [text];
|
|
15
|
+
}
|
|
16
|
+
const messages = [];
|
|
17
|
+
let remainingText = text;
|
|
18
|
+
while (remainingText.length > 0) {
|
|
19
|
+
if (remainingText.length <= maxLength) {
|
|
20
|
+
messages.push(remainingText);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
// Try to split at paragraph boundary (\n\n)
|
|
24
|
+
let splitIndex = remainingText.lastIndexOf('\n\n', maxLength);
|
|
25
|
+
// If no paragraph boundary, try sentence boundary (. ! ?)
|
|
26
|
+
if (splitIndex === -1 || splitIndex < maxLength * 0.5) {
|
|
27
|
+
const sentenceEndings = ['. ', '! ', '? ', '.\n', '!\n', '?\n'];
|
|
28
|
+
for (const ending of sentenceEndings) {
|
|
29
|
+
const idx = remainingText.lastIndexOf(ending, maxLength);
|
|
30
|
+
if (idx > splitIndex) {
|
|
31
|
+
splitIndex = idx + ending.length;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// If no sentence boundary, try word boundary (space)
|
|
36
|
+
if (splitIndex === -1 || splitIndex < maxLength * 0.5) {
|
|
37
|
+
splitIndex = remainingText.lastIndexOf(' ', maxLength);
|
|
38
|
+
}
|
|
39
|
+
// Last resort: hard split at maxLength
|
|
40
|
+
if (splitIndex === -1 || splitIndex < maxLength * 0.5) {
|
|
41
|
+
splitIndex = maxLength;
|
|
42
|
+
}
|
|
43
|
+
messages.push(remainingText.substring(0, splitIndex).trim());
|
|
44
|
+
remainingText = remainingText.substring(splitIndex).trim();
|
|
45
|
+
}
|
|
46
|
+
return messages;
|
|
47
|
+
}
|
|
48
|
+
exports.skaiToWhatsApp = (0, pieces_framework_1.createAction)({
|
|
49
|
+
name: 'skai_to_whatsapp',
|
|
50
|
+
displayName: 'SKAI → WhatsApp',
|
|
51
|
+
description: 'Transform SKAI webhook response to WhatsApp message format (with auto message splitting)',
|
|
52
|
+
props: {
|
|
53
|
+
webhookPayload: pieces_framework_1.Property.Json({
|
|
54
|
+
displayName: 'SKAI Webhook Payload',
|
|
55
|
+
description: 'Output from SKAI Response Webhook trigger',
|
|
56
|
+
required: true,
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
run(context) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const { webhookPayload } = context.propsValue;
|
|
63
|
+
try {
|
|
64
|
+
// Parse webhook payload
|
|
65
|
+
const payload = webhookPayload;
|
|
66
|
+
// Validate platform
|
|
67
|
+
if (!payload.platform || payload.platform !== 'whatsapp') {
|
|
68
|
+
throw new Error(`Invalid platform: expected 'whatsapp', got '${payload.platform || 'undefined'}'`);
|
|
69
|
+
}
|
|
70
|
+
// Validate required fields
|
|
71
|
+
if (!payload.external_id || !payload.message) {
|
|
72
|
+
throw new Error('Missing required fields: external_id or message');
|
|
73
|
+
}
|
|
74
|
+
console.log('Transforming SKAI response to WhatsApp format');
|
|
75
|
+
console.log('External ID:', payload.external_id);
|
|
76
|
+
console.log('Message preview:', ((_a = payload.message) === null || _a === void 0 ? void 0 : _a.substring(0, 50)) + '...');
|
|
77
|
+
console.log('Message length:', ((_b = payload.message) === null || _b === void 0 ? void 0 : _b.length) || 0);
|
|
78
|
+
// Split message if it exceeds WhatsApp's limit
|
|
79
|
+
const messageParts = splitMessage(payload.message);
|
|
80
|
+
if (messageParts.length > 1) {
|
|
81
|
+
console.log(`Message exceeds ${MAX_WHATSAPP_MESSAGE_LENGTH} chars, split into ${messageParts.length} parts`);
|
|
82
|
+
}
|
|
83
|
+
const whatsappMessages = [];
|
|
84
|
+
const hasMedia = payload.media_urls && payload.media_urls.length > 0;
|
|
85
|
+
const hasText = payload.message && payload.message.trim().length > 0;
|
|
86
|
+
// Handle media URLs
|
|
87
|
+
if (hasMedia) {
|
|
88
|
+
const mediaUrls = payload.media_urls;
|
|
89
|
+
const mediaTypes = payload.media_types || [];
|
|
90
|
+
console.log(`Processing ${mediaUrls.length} media item(s)`);
|
|
91
|
+
// If text exists, combine first text part with first media
|
|
92
|
+
if (hasText && messageParts.length > 0) {
|
|
93
|
+
const firstMediaUrl = mediaUrls[0];
|
|
94
|
+
const firstMediaType = mediaTypes.length > 0
|
|
95
|
+
? mediaTypes[0].toLowerCase()
|
|
96
|
+
: 'image';
|
|
97
|
+
console.log('First message: text + media 0 (', firstMediaType, '-', firstMediaUrl, ')');
|
|
98
|
+
// First message: text + first media
|
|
99
|
+
whatsappMessages.push({
|
|
100
|
+
to: payload.external_id,
|
|
101
|
+
text: messageParts[0],
|
|
102
|
+
mediaUrl: firstMediaUrl,
|
|
103
|
+
mediaType: firstMediaType,
|
|
104
|
+
reference_id: payload.reference_id,
|
|
105
|
+
partNumber: 1,
|
|
106
|
+
totalParts: messageParts.length + mediaUrls.length - 1,
|
|
107
|
+
});
|
|
108
|
+
// Remaining text parts (if any) as separate text messages
|
|
109
|
+
for (let i = 1; i < messageParts.length; i++) {
|
|
110
|
+
whatsappMessages.push({
|
|
111
|
+
to: payload.external_id,
|
|
112
|
+
text: messageParts[i],
|
|
113
|
+
reference_id: payload.reference_id,
|
|
114
|
+
partNumber: i + 1,
|
|
115
|
+
totalParts: messageParts.length + mediaUrls.length - 1,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// Remaining media items as separate media-only messages
|
|
119
|
+
for (let i = 1; i < mediaUrls.length; i++) {
|
|
120
|
+
const mediaType = mediaTypes.length > i
|
|
121
|
+
? mediaTypes[i].toLowerCase()
|
|
122
|
+
: 'image';
|
|
123
|
+
console.log(`Media ${i}:`, mediaType, '-', mediaUrls[i]);
|
|
124
|
+
whatsappMessages.push({
|
|
125
|
+
to: payload.external_id,
|
|
126
|
+
mediaUrl: mediaUrls[i],
|
|
127
|
+
mediaType: mediaType,
|
|
128
|
+
reference_id: payload.reference_id,
|
|
129
|
+
partNumber: messageParts.length + i,
|
|
130
|
+
totalParts: messageParts.length + mediaUrls.length - 1,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
// No text, send all media as separate messages
|
|
136
|
+
for (let i = 0; i < mediaUrls.length; i++) {
|
|
137
|
+
const mediaType = mediaTypes.length > i
|
|
138
|
+
? mediaTypes[i].toLowerCase()
|
|
139
|
+
: 'image';
|
|
140
|
+
console.log(`Media ${i}:`, mediaType, '-', mediaUrls[i]);
|
|
141
|
+
whatsappMessages.push({
|
|
142
|
+
to: payload.external_id,
|
|
143
|
+
mediaUrl: mediaUrls[i],
|
|
144
|
+
mediaType: mediaType,
|
|
145
|
+
reference_id: payload.reference_id,
|
|
146
|
+
partNumber: i + 1,
|
|
147
|
+
totalParts: mediaUrls.length,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// No media, just text messages
|
|
154
|
+
whatsappMessages.push(...messageParts.map((part, index) => ({
|
|
155
|
+
to: payload.external_id,
|
|
156
|
+
text: part,
|
|
157
|
+
reference_id: payload.reference_id,
|
|
158
|
+
partNumber: index + 1,
|
|
159
|
+
totalParts: messageParts.length,
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
console.log(`Message formatted for WhatsApp: ${whatsappMessages.length} message(s) to send`);
|
|
163
|
+
// Return all message parts (array if split, single item array if not)
|
|
164
|
+
return {
|
|
165
|
+
messages: whatsappMessages,
|
|
166
|
+
requiresMultipleSends: whatsappMessages.length > 1,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
console.error('Error in SKAI → WhatsApp:', error);
|
|
171
|
+
return {
|
|
172
|
+
success: false,
|
|
173
|
+
error: error.message || 'Failed to transform SKAI response to WhatsApp format',
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=skai-to-whatsapp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skai-to-whatsapp.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-adapters/src/lib/actions/skai-to-whatsapp.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAExE,gCAAgC;AAChC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC;;;GAGG;AACH,SAAS,YAAY,CAAC,IAAY,EAAE,YAAoB,2BAA2B;IAClF,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,aAAa,GAAG,IAAI,CAAC;IAEzB,OAAO,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,aAAa,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YACvC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7B,MAAM;QACP,CAAC;QAED,4CAA4C;QAC5C,IAAI,UAAU,GAAG,aAAa,CA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AC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACrB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;gBAElD,OAAO;oBACN,OAAO,EAAE,KAAK;oBACd,KAAK,EACJ,KAAK,CAAC,OAAO,IAAI,sDAAsD;iBACxE,CAAC;YACH,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const telegramToSkai: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
+
telegramMessage: import("@activepieces/pieces-framework").JsonProperty<true>;
|
|
3
|
+
agent: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
webhookUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
chatBufferWindowSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.telegramToSkai = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const telegram_transformer_1 = require("../transformers/telegram.transformer");
|
|
7
|
+
const skai_client_1 = require("../common/skai-client");
|
|
8
|
+
const dropdowns_1 = require("../common/dropdowns");
|
|
9
|
+
exports.telegramToSkai = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'telegram_to_skai',
|
|
11
|
+
displayName: 'Telegram → SKAI Agent',
|
|
12
|
+
description: 'Transform Telegram message to generic format and process with SKAI agent',
|
|
13
|
+
props: {
|
|
14
|
+
telegramMessage: pieces_framework_1.Property.Json({
|
|
15
|
+
displayName: 'Telegram Message',
|
|
16
|
+
description: 'Output from Telegram New Message trigger',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
agent: dropdowns_1.agentDropdown,
|
|
20
|
+
webhookUrl: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Webhook Callback URL',
|
|
22
|
+
description: 'URL from SKAI Response Webhook trigger (Flow 2) for backend to send response',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
chatBufferWindowSeconds: pieces_framework_1.Property.Number({
|
|
26
|
+
displayName: 'Chat Buffer Window (Seconds)',
|
|
27
|
+
description: 'Chat buffer window in seconds (0 to 60 seconds, 1 minute max)',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 0,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
run(context) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { telegramMessage, agent, webhookUrl, chatBufferWindowSeconds } = context.propsValue;
|
|
35
|
+
try {
|
|
36
|
+
console.log('📨 Processing Telegram → SKAI');
|
|
37
|
+
// Validate chat buffer window seconds
|
|
38
|
+
const bufferSeconds = chatBufferWindowSeconds !== null && chatBufferWindowSeconds !== void 0 ? chatBufferWindowSeconds : 0;
|
|
39
|
+
if (bufferSeconds < 0 || bufferSeconds > 60) {
|
|
40
|
+
throw new Error('Chat buffer window seconds must be between 0 and 60 (1 minute)');
|
|
41
|
+
}
|
|
42
|
+
// Transform Telegram message to GenericMessage format
|
|
43
|
+
const transformer = new telegram_transformer_1.TelegramTransformer();
|
|
44
|
+
const genericMessage = transformer.transform(telegramMessage);
|
|
45
|
+
console.log('✅ Message transformed', {
|
|
46
|
+
from: genericMessage.external_id,
|
|
47
|
+
platform: genericMessage.platform,
|
|
48
|
+
preview: genericMessage.message.substring(0, 50) + '...',
|
|
49
|
+
});
|
|
50
|
+
// Prepare request body
|
|
51
|
+
const requestBody = {
|
|
52
|
+
external_id: genericMessage.external_id,
|
|
53
|
+
reference_id: genericMessage.reference_id,
|
|
54
|
+
platform: genericMessage.platform,
|
|
55
|
+
message: genericMessage.message,
|
|
56
|
+
sender_name: genericMessage.sender_name,
|
|
57
|
+
unique_handle: genericMessage.unique_handle,
|
|
58
|
+
media_urls: genericMessage.media_urls || [],
|
|
59
|
+
media_types: genericMessage.media_types || [],
|
|
60
|
+
metadata: genericMessage.metadata || {},
|
|
61
|
+
webhook_url: webhookUrl,
|
|
62
|
+
chat_buffer_window_seconds: Math.round(bufferSeconds),
|
|
63
|
+
};
|
|
64
|
+
// Call SKAI Agents API using server context
|
|
65
|
+
const skaiResponse = yield skai_client_1.skaiClient.processMessage({
|
|
66
|
+
serverUrl: context.server.publicUrl,
|
|
67
|
+
token: context.server.token,
|
|
68
|
+
agentId: agent,
|
|
69
|
+
payload: requestBody,
|
|
70
|
+
});
|
|
71
|
+
console.log('✅ SKAI agent processed message successfully');
|
|
72
|
+
// Build response
|
|
73
|
+
const response = {
|
|
74
|
+
success: true,
|
|
75
|
+
skaiResponse,
|
|
76
|
+
genericMessage,
|
|
77
|
+
originalPlatform: 'telegram',
|
|
78
|
+
originalMessage: telegramMessage,
|
|
79
|
+
};
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('❌ Error in Telegram → SKAI:', error);
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: error.message || 'Failed to process message with SKAI agent',
|
|
87
|
+
originalPlatform: 'telegram',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=telegram-to-skai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram-to-skai.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-adapters/src/lib/actions/telegram-to-skai.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+EAA2E;AAC3E,uDAAmD;AACnD,mDAAoD;AAEvC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EA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KAAK,EAAE,KAAK,CAAC,OAAO,IAAI,2CAA2C;oBACnE,gBAAgB,EAAE,UAAU;iBAC5B,CAAC;YACH,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const whatsappToSkai: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
2
|
+
whatsappMessage: import("@activepieces/pieces-framework").JsonProperty<true>;
|
|
3
|
+
agent: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
|
|
4
|
+
webhookUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
chatBufferWindowSeconds: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.whatsappToSkai = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const whatsapp_transformer_1 = require("../transformers/whatsapp.transformer");
|
|
7
|
+
const skai_client_1 = require("../common/skai-client");
|
|
8
|
+
const dropdowns_1 = require("../common/dropdowns");
|
|
9
|
+
exports.whatsappToSkai = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'whatsapp_to_skai',
|
|
11
|
+
displayName: 'WhatsApp → SKAI Agent',
|
|
12
|
+
description: 'Transform WhatsApp message to generic format and process with SKAI agent',
|
|
13
|
+
props: {
|
|
14
|
+
whatsappMessage: pieces_framework_1.Property.Json({
|
|
15
|
+
displayName: 'WhatsApp Message',
|
|
16
|
+
description: 'Output from WhatsApp New Message trigger',
|
|
17
|
+
required: true,
|
|
18
|
+
}),
|
|
19
|
+
agent: dropdowns_1.agentDropdown,
|
|
20
|
+
webhookUrl: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Webhook Callback URL',
|
|
22
|
+
description: 'URL from SKAI Response Webhook trigger (Flow 2) for backend to send response',
|
|
23
|
+
required: true,
|
|
24
|
+
}),
|
|
25
|
+
chatBufferWindowSeconds: pieces_framework_1.Property.Number({
|
|
26
|
+
displayName: 'Chat Buffer Window (Seconds)',
|
|
27
|
+
description: 'Chat buffer window in seconds (0 to 60 seconds, 1 minute max)',
|
|
28
|
+
required: false,
|
|
29
|
+
defaultValue: 0,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
run(context) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { whatsappMessage, agent, webhookUrl, chatBufferWindowSeconds } = context.propsValue;
|
|
35
|
+
try {
|
|
36
|
+
console.log('📨 Processing WhatsApp → SKAI');
|
|
37
|
+
// Validate chat buffer window seconds
|
|
38
|
+
const bufferSeconds = chatBufferWindowSeconds !== null && chatBufferWindowSeconds !== void 0 ? chatBufferWindowSeconds : 0;
|
|
39
|
+
if (bufferSeconds < 0 || bufferSeconds > 60) {
|
|
40
|
+
throw new Error('Chat buffer window seconds must be between 0 and 60 (1 minute)');
|
|
41
|
+
}
|
|
42
|
+
// Transform WhatsApp message to GenericMessage format
|
|
43
|
+
const transformer = new whatsapp_transformer_1.WhatsAppTransformer();
|
|
44
|
+
const genericMessage = transformer.transform(whatsappMessage);
|
|
45
|
+
console.log('✅ Message transformed', {
|
|
46
|
+
from: genericMessage.external_id,
|
|
47
|
+
platform: genericMessage.platform,
|
|
48
|
+
preview: genericMessage.message.substring(0, 50) + '...',
|
|
49
|
+
});
|
|
50
|
+
// Prepare request body
|
|
51
|
+
const requestBody = {
|
|
52
|
+
external_id: genericMessage.external_id,
|
|
53
|
+
reference_id: genericMessage.reference_id,
|
|
54
|
+
platform: genericMessage.platform,
|
|
55
|
+
message: genericMessage.message,
|
|
56
|
+
sender_name: genericMessage.sender_name,
|
|
57
|
+
unique_handle: genericMessage.unique_handle,
|
|
58
|
+
media_urls: genericMessage.media_urls || [],
|
|
59
|
+
media_types: genericMessage.media_types || [],
|
|
60
|
+
metadata: genericMessage.metadata || {},
|
|
61
|
+
webhook_url: webhookUrl,
|
|
62
|
+
chat_buffer_window_seconds: Math.round(bufferSeconds),
|
|
63
|
+
};
|
|
64
|
+
// Call SKAI Agents API using server context
|
|
65
|
+
const skaiResponse = yield skai_client_1.skaiClient.processMessage({
|
|
66
|
+
serverUrl: context.server.publicUrl,
|
|
67
|
+
token: context.server.token,
|
|
68
|
+
agentId: agent,
|
|
69
|
+
payload: requestBody,
|
|
70
|
+
});
|
|
71
|
+
console.log('✅ SKAI agent processed message successfully');
|
|
72
|
+
// Build response
|
|
73
|
+
const response = {
|
|
74
|
+
success: true,
|
|
75
|
+
skaiResponse,
|
|
76
|
+
genericMessage,
|
|
77
|
+
originalPlatform: 'whatsapp',
|
|
78
|
+
originalMessage: whatsappMessage,
|
|
79
|
+
};
|
|
80
|
+
return response;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('❌ Error in WhatsApp → SKAI:', error);
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
error: error.message || 'Failed to process message with SKAI agent',
|
|
87
|
+
originalPlatform: 'whatsapp',
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=whatsapp-to-skai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whatsapp-to-skai.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-adapters/src/lib/actions/whatsapp-to-skai.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+EAA2E;AAC3E,uDAAmD;AACnD,mDAAoD;AAEvC,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,0EAA0E;IAEvF,KAAK,EAAE;QACN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EAAE,UAAU;iBAC5B,CAAC;YACH,CAAC;QACF,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.skaiAuth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const markdown = `
|
|
6
|
+
## 🤖 SKAI Agents API Key
|
|
7
|
+
|
|
8
|
+
To get your SKAI Agents API key:
|
|
9
|
+
|
|
10
|
+
1. Go to [SKAI Agents Platform](https://agents.skillfulai.io)
|
|
11
|
+
2. Log in to your account
|
|
12
|
+
3. Navigate to Settings → API Keys
|
|
13
|
+
4. Create a new API key or copy an existing one
|
|
14
|
+
5. The key starts with \`sk_\`
|
|
15
|
+
|
|
16
|
+
**Security Notes:**
|
|
17
|
+
- Keep your API key secure and never share it
|
|
18
|
+
- API key grants access to your SKAI agents and conversations
|
|
19
|
+
- You can revoke and regenerate keys at any time
|
|
20
|
+
`;
|
|
21
|
+
exports.skaiAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
22
|
+
required: true,
|
|
23
|
+
description: markdown,
|
|
24
|
+
props: {
|
|
25
|
+
apiKey: pieces_framework_1.PieceAuth.SecretText({
|
|
26
|
+
displayName: 'SKAI API Key',
|
|
27
|
+
description: 'Your SKAI Agents API key (starts with sk_)',
|
|
28
|
+
required: true,
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=skai.auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skai.auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-adapters/src/lib/auth/skai.auth.ts"],"names":[],"mappings":";;;AAAA,qEAA2D;AAE3D,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;CAehB,CAAC;AAEW,QAAA,QAAQ,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE;QACN,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC5B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,IAAI;SACd,CAAC;KACF;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentDropdown = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const skai_client_1 = require("./skai-client");
|
|
7
|
+
/**
|
|
8
|
+
* Dynamic dropdown for selecting SKAI agent
|
|
9
|
+
* Fetches agents from SKAI API using server context (publicUrl + token)
|
|
10
|
+
*/
|
|
11
|
+
exports.agentDropdown = pieces_framework_1.Property.Dropdown({
|
|
12
|
+
displayName: 'SKAI Agent',
|
|
13
|
+
description: 'Select which AI agent will process the message',
|
|
14
|
+
required: true,
|
|
15
|
+
refreshers: [],
|
|
16
|
+
options: (_auth, ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.server) === null || _a === void 0 ? void 0 : _a.token)) {
|
|
19
|
+
return {
|
|
20
|
+
disabled: true,
|
|
21
|
+
placeholder: 'Server token required',
|
|
22
|
+
options: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
// Fetch agents from SKAI API using server context
|
|
27
|
+
const agents = yield skai_client_1.skaiClient.listAgents({
|
|
28
|
+
serverUrl: ctx.server.publicUrl,
|
|
29
|
+
token: ctx.server.token,
|
|
30
|
+
});
|
|
31
|
+
// Filter to only show non-draft, minted agents
|
|
32
|
+
const availableAgents = agents.filter((agent) => !agent.isDraft && agent.isMinted);
|
|
33
|
+
if (availableAgents.length === 0) {
|
|
34
|
+
return {
|
|
35
|
+
disabled: true,
|
|
36
|
+
placeholder: 'No agents available. Create an agent first.',
|
|
37
|
+
options: [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
disabled: false,
|
|
42
|
+
options: availableAgents.map((agent) => ({
|
|
43
|
+
label: agent.name,
|
|
44
|
+
value: agent.id,
|
|
45
|
+
})),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('Failed to fetch SKAI agents:', error);
|
|
50
|
+
const isApiKeyError = (_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('SKAI API key not configured');
|
|
51
|
+
return {
|
|
52
|
+
disabled: true,
|
|
53
|
+
placeholder: isApiKeyError
|
|
54
|
+
? 'SKAI API key not configured'
|
|
55
|
+
: `Error: ${error.message || 'Failed to load agents'}`,
|
|
56
|
+
options: [],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=dropdowns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdowns.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/custom/skai-adapters/src/lib/common/dropdowns.ts"],"names":[],"mappings":";;;;AAAA,qEAA0D;AAC1D,+CAA2C;AAE3C;;;GAGG;AACU,QAAA,aAAa,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC9C,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,gDAAgD;IAC7D,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,CAAO,KAAK,EAAE,GAAG,EAAE,EAAE;;QAC7B,IAAI,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,KAAK,CAAA,EAAE,CAAC;YACzB,OAAO;gBACN,QAAQ,EAAE,IA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AAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SkaiAgentsClient } from '@skillful-ai/skai-sdk';
|
|
2
|
+
import { SkaiAgentResponse } from './types/generic-message';
|
|
3
|
+
export interface ProcessMessageParams {
|
|
4
|
+
serverUrl: string;
|
|
5
|
+
token: string;
|
|
6
|
+
agentId: string;
|
|
7
|
+
payload: any;
|
|
8
|
+
}
|
|
9
|
+
export interface ListAgentsParams {
|
|
10
|
+
serverUrl: string;
|
|
11
|
+
token: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AgentInfo {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
logoUrl?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
isDraft: boolean;
|
|
20
|
+
isMinted: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface User {
|
|
23
|
+
id: string;
|
|
24
|
+
skaiApiKey?: string;
|
|
25
|
+
externalId?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* SKAI Agents API client
|
|
29
|
+
* Uses server context (publicUrl + token) to get user's SKAI API key and configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare const skaiClient: {
|
|
32
|
+
/**
|
|
33
|
+
* Get the piece user with their credentials from the server
|
|
34
|
+
*/
|
|
35
|
+
getPieceUser(params: {
|
|
36
|
+
serverUrl: string;
|
|
37
|
+
token: string;
|
|
38
|
+
}): Promise<User>;
|
|
39
|
+
/**
|
|
40
|
+
* Get SKAI API URL from server configuration
|
|
41
|
+
*/
|
|
42
|
+
getSkaiApiUrl(params: {
|
|
43
|
+
serverUrl: string;
|
|
44
|
+
token: string;
|
|
45
|
+
}): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a SKAI API client instance with proper configuration
|
|
48
|
+
*/
|
|
49
|
+
createSkaiClient(params: {
|
|
50
|
+
serverUrl: string;
|
|
51
|
+
token: string;
|
|
52
|
+
userApiKey: string;
|
|
53
|
+
}): Promise<SkaiAgentsClient>;
|
|
54
|
+
/**
|
|
55
|
+
* Process a message with a SKAI agent
|
|
56
|
+
* Uses HTTP call for async webhook-based processing (not available in SDK)
|
|
57
|
+
*/
|
|
58
|
+
processMessage(params: ProcessMessageParams): Promise<SkaiAgentResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* List available agents for dropdown
|
|
61
|
+
* Uses SKAI SDK for consistency with other pieces
|
|
62
|
+
*/
|
|
63
|
+
listAgents(params: ListAgentsParams): Promise<AgentInfo[]>;
|
|
64
|
+
};
|
|
65
|
+
export {};
|