From 61903efaede91e236089539eb983a35a5e34e6af Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Wed, 24 Feb 2021 17:58:35 -0500 Subject: [PATCH] :sparkles: Add field to reply to message - Microsoft Team (#1479) * Add replyTo feature to Microsoft Teams * consolidate create and replyTo channel message in Microsoft Teams Node * :zap: Improvements to #1451 Co-authored-by: Sebastian Vogel --- .../Teams/ChannelMessageDescription.ts | 26 +++++++++++++++++++ .../Microsoft/Teams/MicrosoftTeams.node.ts | 11 +++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts b/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts index 61879542ad..ede9af39d4 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts @@ -129,6 +129,32 @@ export const channelMessageFields = [ default: '', description: 'The content of the item.', }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Field', + default: {}, + displayOptions: { + show: { + resource: [ + 'channelMessage', + ], + operation: [ + 'create', + ], + }, + }, + options: [ + { + displayName: 'Make Reply', + name: 'makeReply', + type: 'string', + default: '', + description: 'An optional ID of the message you want to reply to.', + }, + ], + }, /* -------------------------------------------------------------------------- */ /* channelMessage:getAll */ /* -------------------------------------------------------------------------- */ diff --git a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts index 04d106c750..c6dfb2665a 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts @@ -262,18 +262,27 @@ export class MicrosoftTeams implements INodeType { } if (resource === 'channelMessage') { //https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http + //https://docs.microsoft.com/en-us/graph/api/channel-post-messagereply?view=graph-rest-beta&tabs=http if (operation === 'create') { const teamId = this.getNodeParameter('teamId', i) as string; const channelId = this.getNodeParameter('channelId', i) as string; const messageType = this.getNodeParameter('messageType', i) as string; const message = this.getNodeParameter('message', i) as string; + const options = this.getNodeParameter('options', i) as IDataObject; + const body: IDataObject = { body: { contentType: messageType, content: message, }, }; - responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages`, body); + + if (options.makeReply) { + const replyToId = options.makeReply as string; + responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`, body); + } else { + responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages`, body); + } } //https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http if (operation === 'getAll') {