n8n-nodes-evolution-message-search 2.0.3 → 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
|
|
|
@@ -93,6 +129,16 @@ class SearchMessages {
|
|
|
93
129
|
},
|
|
94
130
|
],
|
|
95
131
|
properties: [
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Tool Description',
|
|
134
|
+
name: 'toolDescription',
|
|
135
|
+
type: 'string',
|
|
136
|
+
typeOptions: {
|
|
137
|
+
rows: 4,
|
|
138
|
+
},
|
|
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)',
|
|
140
|
+
description: 'Custom description shown to AI agent to help it understand how to use this tool',
|
|
141
|
+
},
|
|
96
142
|
{
|
|
97
143
|
displayName: 'Instance Name',
|
|
98
144
|
name: 'instanceName',
|
|
@@ -107,7 +153,7 @@ class SearchMessages {
|
|
|
107
153
|
type: 'string',
|
|
108
154
|
required: false,
|
|
109
155
|
default: '',
|
|
110
|
-
description: 'WhatsApp conversation ID (JID).
|
|
156
|
+
description: 'WhatsApp conversation ID (JID). Leave empty to search all conversations.',
|
|
111
157
|
placeholder: '5511999999999@s.whatsapp.net',
|
|
112
158
|
},
|
|
113
159
|
{
|
|
@@ -123,7 +169,8 @@ class SearchMessages {
|
|
|
123
169
|
type: 'string',
|
|
124
170
|
required: false,
|
|
125
171
|
default: '',
|
|
126
|
-
description: 'Search text in message content
|
|
172
|
+
description: 'OPTIONAL: Search text in message content. Leave empty to search by date only.',
|
|
173
|
+
placeholder: '={{ $fromAI("Keywords", "", "string") }}',
|
|
127
174
|
},
|
|
128
175
|
{
|
|
129
176
|
displayName: 'Date From',
|
|
@@ -131,8 +178,8 @@ class SearchMessages {
|
|
|
131
178
|
type: 'string',
|
|
132
179
|
required: false,
|
|
133
180
|
default: '',
|
|
134
|
-
description: 'Start date
|
|
135
|
-
placeholder: '
|
|
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") }}',
|
|
136
183
|
},
|
|
137
184
|
{
|
|
138
185
|
displayName: 'Date To',
|
|
@@ -140,8 +187,8 @@ class SearchMessages {
|
|
|
140
187
|
type: 'string',
|
|
141
188
|
required: false,
|
|
142
189
|
default: '',
|
|
143
|
-
description: 'End date
|
|
144
|
-
placeholder: '
|
|
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") }}',
|
|
145
192
|
},
|
|
146
193
|
{
|
|
147
194
|
displayName: 'Items per Page',
|
|
@@ -162,7 +209,8 @@ class SearchMessages {
|
|
|
162
209
|
typeOptions: {
|
|
163
210
|
minValue: 1,
|
|
164
211
|
},
|
|
165
|
-
description: 'Page
|
|
212
|
+
description: 'Page to retrieve (model can navigate: increase to see older messages)',
|
|
213
|
+
placeholder: '={{ $fromAI("Page_Number", "1", "number") }}',
|
|
166
214
|
},
|
|
167
215
|
],
|
|
168
216
|
};
|
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",
|