n8n-nodes-evolution-message-search 2.0.0 → 2.0.2
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.
|
@@ -13,7 +13,7 @@ class SearchMessages {
|
|
|
13
13
|
icon: 'file:icon.svg',
|
|
14
14
|
group: ['transform'],
|
|
15
15
|
version: 1,
|
|
16
|
-
subtitle: '
|
|
16
|
+
subtitle: 'Search WhatsApp message history',
|
|
17
17
|
description: 'Search WhatsApp message history via Evolution API',
|
|
18
18
|
defaults: {
|
|
19
19
|
name: 'Evolution API - Search Messages',
|
|
@@ -42,7 +42,7 @@ class SearchMessages {
|
|
|
42
42
|
type: 'string',
|
|
43
43
|
required: false,
|
|
44
44
|
default: '',
|
|
45
|
-
description: 'WhatsApp conversation ID (JID). If empty, searches all conversations.
|
|
45
|
+
description: 'WhatsApp conversation ID (JID). If empty, searches all conversations.',
|
|
46
46
|
placeholder: '5511999999999@s.whatsapp.net',
|
|
47
47
|
},
|
|
48
48
|
{
|
|
@@ -50,7 +50,7 @@ class SearchMessages {
|
|
|
50
50
|
name: 'allowModelSetConversation',
|
|
51
51
|
type: 'boolean',
|
|
52
52
|
default: false,
|
|
53
|
-
description: 'If enabled, the AI model can set the conversation ID',
|
|
53
|
+
description: 'If enabled, the AI model can set the conversation ID via $fromAI()',
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
displayName: 'Keywords',
|
|
@@ -63,18 +63,20 @@ class SearchMessages {
|
|
|
63
63
|
{
|
|
64
64
|
displayName: 'Date From',
|
|
65
65
|
name: 'dateFrom',
|
|
66
|
-
type: '
|
|
66
|
+
type: 'string',
|
|
67
67
|
required: false,
|
|
68
68
|
default: '',
|
|
69
69
|
description: 'Start date for message search (model can set)',
|
|
70
|
+
placeholder: '2024-01-01T00:00:00Z',
|
|
70
71
|
},
|
|
71
72
|
{
|
|
72
73
|
displayName: 'Date To',
|
|
73
74
|
name: 'dateTo',
|
|
74
|
-
type: '
|
|
75
|
+
type: 'string',
|
|
75
76
|
required: false,
|
|
76
77
|
default: '',
|
|
77
78
|
description: 'End date for message search (model can set)',
|
|
79
|
+
placeholder: '2024-12-31T23:59:59Z',
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
displayName: 'Items per Page',
|
|
@@ -102,40 +104,31 @@ class SearchMessages {
|
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
async execute() {
|
|
105
|
-
const items = this.getInputData();
|
|
107
|
+
const items = this.getInputData ? this.getInputData() : [];
|
|
106
108
|
const returnData = [];
|
|
107
109
|
|
|
108
|
-
for (let
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
for (let itemIndex = 0; itemIndex < (items.length || 1); itemIndex++) {
|
|
111
|
+
try {
|
|
112
|
+
const result = await this.executeSingle.call(this, itemIndex);
|
|
113
|
+
returnData.push({
|
|
114
|
+
json: result,
|
|
115
|
+
pairedItem: { item: itemIndex },
|
|
116
|
+
});
|
|
117
|
+
} catch (err) {
|
|
118
|
+
if (this.continueOnFail && this.continueOnFail()) {
|
|
119
|
+
returnData.push({
|
|
120
|
+
json: { error: err.message },
|
|
121
|
+
pairedItem: { item: itemIndex },
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
114
127
|
}
|
|
115
128
|
|
|
116
129
|
return [returnData];
|
|
117
130
|
}
|
|
118
131
|
|
|
119
|
-
async supplyData(itemIndex) {
|
|
120
|
-
const result = await this.executeSingle.call(this, itemIndex);
|
|
121
|
-
return {
|
|
122
|
-
response: {
|
|
123
|
-
name: this.getNode().name,
|
|
124
|
-
description: 'Search WhatsApp message history',
|
|
125
|
-
invoke: async (input) => {
|
|
126
|
-
if (typeof input === 'object' && input !== null) {
|
|
127
|
-
for (const key of ['keywords', 'dateFrom', 'dateTo', 'page', 'conversationId']) {
|
|
128
|
-
if (input[key] !== undefined && input[key] !== null) {
|
|
129
|
-
this.getNodeParameter;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return JSON.stringify(result);
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
132
|
async executeSingle(itemIndex) {
|
|
140
133
|
const credentials = await this.getCredentials('evolutionApi');
|
|
141
134
|
const serverUrl = credentials['server-url'];
|
|
@@ -143,27 +136,21 @@ class SearchMessages {
|
|
|
143
136
|
|
|
144
137
|
const instanceName = this.getNodeParameter('instanceName', itemIndex);
|
|
145
138
|
const userConversationId = this.getNodeParameter('conversationId', itemIndex) || '';
|
|
146
|
-
const allowModelSetConversation = this.getNodeParameter('allowModelSetConversation', itemIndex);
|
|
147
139
|
const keywords = this.getNodeParameter('keywords', itemIndex) || '';
|
|
148
140
|
const dateFrom = this.getNodeParameter('dateFrom', itemIndex) || '';
|
|
149
141
|
const dateTo = this.getNodeParameter('dateTo', itemIndex) || '';
|
|
150
142
|
const pageSize = this.getNodeParameter('pageSize', itemIndex) || 10;
|
|
151
143
|
const page = this.getNodeParameter('page', itemIndex) || 1;
|
|
152
144
|
|
|
153
|
-
const conversationId = userConversationId;
|
|
154
145
|
const skip = (page - 1) * pageSize;
|
|
155
146
|
|
|
156
147
|
const whereClause = {};
|
|
157
|
-
if (
|
|
158
|
-
whereClause['key.remote'] =
|
|
159
|
-
} else if (conversationId) {
|
|
160
|
-
whereClause['key.remote'] = conversationId;
|
|
148
|
+
if (userConversationId) {
|
|
149
|
+
whereClause['key.remote'] = userConversationId;
|
|
161
150
|
}
|
|
162
|
-
|
|
163
151
|
if (keywords) {
|
|
164
152
|
whereClause['message.conversationMessage.text'] = { contains: keywords };
|
|
165
153
|
}
|
|
166
|
-
|
|
167
154
|
if (dateFrom || dateTo) {
|
|
168
155
|
whereClause['timestamp'] = {};
|
|
169
156
|
if (dateFrom) {
|
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.2",
|
|
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",
|