n8n-nodes-evolution-message-search 2.0.4 → 2.0.5
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.
|
@@ -5,6 +5,40 @@ exports.SearchMessages = void 0;
|
|
|
5
5
|
|
|
6
6
|
const n8n_workflow_1 = require('n8n-workflow');
|
|
7
7
|
|
|
8
|
+
function parseDate(input) {
|
|
9
|
+
if (!input) return null;
|
|
10
|
+
if (typeof input === 'number') {
|
|
11
|
+
return input > 1e12 ? Math.floor(input / 1000) : input;
|
|
12
|
+
}
|
|
13
|
+
if (typeof input !== 'string') return null;
|
|
14
|
+
|
|
15
|
+
const str = input.trim();
|
|
16
|
+
|
|
17
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(str)) {
|
|
18
|
+
const d = new Date(str);
|
|
19
|
+
if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (/^\d{2}\/\d{2}\/\d{4}/.test(str)) {
|
|
23
|
+
const parts = str.split('/');
|
|
24
|
+
const iso = `${parts[2]}-${parts[1]}-${parts[0]}T00:00:00Z`;
|
|
25
|
+
const d = new Date(iso);
|
|
26
|
+
if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (/^\d{2}-\d{2}-\d{4}/.test(str)) {
|
|
30
|
+
const parts = str.split('-');
|
|
31
|
+
const iso = `${parts[2]}-${parts[1]}-${parts[0]}T00:00:00Z`;
|
|
32
|
+
const d = new Date(iso);
|
|
33
|
+
if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const d = new Date(str);
|
|
37
|
+
if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000);
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
8
42
|
async function performSearch(ctx, itemIndex) {
|
|
9
43
|
const credentials = await ctx.getCredentials('evolutionApi');
|
|
10
44
|
const serverUrl = credentials['server-url'];
|
|
@@ -27,13 +61,15 @@ async function performSearch(ctx, itemIndex) {
|
|
|
27
61
|
if (keywords) {
|
|
28
62
|
whereClause['message.conversationMessage.text'] = { contains: keywords };
|
|
29
63
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
64
|
+
|
|
65
|
+
const tsFrom = parseDate(dateFrom);
|
|
66
|
+
const tsTo = parseDate(dateTo);
|
|
67
|
+
|
|
68
|
+
if (tsFrom !== null || tsTo !== null) {
|
|
69
|
+
whereClause.timestamp = {};
|
|
70
|
+
if (tsFrom !== null) whereClause.timestamp.gte = tsFrom;
|
|
71
|
+
if (tsTo !== null) {
|
|
72
|
+
whereClause.timestamp.lte = tsTo + 86399;
|
|
37
73
|
}
|
|
38
74
|
}
|
|
39
75
|
|
|
@@ -100,7 +136,7 @@ class SearchMessages {
|
|
|
100
136
|
typeOptions: {
|
|
101
137
|
rows: 4,
|
|
102
138
|
},
|
|
103
|
-
default: 'Search the WhatsApp message history of a conversation. ALL parameters are OPTIONAL except when explicitly needed:\n\n- Use ONLY keywords when user wants to find specific words/topics\n- Use ONLY dateFrom/dateTo when user asks about a time period (e.g. "last month", "yesterday")\n- Use BOTH keywords AND dates to combine topic search with time period\n- Use NONE when user wants recent messages (uses page 1)\n\nExamples:\n- "Did we talk about payment?" → use keywords="payment"\n- "What did we discuss last month?" → use dateFrom
|
|
139
|
+
default: 'Search the WhatsApp message history of a conversation. ALL parameters are OPTIONAL except when explicitly needed:\n\n- Use ONLY keywords when user wants to find specific words/topics\n- Use ONLY dateFrom/dateTo when user asks about a time period (e.g. "last month", "yesterday")\n- Use BOTH keywords AND dates to combine topic search with time period\n- Use NONE when user wants recent messages (uses page 1)\n\nDATE FORMAT (IMPORTANT): Always use ISO 8601 format: "YYYY-MM-DD" or "YYYY-MM-DDTHH:MM:SSZ"\n- "01/08/2026" → use "2026-08-01"\n- "last month" → use "2026-08-01" to "2026-08-31"\n- "yesterday" → use yesterday in YYYY-MM-DD format\n\nExamples:\n- "Did we talk about payment?" → use keywords="payment"\n- "What did we discuss last month?" → use dateFrom="2026-08-01" dateTo="2026-08-31"\n- "Anything about refund in January?" → use keywords="refund" + dateFrom/dateTo\n\nNavigation:\n- page: increase to see older messages (model can change)\n- pageSize: number of results per page (user-defined, do not change)',
|
|
104
140
|
description: 'Custom description shown to AI agent to help it understand how to use this tool',
|
|
105
141
|
},
|
|
106
142
|
{
|
|
@@ -142,8 +178,8 @@ class SearchMessages {
|
|
|
142
178
|
type: 'string',
|
|
143
179
|
required: false,
|
|
144
180
|
default: '',
|
|
145
|
-
description: 'OPTIONAL: Start date
|
|
146
|
-
placeholder: '={{ $fromAI("
|
|
181
|
+
description: 'OPTIONAL: Start date in ISO format YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ. Use when user mentions a time period.',
|
|
182
|
+
placeholder: '={{ $fromAI("Date_From_ISO", "", "string") }}',
|
|
147
183
|
},
|
|
148
184
|
{
|
|
149
185
|
displayName: 'Date To',
|
|
@@ -151,8 +187,8 @@ class SearchMessages {
|
|
|
151
187
|
type: 'string',
|
|
152
188
|
required: false,
|
|
153
189
|
default: '',
|
|
154
|
-
description: 'OPTIONAL: End date
|
|
155
|
-
placeholder: '={{ $fromAI("
|
|
190
|
+
description: 'OPTIONAL: End date in ISO format YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ. Use when user mentions a time period.',
|
|
191
|
+
placeholder: '={{ $fromAI("Date_To_ISO", "", "string") }}',
|
|
156
192
|
},
|
|
157
193
|
{
|
|
158
194
|
displayName: 'Items per Page',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-evolution-message-search",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
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",
|