n8n-nodes-microsoft-teams-bot 1.0.0
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.
- package/dist/credentials/TeamsBotApi.credentials.d.ts +7 -0
- package/dist/credentials/TeamsBotApi.credentials.js +107 -0
- package/dist/credentials/TeamsBotApi.credentials.js.map +1 -0
- package/dist/credentials/TeamsGraphApi.credentials.d.ts +7 -0
- package/dist/credentials/TeamsGraphApi.credentials.js +58 -0
- package/dist/credentials/TeamsGraphApi.credentials.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/TeamsBot/TeamsBot.node.d.ts +21 -0
- package/dist/nodes/TeamsBot/TeamsBot.node.js +457 -0
- package/dist/nodes/TeamsBot/TeamsBot.node.js.map +1 -0
- package/dist/nodes/TeamsBot/TeamsBot.node.json +73 -0
- package/dist/nodes/TeamsBot/TeamsBotTrigger.node.d.ts +21 -0
- package/dist/nodes/TeamsBot/TeamsBotTrigger.node.js +506 -0
- package/dist/nodes/TeamsBot/TeamsBotTrigger.node.js.map +1 -0
- package/dist/nodes/TeamsBot/TeamsBotTrigger.node.json +57 -0
- package/dist/nodes/TeamsBot/actions/buildCard.d.ts +6 -0
- package/dist/nodes/TeamsBot/actions/buildCard.js +176 -0
- package/dist/nodes/TeamsBot/actions/buildCard.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/cards.d.ts +34 -0
- package/dist/nodes/TeamsBot/actions/cards.js +731 -0
- package/dist/nodes/TeamsBot/actions/cards.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/channels.d.ts +18 -0
- package/dist/nodes/TeamsBot/actions/channels.js +199 -0
- package/dist/nodes/TeamsBot/actions/channels.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/messages.d.ts +86 -0
- package/dist/nodes/TeamsBot/actions/messages.js +1259 -0
- package/dist/nodes/TeamsBot/actions/messages.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/router.d.ts +2 -0
- package/dist/nodes/TeamsBot/actions/router.js +186 -0
- package/dist/nodes/TeamsBot/actions/router.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/teams.d.ts +18 -0
- package/dist/nodes/TeamsBot/actions/teams.js +227 -0
- package/dist/nodes/TeamsBot/actions/teams.js.map +1 -0
- package/dist/nodes/TeamsBot/actions/users.d.ts +13 -0
- package/dist/nodes/TeamsBot/actions/users.js +184 -0
- package/dist/nodes/TeamsBot/actions/users.js.map +1 -0
- package/dist/nodes/TeamsBot/descriptions/buildCard.description.d.ts +7 -0
- package/dist/nodes/TeamsBot/descriptions/buildCard.description.js +682 -0
- package/dist/nodes/TeamsBot/descriptions/buildCard.description.js.map +1 -0
- package/dist/nodes/TeamsBot/descriptions/card.description.d.ts +2 -0
- package/dist/nodes/TeamsBot/descriptions/card.description.js +564 -0
- package/dist/nodes/TeamsBot/descriptions/card.description.js.map +1 -0
- package/dist/nodes/TeamsBot/descriptions/index.d.ts +3 -0
- package/dist/nodes/TeamsBot/descriptions/index.js +20 -0
- package/dist/nodes/TeamsBot/descriptions/index.js.map +1 -0
- package/dist/nodes/TeamsBot/descriptions/message.description.d.ts +2 -0
- package/dist/nodes/TeamsBot/descriptions/message.description.js +964 -0
- package/dist/nodes/TeamsBot/descriptions/message.description.js.map +1 -0
- package/dist/nodes/TeamsBot/descriptions/node.description.d.ts +2 -0
- package/dist/nodes/TeamsBot/descriptions/node.description.js +567 -0
- package/dist/nodes/TeamsBot/descriptions/node.description.js.map +1 -0
- package/dist/nodes/TeamsBot/errors/authentication.d.ts +100 -0
- package/dist/nodes/TeamsBot/errors/authentication.js +110 -0
- package/dist/nodes/TeamsBot/errors/authentication.js.map +1 -0
- package/dist/nodes/TeamsBot/errors/graphApi.d.ts +44 -0
- package/dist/nodes/TeamsBot/errors/graphApi.js +84 -0
- package/dist/nodes/TeamsBot/errors/graphApi.js.map +1 -0
- package/dist/nodes/TeamsBot/errors/messages.d.ts +187 -0
- package/dist/nodes/TeamsBot/errors/messages.js +190 -0
- package/dist/nodes/TeamsBot/errors/messages.js.map +1 -0
- package/dist/nodes/TeamsBot/methods/listSearch.d.ts +4 -0
- package/dist/nodes/TeamsBot/methods/listSearch.js +78 -0
- package/dist/nodes/TeamsBot/methods/listSearch.js.map +1 -0
- package/dist/nodes/TeamsBot/teams.svg +11 -0
- package/dist/nodes/TeamsBot/transport/TeamsApiClient.d.ts +305 -0
- package/dist/nodes/TeamsBot/transport/TeamsApiClient.js +458 -0
- package/dist/nodes/TeamsBot/transport/TeamsApiClient.js.map +1 -0
- package/dist/nodes/TeamsBot/transport/api/BotFrameworkApi.d.ts +350 -0
- package/dist/nodes/TeamsBot/transport/api/BotFrameworkApi.js +1265 -0
- package/dist/nodes/TeamsBot/transport/api/BotFrameworkApi.js.map +1 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApi.d.ts +158 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApi.js +443 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApi.js.map +1 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApiClient.d.ts +160 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApiClient.js +268 -0
- package/dist/nodes/TeamsBot/transport/api/GraphApiClient.js.map +1 -0
- package/dist/nodes/TeamsBot/transport/api/index.d.ts +7 -0
- package/dist/nodes/TeamsBot/transport/api/index.js +26 -0
- package/dist/nodes/TeamsBot/transport/api/index.js.map +1 -0
- package/dist/nodes/TeamsBot/transport/index.d.ts +12 -0
- package/dist/nodes/TeamsBot/transport/index.js +30 -0
- package/dist/nodes/TeamsBot/transport/index.js.map +1 -0
- package/dist/nodes/TeamsBot/types/api-types.d.ts +258 -0
- package/dist/nodes/TeamsBot/types/api-types.js +3 -0
- package/dist/nodes/TeamsBot/types/api-types.js.map +1 -0
- package/dist/nodes/TeamsBot/types/cards.d.ts +252 -0
- package/dist/nodes/TeamsBot/types/cards.js +3 -0
- package/dist/nodes/TeamsBot/types/cards.js.map +1 -0
- package/dist/nodes/TeamsBot/types/index.d.ts +5 -0
- package/dist/nodes/TeamsBot/types/index.js +24 -0
- package/dist/nodes/TeamsBot/types/index.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardBuilder.d.ts +147 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardBuilder.js +333 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardBuilder.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardTemplates.d.ts +122 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardTemplates.js +467 -0
- package/dist/nodes/TeamsBot/utils/AdaptiveCardTemplates.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/CardTemplates.d.ts +94 -0
- package/dist/nodes/TeamsBot/utils/CardTemplates.js +446 -0
- package/dist/nodes/TeamsBot/utils/CardTemplates.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/apiHelpers.d.ts +30 -0
- package/dist/nodes/TeamsBot/utils/apiHelpers.js +95 -0
- package/dist/nodes/TeamsBot/utils/apiHelpers.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/constants.d.ts +86 -0
- package/dist/nodes/TeamsBot/utils/constants.js +60 -0
- package/dist/nodes/TeamsBot/utils/constants.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/fileProcessing.d.ts +66 -0
- package/dist/nodes/TeamsBot/utils/fileProcessing.js +276 -0
- package/dist/nodes/TeamsBot/utils/fileProcessing.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/graphNotificationParser.d.ts +91 -0
- package/dist/nodes/TeamsBot/utils/graphNotificationParser.js +162 -0
- package/dist/nodes/TeamsBot/utils/graphNotificationParser.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/index.d.ts +24 -0
- package/dist/nodes/TeamsBot/utils/index.js +90 -0
- package/dist/nodes/TeamsBot/utils/index.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/installation.d.ts +15 -0
- package/dist/nodes/TeamsBot/utils/installation.js +41 -0
- package/dist/nodes/TeamsBot/utils/installation.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/subscriptionManager.d.ts +63 -0
- package/dist/nodes/TeamsBot/utils/subscriptionManager.js +100 -0
- package/dist/nodes/TeamsBot/utils/subscriptionManager.js.map +1 -0
- package/dist/nodes/TeamsBot/utils/validation.d.ts +93 -0
- package/dist/nodes/TeamsBot/utils/validation.js +281 -0
- package/dist/nodes/TeamsBot/utils/validation.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeamsBotTrigger = void 0;
|
|
4
|
+
const index_1 = require("./transport/index");
|
|
5
|
+
const graphNotificationParser_1 = require("./utils/graphNotificationParser");
|
|
6
|
+
const subscriptionManager_1 = require("./utils/subscriptionManager");
|
|
7
|
+
/**
|
|
8
|
+
* Checks if an incoming message matches a waiting response from sendAndWait
|
|
9
|
+
* @param {IDataObject} workflowStaticData - Workflow static data containing waitingResponses
|
|
10
|
+
* @param {ParsedNotification} notification - Parsed notification from Graph API
|
|
11
|
+
* @param {any} resourceData - Full resource data (message details)
|
|
12
|
+
* @param {IDataObject} standardEvent - Normalized event data
|
|
13
|
+
* @returns {any | null} Matched wait context or null if no match
|
|
14
|
+
*/
|
|
15
|
+
function checkForWaitingResponse(workflowStaticData, notification, resourceData, standardEvent) {
|
|
16
|
+
// Check if there are any waiting responses
|
|
17
|
+
if (!workflowStaticData.waitingResponses || typeof workflowStaticData.waitingResponses !== 'object') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const waitingResponses = workflowStaticData.waitingResponses;
|
|
21
|
+
// Extract conversation ID and replyToId from the message
|
|
22
|
+
const conversationId = notification.chatId || notification.channelId;
|
|
23
|
+
const replyToId = resourceData === null || resourceData === void 0 ? void 0 : resourceData.replyToId;
|
|
24
|
+
// Check each waiting response for a match
|
|
25
|
+
for (const [originalMessageId, waitContext] of Object.entries(waitingResponses)) {
|
|
26
|
+
// Match by conversation ID and check if this is a reply to the original message
|
|
27
|
+
const conversationMatches = waitContext.conversationId === conversationId ||
|
|
28
|
+
(waitContext.teamId && waitContext.channelId &&
|
|
29
|
+
notification.teamId === waitContext.teamId &&
|
|
30
|
+
notification.channelId === waitContext.channelId) ||
|
|
31
|
+
(waitContext.userId && notification.chatId);
|
|
32
|
+
// Check if this message is a reply to the original message
|
|
33
|
+
const isReplyToOriginal = replyToId === originalMessageId || replyToId === waitContext.originalMessageId;
|
|
34
|
+
if (conversationMatches && isReplyToOriginal) {
|
|
35
|
+
// Match found - remove from waiting responses
|
|
36
|
+
delete waitingResponses[originalMessageId];
|
|
37
|
+
return waitContext;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Cleans up expired waiting responses
|
|
44
|
+
* @param {IDataObject} workflowStaticData - Workflow static data containing waitingResponses
|
|
45
|
+
* @param {any} logger - Logger instance for logging cleanup actions
|
|
46
|
+
*/
|
|
47
|
+
function cleanupExpiredWaitingResponses(workflowStaticData, logger) {
|
|
48
|
+
if (!workflowStaticData.waitingResponses || typeof workflowStaticData.waitingResponses !== 'object') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const waitingResponses = workflowStaticData.waitingResponses;
|
|
52
|
+
const now = Date.now();
|
|
53
|
+
// Remove expired waiting responses
|
|
54
|
+
for (const [messageId, waitContext] of Object.entries(waitingResponses)) {
|
|
55
|
+
if (waitContext.timeout && waitContext.timeout < now) {
|
|
56
|
+
delete waitingResponses[messageId];
|
|
57
|
+
logger.info(`Cleaned up expired waiting response: ${messageId}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Teams Bot Trigger Node
|
|
63
|
+
*
|
|
64
|
+
* This node provides webhook functionality for receiving Teams events via Microsoft Graph API subscriptions.
|
|
65
|
+
* It listens for incoming notifications from Graph API and triggers workflows based on Teams message events.
|
|
66
|
+
*/
|
|
67
|
+
class TeamsBotTrigger {
|
|
68
|
+
constructor() {
|
|
69
|
+
this.description = {
|
|
70
|
+
displayName: 'Microsoft Teams Bot Trigger',
|
|
71
|
+
name: 'teamsBotTrigger',
|
|
72
|
+
icon: 'file:teams.svg',
|
|
73
|
+
group: ['trigger'],
|
|
74
|
+
version: 2,
|
|
75
|
+
subtitle: '={{$parameter["subscriptionType"]}}',
|
|
76
|
+
description: 'Triggers workflows when Teams messages are created, updated, or deleted via Microsoft Graph API subscriptions',
|
|
77
|
+
defaults: {
|
|
78
|
+
name: 'Teams Bot Trigger',
|
|
79
|
+
},
|
|
80
|
+
credentials: [
|
|
81
|
+
{
|
|
82
|
+
name: 'teamsGraphApi',
|
|
83
|
+
required: true,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
inputs: [],
|
|
87
|
+
outputs: ["main" /* NodeConnectionType.Main */],
|
|
88
|
+
webhooks: [
|
|
89
|
+
{
|
|
90
|
+
name: 'default',
|
|
91
|
+
httpMethod: 'POST',
|
|
92
|
+
responseMode: 'responseNode',
|
|
93
|
+
path: 'webhook',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
properties: [
|
|
97
|
+
{
|
|
98
|
+
displayName: 'Subscription Type',
|
|
99
|
+
name: 'subscriptionType',
|
|
100
|
+
type: 'options',
|
|
101
|
+
default: 'specificChannel',
|
|
102
|
+
options: [
|
|
103
|
+
{
|
|
104
|
+
name: 'Specific Channel Messages',
|
|
105
|
+
value: 'specificChannel',
|
|
106
|
+
description: 'Receive messages from a specific channel (FREE)',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'Specific Chat Messages',
|
|
110
|
+
value: 'specificChat',
|
|
111
|
+
description: 'Receive messages from a specific chat (FREE)',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'All Tenant Chat Messages',
|
|
115
|
+
value: 'allChats',
|
|
116
|
+
description: 'Receive all chat messages in tenant (REQUIRES LICENSING)',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'All Tenant Channel Messages',
|
|
120
|
+
value: 'allChannels',
|
|
121
|
+
description: 'Receive all channel messages in tenant (REQUIRES LICENSING)',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
description: 'Type of subscription to create',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
displayName: 'Team ID',
|
|
128
|
+
name: 'teamId',
|
|
129
|
+
type: 'string',
|
|
130
|
+
required: true,
|
|
131
|
+
default: '',
|
|
132
|
+
displayOptions: {
|
|
133
|
+
show: {
|
|
134
|
+
subscriptionType: ['specificChannel'],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
description: 'ID of the team containing the channel',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
displayName: 'Channel ID',
|
|
141
|
+
name: 'channelId',
|
|
142
|
+
type: 'string',
|
|
143
|
+
required: true,
|
|
144
|
+
default: '',
|
|
145
|
+
displayOptions: {
|
|
146
|
+
show: {
|
|
147
|
+
subscriptionType: ['specificChannel'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
description: 'ID of the channel to monitor',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
displayName: 'Chat ID',
|
|
154
|
+
name: 'chatId',
|
|
155
|
+
type: 'string',
|
|
156
|
+
required: true,
|
|
157
|
+
default: '',
|
|
158
|
+
displayOptions: {
|
|
159
|
+
show: {
|
|
160
|
+
subscriptionType: ['specificChat'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
description: 'ID of the chat to monitor',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
displayName: 'Event Types',
|
|
167
|
+
name: 'changeTypes',
|
|
168
|
+
type: 'multiOptions',
|
|
169
|
+
required: true,
|
|
170
|
+
default: ['created'],
|
|
171
|
+
options: [
|
|
172
|
+
{
|
|
173
|
+
name: 'Created',
|
|
174
|
+
value: 'created',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: 'Updated',
|
|
178
|
+
value: 'updated',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: 'Deleted',
|
|
182
|
+
value: 'deleted',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
description: 'Types of changes to listen for',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Payment Model',
|
|
189
|
+
name: 'paymentModel',
|
|
190
|
+
type: 'options',
|
|
191
|
+
default: 'evaluation',
|
|
192
|
+
displayOptions: {
|
|
193
|
+
show: {
|
|
194
|
+
subscriptionType: ['allChats', 'allChannels'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
options: [
|
|
198
|
+
{
|
|
199
|
+
name: 'Evaluation Mode (Free - Testing Only)',
|
|
200
|
+
value: 'evaluation',
|
|
201
|
+
description: 'Free tier with throttling limits - NOT FOR PRODUCTION',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'Model A (Seeded Capacity)',
|
|
205
|
+
value: 'A',
|
|
206
|
+
description: 'Based on license count with pay-as-you-go overages',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'Model B (Pay-as-you-go)',
|
|
210
|
+
value: 'B',
|
|
211
|
+
description: 'Per-notification billing',
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
description: 'Payment model for licensed endpoints',
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
displayName: 'Include Full Message Data',
|
|
218
|
+
name: 'includeResourceData',
|
|
219
|
+
type: 'boolean',
|
|
220
|
+
default: false,
|
|
221
|
+
description: 'Whether to include full message content in notifications (requires certificate for encryption)',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
displayName: 'Filters',
|
|
225
|
+
name: 'filters',
|
|
226
|
+
type: 'collection',
|
|
227
|
+
placeholder: 'Add Filter',
|
|
228
|
+
default: {},
|
|
229
|
+
options: [
|
|
230
|
+
{
|
|
231
|
+
displayName: 'Message Contains',
|
|
232
|
+
name: 'messageContains',
|
|
233
|
+
type: 'string',
|
|
234
|
+
default: '',
|
|
235
|
+
description: 'Only trigger if message contains this text (case insensitive)',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
displayName: 'Sender Email',
|
|
239
|
+
name: 'senderEmail',
|
|
240
|
+
type: 'string',
|
|
241
|
+
default: '',
|
|
242
|
+
description: 'Only trigger if message is from this user email',
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
description: 'Optional filters to apply to notifications',
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Webhook lifecycle methods for subscription management
|
|
251
|
+
*/
|
|
252
|
+
this.webhookMethods = {
|
|
253
|
+
default: {
|
|
254
|
+
async checkExists() {
|
|
255
|
+
const subscriptionManager = new subscriptionManager_1.SubscriptionManager(this);
|
|
256
|
+
const subscription = subscriptionManager.getSubscription();
|
|
257
|
+
if (!(subscription === null || subscription === void 0 ? void 0 : subscription.subscriptionId)) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
// Verify subscription still exists in Graph API
|
|
261
|
+
try {
|
|
262
|
+
const credentials = await this.getCredentials('teamsGraphApi');
|
|
263
|
+
const graphClient = new index_1.GraphApiClient(this, credentials);
|
|
264
|
+
await graphClient.getSubscription(subscription.subscriptionId);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
// Subscription doesn't exist
|
|
269
|
+
subscriptionManager.clearSubscription();
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
async create() {
|
|
274
|
+
const credentials = await this.getCredentials('teamsGraphApi');
|
|
275
|
+
const webhookUrl = this.getNodeWebhookUrl('default');
|
|
276
|
+
// Get parameters
|
|
277
|
+
const subscriptionType = this.getNodeParameter('subscriptionType');
|
|
278
|
+
const changeTypes = this.getNodeParameter('changeTypes');
|
|
279
|
+
const teamId = this.getNodeParameter('teamId', '');
|
|
280
|
+
const channelId = this.getNodeParameter('channelId', '');
|
|
281
|
+
const chatId = this.getNodeParameter('chatId', '');
|
|
282
|
+
const paymentModel = this.getNodeParameter('paymentModel', 'evaluation');
|
|
283
|
+
const includeResourceData = this.getNodeParameter('includeResourceData', false);
|
|
284
|
+
// Build resource URL
|
|
285
|
+
let resource = '';
|
|
286
|
+
switch (subscriptionType) {
|
|
287
|
+
case 'specificChannel':
|
|
288
|
+
resource = `/teams/${teamId}/channels/${channelId}/messages`;
|
|
289
|
+
break;
|
|
290
|
+
case 'specificChat':
|
|
291
|
+
resource = `/chats/${chatId}/messages`;
|
|
292
|
+
break;
|
|
293
|
+
case 'allChats':
|
|
294
|
+
resource = paymentModel === 'evaluation'
|
|
295
|
+
? '/chats/getAllMessages'
|
|
296
|
+
: `/chats/getAllMessages?model=${paymentModel}`;
|
|
297
|
+
break;
|
|
298
|
+
case 'allChannels':
|
|
299
|
+
resource = paymentModel === 'evaluation'
|
|
300
|
+
? '/teams/getAllMessages'
|
|
301
|
+
: `/teams/getAllMessages?model=${paymentModel}`;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
// Generate client state
|
|
305
|
+
const subscriptionManager = new subscriptionManager_1.SubscriptionManager(this);
|
|
306
|
+
const clientState = subscriptionManager.generateClientState();
|
|
307
|
+
// Calculate expiration (1 hour from now)
|
|
308
|
+
const expirationDateTime = subscriptionManager.calculateExpiryTime(60);
|
|
309
|
+
// Build subscription parameters
|
|
310
|
+
const params = {
|
|
311
|
+
changeType: changeTypes.join(','),
|
|
312
|
+
notificationUrl: webhookUrl,
|
|
313
|
+
resource,
|
|
314
|
+
expirationDateTime,
|
|
315
|
+
clientState,
|
|
316
|
+
lifecycleNotificationUrl: webhookUrl, // Required for >1 hour subscriptions
|
|
317
|
+
};
|
|
318
|
+
// Add encryption if includeResourceData requested
|
|
319
|
+
if (includeResourceData) {
|
|
320
|
+
const certificatePem = credentials.certificatePem;
|
|
321
|
+
if (!certificatePem) {
|
|
322
|
+
throw new Error('Certificate required for includeResourceData=true. Add certificate in credentials.');
|
|
323
|
+
}
|
|
324
|
+
params.includeResourceData = true;
|
|
325
|
+
params.encryptionCertificate = Buffer.from(certificatePem).toString('base64');
|
|
326
|
+
params.encryptionCertificateId = credentials.certificateThumbprint || 'default';
|
|
327
|
+
}
|
|
328
|
+
// Create subscription
|
|
329
|
+
const graphClient = new index_1.GraphApiClient(this, credentials);
|
|
330
|
+
const subscription = await graphClient.createSubscription(params);
|
|
331
|
+
// Store subscription metadata
|
|
332
|
+
subscriptionManager.storeSubscription({
|
|
333
|
+
subscriptionId: subscription.id,
|
|
334
|
+
expirationDateTime: subscription.expirationDateTime,
|
|
335
|
+
resource,
|
|
336
|
+
changeType: changeTypes.join(','),
|
|
337
|
+
notificationUrl: webhookUrl,
|
|
338
|
+
clientState,
|
|
339
|
+
lastRenewalCheck: Date.now(),
|
|
340
|
+
createdAt: Date.now(),
|
|
341
|
+
});
|
|
342
|
+
return true;
|
|
343
|
+
},
|
|
344
|
+
async delete() {
|
|
345
|
+
const subscriptionManager = new subscriptionManager_1.SubscriptionManager(this);
|
|
346
|
+
const subscription = subscriptionManager.getSubscription();
|
|
347
|
+
if (!(subscription === null || subscription === void 0 ? void 0 : subscription.subscriptionId)) {
|
|
348
|
+
return true; // Already deleted
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
const credentials = await this.getCredentials('teamsGraphApi');
|
|
352
|
+
const graphClient = new index_1.GraphApiClient(this, credentials);
|
|
353
|
+
await graphClient.deleteSubscription(subscription.subscriptionId);
|
|
354
|
+
}
|
|
355
|
+
catch (error) {
|
|
356
|
+
// Log but don't fail - subscription might already be deleted
|
|
357
|
+
this.logger.warn(`Failed to delete subscription: ${error}`);
|
|
358
|
+
}
|
|
359
|
+
// Clear storage
|
|
360
|
+
subscriptionManager.clearSubscription();
|
|
361
|
+
return true;
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
async webhook() {
|
|
367
|
+
var _a, _b, _c;
|
|
368
|
+
const req = this.getRequestObject();
|
|
369
|
+
const res = this.getResponseObject();
|
|
370
|
+
try {
|
|
371
|
+
// Handle Graph API validation request
|
|
372
|
+
const validationToken = req.query.validationToken;
|
|
373
|
+
if (validationToken) {
|
|
374
|
+
// Must respond within 10 seconds with plain text token
|
|
375
|
+
res.status(200).contentType('text/plain').send(validationToken);
|
|
376
|
+
return { noWebhookResponse: true };
|
|
377
|
+
}
|
|
378
|
+
// Get credentials and parameters
|
|
379
|
+
const credentials = await this.getCredentials('teamsGraphApi');
|
|
380
|
+
const subscriptionType = this.getNodeParameter('subscriptionType');
|
|
381
|
+
const changeTypes = this.getNodeParameter('changeTypes');
|
|
382
|
+
const filters = this.getNodeParameter('filters', {});
|
|
383
|
+
const includeResourceData = this.getNodeParameter('includeResourceData', false);
|
|
384
|
+
// Parse Graph API notification
|
|
385
|
+
const body = req.body;
|
|
386
|
+
const parser = new graphNotificationParser_1.GraphNotificationParser();
|
|
387
|
+
const notifications = parser.parseNotification(body);
|
|
388
|
+
if (notifications.length === 0) {
|
|
389
|
+
// No valid notifications
|
|
390
|
+
res.status(202).json({ status: 'Accepted' });
|
|
391
|
+
return { noWebhookResponse: true };
|
|
392
|
+
}
|
|
393
|
+
// Get stored subscription metadata
|
|
394
|
+
const subscriptionManager = new subscriptionManager_1.SubscriptionManager(this);
|
|
395
|
+
const storedSubscription = subscriptionManager.getSubscription();
|
|
396
|
+
// Validate clientState matches (security check)
|
|
397
|
+
for (const notification of notifications) {
|
|
398
|
+
if (!storedSubscription || notification.clientState !== storedSubscription.clientState) {
|
|
399
|
+
res.status(403).json({ error: 'Invalid clientState' });
|
|
400
|
+
return { noWebhookResponse: true };
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// Check if subscription needs renewal
|
|
404
|
+
if (storedSubscription && subscriptionManager.shouldRenew()) {
|
|
405
|
+
try {
|
|
406
|
+
const graphClient = new index_1.GraphApiClient(this, credentials);
|
|
407
|
+
const newExpirationDateTime = subscriptionManager.calculateExpiryTime(60);
|
|
408
|
+
await graphClient.renewSubscription(storedSubscription.subscriptionId, {
|
|
409
|
+
expirationDateTime: newExpirationDateTime,
|
|
410
|
+
});
|
|
411
|
+
subscriptionManager.updateExpiration(newExpirationDateTime);
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
this.logger.error(`Failed to renew subscription: ${error}`);
|
|
415
|
+
// Don't throw - subscription might still be valid
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// Get workflow static data to check for waiting responses
|
|
419
|
+
const workflowStaticData = this.getWorkflowStaticData('global');
|
|
420
|
+
// Clean up expired waiting responses
|
|
421
|
+
cleanupExpiredWaitingResponses(workflowStaticData, this.logger);
|
|
422
|
+
// Process each notification
|
|
423
|
+
const workflowData = [];
|
|
424
|
+
for (const notification of notifications) {
|
|
425
|
+
// Apply filters
|
|
426
|
+
let passesFilters = true;
|
|
427
|
+
// Check message content filter
|
|
428
|
+
if (filters.messageContains) {
|
|
429
|
+
const resourceData = notification.resourceData;
|
|
430
|
+
if ((_a = resourceData === null || resourceData === void 0 ? void 0 : resourceData.body) === null || _a === void 0 ? void 0 : _a.content) {
|
|
431
|
+
const messageText = resourceData.body.content.toLowerCase();
|
|
432
|
+
const filterText = filters.messageContains.toLowerCase();
|
|
433
|
+
if (!messageText.includes(filterText)) {
|
|
434
|
+
passesFilters = false;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// If no resource data, we can't filter by content, so pass through
|
|
438
|
+
}
|
|
439
|
+
// Check sender email filter
|
|
440
|
+
if (passesFilters && filters.senderEmail) {
|
|
441
|
+
const resourceData = notification.resourceData;
|
|
442
|
+
if ((_c = (_b = resourceData === null || resourceData === void 0 ? void 0 : resourceData.from) === null || _b === void 0 ? void 0 : _b.user) === null || _c === void 0 ? void 0 : _c.userIdentity) {
|
|
443
|
+
const senderEmail = resourceData.from.user.userIdentity;
|
|
444
|
+
const filterEmail = filters.senderEmail.toLowerCase();
|
|
445
|
+
if (senderEmail.toLowerCase() !== filterEmail) {
|
|
446
|
+
passesFilters = false;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (!passesFilters) {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
// Fetch full resource data if not included
|
|
454
|
+
let resourceData = notification.resourceData;
|
|
455
|
+
if (!resourceData && notification.resourceUrl && !includeResourceData) {
|
|
456
|
+
// Only fetch if includeResourceData is false (data not in notification)
|
|
457
|
+
try {
|
|
458
|
+
const graphClient = new index_1.GraphApiClient(this, credentials);
|
|
459
|
+
resourceData = await graphClient.getResource(notification.resourceUrl);
|
|
460
|
+
}
|
|
461
|
+
catch (error) {
|
|
462
|
+
this.logger.warn(`Failed to fetch resource data: ${error}`);
|
|
463
|
+
// Continue without resource data
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
// Normalize to standard event format
|
|
467
|
+
const standardEvent = parser.normalizeEvent(notification, resourceData);
|
|
468
|
+
// Check if this message matches a waiting response
|
|
469
|
+
const matchedWait = checkForWaitingResponse(workflowStaticData, notification, resourceData, standardEvent);
|
|
470
|
+
if (matchedWait) {
|
|
471
|
+
// This message is a response to a "send and wait" operation
|
|
472
|
+
// The execution will be resumed automatically by n8n
|
|
473
|
+
this.logger.info(`Matched response for waiting execution: ${matchedWait.originalMessageId}`);
|
|
474
|
+
// Return accepted immediately (Graph API expects quick response)
|
|
475
|
+
res.status(202).json({ status: 'Accepted' });
|
|
476
|
+
return {
|
|
477
|
+
workflowData: [[{ json: standardEvent }]],
|
|
478
|
+
noWebhookResponse: true,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
// Regular trigger - add to workflow data
|
|
482
|
+
workflowData.push([{ json: standardEvent }]);
|
|
483
|
+
}
|
|
484
|
+
// Return accepted immediately (Graph API expects quick response)
|
|
485
|
+
res.status(202).json({ status: 'Accepted' });
|
|
486
|
+
if (workflowData.length === 0) {
|
|
487
|
+
return { noWebhookResponse: true };
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
workflowData,
|
|
491
|
+
noWebhookResponse: true,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
catch (error) {
|
|
495
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
496
|
+
this.logger.error(`Graph API webhook error: ${errorMessage}`, { error });
|
|
497
|
+
res.status(500).json({
|
|
498
|
+
error: 'Internal server error',
|
|
499
|
+
message: errorMessage,
|
|
500
|
+
});
|
|
501
|
+
return { noWebhookResponse: true };
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
exports.TeamsBotTrigger = TeamsBotTrigger;
|
|
506
|
+
//# sourceMappingURL=TeamsBotTrigger.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TeamsBotTrigger.node.js","sourceRoot":"","sources":["../../../nodes/TeamsBot/TeamsBotTrigger.node.ts"],"names":[],"mappings":";;;AAWA,6CAAsG;AACtG,6EAAmG;AACnG,qEAAkE;AAElE;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC/B,kBAA+B,EAC/B,YAAgC,EAChC,YAAiB,EACjB,aAA0B;IAE1B,2CAA2C;IAC3C,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,IAAI,OAAO,kBAAkB,CAAC,gBAAgB,KAAK,QAAQ,EAAE;QACpG,OAAO,IAAI,CAAC;KACZ;IAED,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,gBAAuC,CAAC;IAEpF,yDAAyD;IACzD,MAAM,cAAc,GAAG,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,SAAS,CAAC;IACrE,MAAM,SAAS,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,SAAS,CAAC;IAE1C,0CAA0C;IAC1C,KAAK,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ACvB,CAAC;iBACF;gBAED,yCAAyC;gBACzC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;aAC7C;YAED,iEAAiE;YACjE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;YAE7C,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC9B,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;aACnC;YAED,OAAO;gBACN,YAAY;gBACZ,iBAAiB,EAAE,IAAI;aACvB,CAAC;SAEF;QAAC,OAAO,KAAK,EAAE;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YAC9E,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAEzE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACpB,KAAK,EAAE,uBAAuB;gBAC9B,OAAO,EAAE,YAAY;aACrB,CAAC,CAAC;YAEH,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC;SACnC;IACF,CAAC;CAqID;AAleD,0CAkeC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-microsoft-teams-bot",
|
|
3
|
+
"nodeVersion": 2,
|
|
4
|
+
"codexVersion": 1,
|
|
5
|
+
"categories": [
|
|
6
|
+
"Communication"
|
|
7
|
+
],
|
|
8
|
+
"resources": {
|
|
9
|
+
"credentialDocumentation": [
|
|
10
|
+
{
|
|
11
|
+
"url": "https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"primaryDocumentation": [
|
|
15
|
+
{
|
|
16
|
+
"url": "https://learn.microsoft.com/en-us/graph/teams-change-notification-in-microsoft-teams-overview"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"subcategories": {
|
|
21
|
+
"Communication": [
|
|
22
|
+
"Trigger"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"alias": [
|
|
26
|
+
"Microsoft",
|
|
27
|
+
"Teams",
|
|
28
|
+
"Bot",
|
|
29
|
+
"Trigger",
|
|
30
|
+
"Webhook",
|
|
31
|
+
"Graph API",
|
|
32
|
+
"Subscriptions",
|
|
33
|
+
"Message",
|
|
34
|
+
"Chat",
|
|
35
|
+
"Channel"
|
|
36
|
+
],
|
|
37
|
+
"operations": {
|
|
38
|
+
"trigger": {
|
|
39
|
+
"specificChannel": {
|
|
40
|
+
"description": "Trigger workflow on messages in a specific Teams channel",
|
|
41
|
+
"documentationUrl": "https://learn.microsoft.com/en-us/graph/teams-changenotifications-chatmessage"
|
|
42
|
+
},
|
|
43
|
+
"specificChat": {
|
|
44
|
+
"description": "Trigger workflow on messages in a specific chat",
|
|
45
|
+
"documentationUrl": "https://learn.microsoft.com/en-us/graph/teams-changenotifications-chatmessage"
|
|
46
|
+
},
|
|
47
|
+
"allChats": {
|
|
48
|
+
"description": "Trigger workflow on all chat messages in tenant (requires licensing)",
|
|
49
|
+
"documentationUrl": "https://learn.microsoft.com/en-us/graph/teams-licenses"
|
|
50
|
+
},
|
|
51
|
+
"allChannels": {
|
|
52
|
+
"description": "Trigger workflow on all channel messages in tenant (requires licensing)",
|
|
53
|
+
"documentationUrl": "https://learn.microsoft.com/en-us/graph/teams-licenses"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Handles the 'Build Adaptive Card' operation in the Teams Bot node.
|
|
4
|
+
* This creates a JSON representation of an adaptive card based on UI inputs.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildCard(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|