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

*  Improvements to #1451

Co-authored-by: Sebastian Vogel <s.vogel@sachsenkabel.de>
This commit is contained in:
Ricardo Espinoza 2021-02-24 17:58:35 -05:00 committed by GitHub
parent 66f6b7dfeb
commit 61903efaed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View file

@ -129,6 +129,32 @@ export const channelMessageFields = [
default: '', default: '',
description: 'The content of the item.', 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 */ /* channelMessage:getAll */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */

View file

@ -262,19 +262,28 @@ export class MicrosoftTeams implements INodeType {
} }
if (resource === 'channelMessage') { 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-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') { if (operation === 'create') {
const teamId = this.getNodeParameter('teamId', i) as string; const teamId = this.getNodeParameter('teamId', i) as string;
const channelId = this.getNodeParameter('channelId', i) as string; const channelId = this.getNodeParameter('channelId', i) as string;
const messageType = this.getNodeParameter('messageType', i) as string; const messageType = this.getNodeParameter('messageType', i) as string;
const message = this.getNodeParameter('message', i) as string; const message = this.getNodeParameter('message', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
const body: IDataObject = { const body: IDataObject = {
body: { body: {
contentType: messageType, contentType: messageType,
content: message, content: message,
}, },
}; };
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); 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 //https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http
if (operation === 'getAll') { if (operation === 'getAll') {
const teamId = this.getNodeParameter('teamId', i) as string; const teamId = this.getNodeParameter('teamId', i) as string;