n8n-nodes-evolution-message-search 1.0.8 → 1.0.9
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.
|
@@ -3,20 +3,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
3
3
|
exports.SearchMessages = void 0;
|
|
4
4
|
const n8n_workflow_1 = require('n8n-workflow');
|
|
5
5
|
class SearchMessagesTool extends n8n_workflow_1.Tool {
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(node) {
|
|
7
7
|
super();
|
|
8
|
-
this.
|
|
9
|
-
this.name = (0, n8n_workflow_1.nodeNameToToolName)(
|
|
10
|
-
this.description = 'Search WhatsApp message history. Input should be an object with: keywords (string, optional), dateFrom (ISO date string, optional), dateTo (ISO date string, optional), page (number, default 1), pageSize (number, default 10), conversationId (string, optional).';
|
|
8
|
+
this.node = node;
|
|
9
|
+
this.name = (0, n8n_workflow_1.nodeNameToToolName)(node.getNode());
|
|
10
|
+
this.description = 'Search WhatsApp message history. Input should be an object with: keywords (string, optional), dateFrom (ISO date string, optional), dateTo (ISO date string, optional), page (number, default 1), pageSize (number, default 10), conversationId (string, optional). Returns paginated message search results with total, pages, currentPage, and records.';
|
|
11
11
|
}
|
|
12
12
|
async _call(input) {
|
|
13
13
|
const params = typeof input === 'string' ? JSON.parse(input) : input;
|
|
14
|
-
const credentials = await this.
|
|
14
|
+
const credentials = await this.node.getCredentials('evolutionApi');
|
|
15
15
|
const serverUrl = credentials['server-url'];
|
|
16
16
|
const apiKey = credentials.apikey;
|
|
17
|
-
const instanceName = this.
|
|
18
|
-
const userConversationId = this.
|
|
19
|
-
const allowModelSetConversation = this.
|
|
17
|
+
const instanceName = this.node.getNodeParameter('instanceName', 0);
|
|
18
|
+
const userConversationId = this.node.getNodeParameter('conversationId', 0) || '';
|
|
19
|
+
const allowModelSetConversation = this.node.getNodeParameter('allowModelSetConversation', 0);
|
|
20
20
|
let conversationId = userConversationId;
|
|
21
21
|
if (!conversationId && allowModelSetConversation && params.conversationId) {
|
|
22
22
|
conversationId = params.conversationId;
|
|
@@ -24,7 +24,7 @@ class SearchMessagesTool extends n8n_workflow_1.Tool {
|
|
|
24
24
|
const keywords = params.keywords || '';
|
|
25
25
|
const dateFrom = params.dateFrom || '';
|
|
26
26
|
const dateTo = params.dateTo || '';
|
|
27
|
-
const pageSize = params.pageSize || this.
|
|
27
|
+
const pageSize = params.pageSize || this.node.getNodeParameter('pageSize', 0) || 10;
|
|
28
28
|
const page = params.page || 1;
|
|
29
29
|
const skip = (page - 1) * pageSize;
|
|
30
30
|
const whereClause = {};
|
|
@@ -56,7 +56,7 @@ class SearchMessagesTool extends n8n_workflow_1.Tool {
|
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
const cleanUrl = serverUrl.replace(/\/$/, '');
|
|
59
|
-
const responseData = await this.
|
|
59
|
+
const responseData = await this.node.helpers.request({
|
|
60
60
|
method: 'POST',
|
|
61
61
|
uri: `${cleanUrl}/chat/findMessages/${instanceName}`,
|
|
62
62
|
body,
|
|
@@ -69,14 +69,13 @@ class SearchMessagesTool extends n8n_workflow_1.Tool {
|
|
|
69
69
|
const messages = responseData.messages || responseData;
|
|
70
70
|
const total = messages.total || messages.length || 0;
|
|
71
71
|
const totalPages = Math.ceil(total / pageSize);
|
|
72
|
-
|
|
72
|
+
return JSON.stringify({
|
|
73
73
|
total,
|
|
74
74
|
pages: totalPages,
|
|
75
75
|
currentPage: page,
|
|
76
76
|
pageSize,
|
|
77
77
|
records: Array.isArray(messages.records) ? messages.records : messages,
|
|
78
|
-
};
|
|
79
|
-
return JSON.stringify(result);
|
|
78
|
+
});
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
class SearchMessages {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-evolution-message-search",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Evolution API - Search Messages node for n8n. Search WhatsApp message history by keywords, dates, and conversation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|