n8n-nodes-evolution-message-search 1.0.1 → 1.0.3

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.
@@ -7,6 +7,13 @@ class EvolutionApi {
7
7
  this.displayName = 'Evolution API';
8
8
  this.documentationUrl = 'https://docs.evolutionfoundation.com.br/evolution-api';
9
9
  this.properties = [
10
+ {
11
+ displayName: 'Base URL',
12
+ name: 'baseUrl',
13
+ type: 'string',
14
+ default: 'http://localhost:8080',
15
+ description: 'Evolution API server URL (e.g., http://localhost:8080 or https://api.example.com)',
16
+ },
10
17
  {
11
18
  displayName: 'API Key',
12
19
  name: 'apiKey',
@@ -24,7 +31,7 @@ class EvolutionApi {
24
31
  };
25
32
  this.test = {
26
33
  request: {
27
- url: '/instance/connectionStatus',
34
+ url: '=/instance/connectionStatus',
28
35
  method: 'GET',
29
36
  },
30
37
  };
@@ -32,36 +32,19 @@ class SearchMessages {
32
32
  },
33
33
  },
34
34
  properties: [
35
- {
36
- displayName: 'Resource',
37
- name: 'resource',
38
- type: 'hidden',
39
- default: 'messages',
40
- },
41
35
  {
42
36
  displayName: 'Instance Name',
43
37
  name: 'instanceName',
44
38
  type: 'string',
45
39
  required: true,
46
- displayOptions: {
47
- show: {
48
- resource: ['messages'],
49
- },
50
- },
51
40
  description: 'Name of the Evolution API instance (set by user, model cannot change)',
52
- hint: 'The instance name is defined by the user and cannot be modified by the AI model',
53
41
  },
54
42
  {
55
43
  displayName: 'Conversation ID',
56
44
  name: 'conversationId',
57
45
  type: 'string',
58
46
  required: false,
59
- displayOptions: {
60
- show: {
61
- resource: ['messages'],
62
- },
63
- },
64
- description: 'WhatsApp conversation ID (JID). If empty, searches all conversations. Model can use if provided by user.',
47
+ description: 'WhatsApp conversation ID (JID). If empty, searches all conversations.',
65
48
  placeholder: '5511999999999@s.whatsapp.net',
66
49
  },
67
50
  {
@@ -69,97 +52,65 @@ class SearchMessages {
69
52
  name: 'allowModelSetConversation',
70
53
  type: 'boolean',
71
54
  default: false,
72
- displayOptions: {
73
- show: {
74
- resource: ['messages'],
75
- },
76
- },
77
55
  description: 'If enabled, the AI model can set the conversation ID. If disabled, model must use the value provided above.',
78
56
  },
79
57
  {
80
- displayName: 'Search Parameters',
81
- name: 'searchParams',
82
- type: 'fixedCollection',
58
+ displayName: 'Model Conversation ID',
59
+ name: 'modelConversationId',
60
+ type: 'string',
61
+ required: false,
83
62
  displayOptions: {
84
63
  show: {
85
- resource: ['messages'],
64
+ allowModelSetConversation: [true],
86
65
  },
87
66
  },
88
- default: {},
89
- options: [
90
- {
91
- displayName: 'Search Fields',
92
- name: 'fields',
93
- values: [
94
- {
95
- displayName: 'Keywords',
96
- name: 'keywords',
97
- type: 'string',
98
- default: '',
99
- description: 'Search text in message content (model can set)',
100
- },
101
- {
102
- displayName: 'Date From',
103
- name: 'dateFrom',
104
- type: 'dateTime',
105
- default: '',
106
- description: 'Start date for message search (model can set)',
107
- },
108
- {
109
- displayName: 'Date To',
110
- name: 'dateTo',
111
- type: 'dateTime',
112
- default: '',
113
- description: 'End date for message search (model can set)',
114
- },
115
- ],
116
- },
117
- ],
67
+ description: 'Conversation ID that the AI model can set (only used if allowed)',
68
+ placeholder: '5511999999999@s.whatsapp.net',
118
69
  },
119
70
  {
120
- displayName: 'Pagination',
121
- name: 'pagination',
122
- type: 'fixedCollection',
123
- displayOptions: {
124
- show: {
125
- resource: ['messages'],
126
- },
71
+ displayName: 'Keywords',
72
+ name: 'keywords',
73
+ type: 'string',
74
+ required: false,
75
+ default: '',
76
+ description: 'Search text in message content (model can set)',
77
+ },
78
+ {
79
+ displayName: 'Date From',
80
+ name: 'dateFrom',
81
+ type: 'dateTime',
82
+ required: false,
83
+ default: '',
84
+ description: 'Start date for message search (model can set)',
85
+ },
86
+ {
87
+ displayName: 'Date To',
88
+ name: 'dateTo',
89
+ type: 'dateTime',
90
+ required: false,
91
+ default: '',
92
+ description: 'End date for message search (model can set)',
93
+ },
94
+ {
95
+ displayName: 'Items per Page',
96
+ name: 'pageSize',
97
+ type: 'number',
98
+ default: 10,
99
+ typeOptions: {
100
+ minValue: 1,
101
+ maxValue: 100,
127
102
  },
128
- default: {
129
- fields: {
130
- pageSize: 10,
131
- page: 1,
132
- },
103
+ description: 'Number of results per page (set by user, model cannot change)',
104
+ },
105
+ {
106
+ displayName: 'Page Number',
107
+ name: 'page',
108
+ type: 'number',
109
+ default: 1,
110
+ typeOptions: {
111
+ minValue: 1,
133
112
  },
134
- options: [
135
- {
136
- displayName: 'Pagination Fields',
137
- name: 'fields',
138
- values: [
139
- {
140
- displayName: 'Items per Page',
141
- name: 'pageSize',
142
- type: 'number',
143
- default: 10,
144
- typeOptions: {
145
- minValue: 1,
146
- maxValue: 100,
147
- },
148
- description: 'Number of results per page (set by user, model cannot change)',
149
- },
150
- {
151
- displayName: 'Page Number',
152
- name: 'page',
153
- type: 'number',
154
- default: 1,
155
- typeOptions: {
156
- minValue: 1,
157
- },
158
- description: 'Page number to retrieve (model can navigate)',
159
- },
160
- ],
161
- },
162
- ],
113
+ description: 'Page number to retrieve (model can navigate)',
163
114
  },
164
115
  ],
165
116
  };
@@ -169,36 +120,35 @@ class SearchMessages {
169
120
  const returnData = [];
170
121
  for (let i = 0; i < items.length; i++) {
171
122
  const instanceName = executeFunctions.getNodeParameter('instanceName', i);
172
- const userConversationId = executeFunctions.getNodeParameter('conversationId', i);
123
+ const userConversationId = executeFunctions.getNodeParameter('conversationId', i) || '';
173
124
  const allowModelSetConversation = executeFunctions.getNodeParameter('allowModelSetConversation', i);
174
- const searchParamsRaw = executeFunctions.getNodeParameter('searchParams', i) || {};
175
- const paginationRaw = executeFunctions.getNodeParameter('pagination', i) || {};
176
- const searchParams = searchParamsRaw.fields || {};
177
- const pagination = paginationRaw.fields || { pageSize: 10, page: 1 };
178
125
  let conversationId = userConversationId;
179
126
  if (!conversationId && allowModelSetConversation) {
180
- conversationId = executeFunctions.getNodeParameter('modelConversationId', i, '');
127
+ conversationId = executeFunctions.getNodeParameter('modelConversationId', i) || '';
181
128
  }
182
- const pageSize = pagination.pageSize;
183
- const page = pagination.page;
129
+ const keywords = executeFunctions.getNodeParameter('keywords', i) || '';
130
+ const dateFrom = executeFunctions.getNodeParameter('dateFrom', i) || '';
131
+ const dateTo = executeFunctions.getNodeParameter('dateTo', i) || '';
132
+ const pageSize = executeFunctions.getNodeParameter('pageSize', i) || 10;
133
+ const page = executeFunctions.getNodeParameter('page', i) || 1;
184
134
  const skip = (page - 1) * pageSize;
185
135
  const whereClause = {};
186
136
  if (conversationId) {
187
137
  whereClause['key.remote'] = conversationId;
188
138
  }
189
- if (searchParams.keywords) {
139
+ if (keywords) {
190
140
  whereClause['message.conversationMessage.text'] = {
191
- contains: searchParams.keywords,
141
+ contains: keywords,
192
142
  };
193
143
  }
194
- if (searchParams.dateFrom || searchParams.dateTo) {
144
+ if (dateFrom || dateTo) {
195
145
  whereClause['timestamp'] = {};
196
- if (searchParams.dateFrom) {
197
- const fromTimestamp = new Date(searchParams.dateFrom).getTime() / 1000;
146
+ if (dateFrom) {
147
+ const fromTimestamp = new Date(dateFrom).getTime() / 1000;
198
148
  whereClause['timestamp']['gte'] = fromTimestamp;
199
149
  }
200
- if (searchParams.dateTo) {
201
- const toTimestamp = new Date(searchParams.dateTo).getTime() / 1000;
150
+ if (dateTo) {
151
+ const toTimestamp = new Date(dateTo).getTime() / 1000;
202
152
  whereClause['timestamp']['lte'] = toTimestamp;
203
153
  }
204
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-evolution-message-search",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
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",