n8n-nodes-msteams-botframework 1.2.9 → 1.2.11
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.
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MsTeamsBotFrameworkTrigger = void 0;
|
|
4
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
-
const botbuilder_1 = require("botbuilder");
|
|
6
4
|
// Track processed activity IDs to prevent duplicates
|
|
7
5
|
const processedActivities = new Map();
|
|
8
6
|
// Clean up old entries every 5 minutes
|
|
@@ -185,136 +183,109 @@ class MsTeamsBotFrameworkTrigger {
|
|
|
185
183
|
};
|
|
186
184
|
}
|
|
187
185
|
async webhook() {
|
|
188
|
-
|
|
186
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
189
187
|
const req = this.getRequestObject();
|
|
190
188
|
const events = this.getNodeParameter('events', []);
|
|
191
189
|
const options = this.getNodeParameter('options', {});
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
//
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
190
|
+
// Get the activity directly from request body
|
|
191
|
+
const activity = req.body;
|
|
192
|
+
// Check for duplicate activity
|
|
193
|
+
const activityKey = `${activity.id}_${activity.timestamp}`;
|
|
194
|
+
if (processedActivities.has(activityKey)) {
|
|
195
|
+
// Already processed this activity, return 200 OK but don't trigger workflow
|
|
196
|
+
return {
|
|
197
|
+
webhookResponse: { status: 'ok' },
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
// Check if we should process this activity type
|
|
201
|
+
if (!events.includes(activity.type)) {
|
|
202
|
+
return {
|
|
203
|
+
webhookResponse: { status: 'ok' },
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// Ignore bot messages if configured
|
|
207
|
+
if (options.ignoreBotMessages && ((_a = activity.from) === null || _a === void 0 ? void 0 : _a.role) === 'bot') {
|
|
208
|
+
return {
|
|
209
|
+
webhookResponse: { status: 'ok' },
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
// Mark this activity as processed
|
|
213
|
+
processedActivities.set(activityKey, Date.now());
|
|
214
|
+
// Extract useful data from activity
|
|
215
|
+
const activityData = {
|
|
216
|
+
type: activity.type,
|
|
217
|
+
text: activity.text,
|
|
218
|
+
timestamp: activity.timestamp,
|
|
219
|
+
id: activity.id,
|
|
220
|
+
conversation: {
|
|
221
|
+
id: (_b = activity.conversation) === null || _b === void 0 ? void 0 : _b.id,
|
|
222
|
+
name: (_c = activity.conversation) === null || _c === void 0 ? void 0 : _c.name,
|
|
223
|
+
conversationType: (_d = activity.conversation) === null || _d === void 0 ? void 0 : _d.conversationType,
|
|
224
|
+
tenantId: (_e = activity.conversation) === null || _e === void 0 ? void 0 : _e.tenantId,
|
|
225
|
+
},
|
|
226
|
+
from: {
|
|
227
|
+
id: (_f = activity.from) === null || _f === void 0 ? void 0 : _f.id,
|
|
228
|
+
name: (_g = activity.from) === null || _g === void 0 ? void 0 : _g.name,
|
|
229
|
+
aadObjectId: (_h = activity.from) === null || _h === void 0 ? void 0 : _h.aadObjectId,
|
|
230
|
+
role: (_j = activity.from) === null || _j === void 0 ? void 0 : _j.role,
|
|
231
|
+
},
|
|
232
|
+
recipient: {
|
|
233
|
+
id: (_k = activity.recipient) === null || _k === void 0 ? void 0 : _k.id,
|
|
234
|
+
name: (_l = activity.recipient) === null || _l === void 0 ? void 0 : _l.name,
|
|
235
|
+
},
|
|
236
|
+
channelId: activity.channelId,
|
|
237
|
+
serviceUrl: activity.serviceUrl,
|
|
238
|
+
locale: activity.locale,
|
|
239
|
+
};
|
|
240
|
+
// Add type-specific data
|
|
241
|
+
switch (activity.type) {
|
|
242
|
+
case 'message':
|
|
243
|
+
activityData.message = {
|
|
233
244
|
text: activity.text,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
id: (_b = activity.conversation) === null || _b === void 0 ? void 0 : _b.id,
|
|
238
|
-
name: (_c = activity.conversation) === null || _c === void 0 ? void 0 : _c.name,
|
|
239
|
-
conversationType: (_d = activity.conversation) === null || _d === void 0 ? void 0 : _d.conversationType,
|
|
240
|
-
tenantId: (_e = activity.conversation) === null || _e === void 0 ? void 0 : _e.tenantId,
|
|
241
|
-
},
|
|
242
|
-
from: {
|
|
243
|
-
id: (_f = activity.from) === null || _f === void 0 ? void 0 : _f.id,
|
|
244
|
-
name: (_g = activity.from) === null || _g === void 0 ? void 0 : _g.name,
|
|
245
|
-
aadObjectId: (_h = activity.from) === null || _h === void 0 ? void 0 : _h.aadObjectId,
|
|
246
|
-
role: (_j = activity.from) === null || _j === void 0 ? void 0 : _j.role,
|
|
247
|
-
},
|
|
248
|
-
recipient: {
|
|
249
|
-
id: (_k = activity.recipient) === null || _k === void 0 ? void 0 : _k.id,
|
|
250
|
-
name: (_l = activity.recipient) === null || _l === void 0 ? void 0 : _l.name,
|
|
251
|
-
},
|
|
252
|
-
channelId: activity.channelId,
|
|
253
|
-
serviceUrl: activity.serviceUrl,
|
|
254
|
-
locale: activity.locale,
|
|
245
|
+
textFormat: activity.textFormat,
|
|
246
|
+
attachments: activity.attachments,
|
|
247
|
+
mentions: (_m = activity.entities) === null || _m === void 0 ? void 0 : _m.filter((e) => e.type === 'mention'),
|
|
255
248
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
textFormat: activity.textFormat,
|
|
262
|
-
attachments: activity.attachments,
|
|
263
|
-
mentions: (_m = activity.entities) === null || _m === void 0 ? void 0 : _m.filter((e) => e.type === 'mention'),
|
|
264
|
-
};
|
|
265
|
-
break;
|
|
266
|
-
case 'conversationUpdate':
|
|
267
|
-
activityData.conversationUpdate = {
|
|
268
|
-
membersAdded: activity.membersAdded,
|
|
269
|
-
membersRemoved: activity.membersRemoved,
|
|
270
|
-
};
|
|
271
|
-
break;
|
|
272
|
-
case 'messageReaction':
|
|
273
|
-
activityData.messageReaction = {
|
|
274
|
-
reactionsAdded: activity.reactionsAdded,
|
|
275
|
-
reactionsRemoved: activity.reactionsRemoved,
|
|
276
|
-
replyToId: activity.replyToId,
|
|
277
|
-
};
|
|
278
|
-
break;
|
|
279
|
-
case 'messageUpdate':
|
|
280
|
-
activityData.messageUpdate = {
|
|
281
|
-
text: activity.text,
|
|
282
|
-
updatedText: activity.text,
|
|
283
|
-
};
|
|
284
|
-
break;
|
|
285
|
-
case 'messageDelete':
|
|
286
|
-
activityData.messageDelete = {
|
|
287
|
-
deletedMessageId: activity.id,
|
|
288
|
-
};
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
// Include raw activity if requested
|
|
292
|
-
if (options.includeRawActivity) {
|
|
293
|
-
activityData.rawActivity = activity;
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
if (!shouldTrigger || !activityData) {
|
|
297
|
-
// Don't trigger workflow - Bot Framework Adapter already sent 200 OK
|
|
298
|
-
return {
|
|
299
|
-
noWebhookResponse: true,
|
|
249
|
+
break;
|
|
250
|
+
case 'conversationUpdate':
|
|
251
|
+
activityData.conversationUpdate = {
|
|
252
|
+
membersAdded: activity.membersAdded,
|
|
253
|
+
membersRemoved: activity.membersRemoved,
|
|
300
254
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
255
|
+
break;
|
|
256
|
+
case 'messageReaction':
|
|
257
|
+
activityData.messageReaction = {
|
|
258
|
+
reactionsAdded: activity.reactionsAdded,
|
|
259
|
+
reactionsRemoved: activity.reactionsRemoved,
|
|
260
|
+
replyToId: activity.replyToId,
|
|
261
|
+
};
|
|
262
|
+
break;
|
|
263
|
+
case 'messageUpdate':
|
|
264
|
+
activityData.messageUpdate = {
|
|
265
|
+
text: activity.text,
|
|
266
|
+
updatedText: activity.text,
|
|
267
|
+
};
|
|
268
|
+
break;
|
|
269
|
+
case 'messageDelete':
|
|
270
|
+
activityData.messageDelete = {
|
|
271
|
+
deletedMessageId: activity.id,
|
|
272
|
+
};
|
|
273
|
+
break;
|
|
312
274
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
275
|
+
// Include raw activity if requested
|
|
276
|
+
if (options.includeRawActivity) {
|
|
277
|
+
activityData.rawActivity = activity;
|
|
317
278
|
}
|
|
279
|
+
// Return the activity data to the workflow
|
|
280
|
+
return {
|
|
281
|
+
workflowData: [
|
|
282
|
+
[
|
|
283
|
+
{
|
|
284
|
+
json: activityData,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
],
|
|
288
|
+
};
|
|
318
289
|
}
|
|
319
290
|
}
|
|
320
291
|
exports.MsTeamsBotFrameworkTrigger = MsTeamsBotFrameworkTrigger;
|