diff --git a/packages/nodes-base/nodes/Slack/MessageDescription.ts b/packages/nodes-base/nodes/Slack/MessageDescription.ts index 16977b6e28..f4a6f5fb0d 100644 --- a/packages/nodes-base/nodes/Slack/MessageDescription.ts +++ b/packages/nodes-base/nodes/Slack/MessageDescription.ts @@ -35,6 +35,11 @@ export const messageOperations = [ value: 'update', description: 'Updates a message.', }, + { + name: 'Delete', + value: 'delete', + description: 'Deletes a message.', + }, ], default: 'post', description: 'The operation to perform.', @@ -1680,4 +1685,46 @@ export const messageFields = [ ], }, + /* ----------------------------------------------------------------------- */ + /* message:delete + /* ----------------------------------------------------------------------- */ + { + displayName: 'Channel', + name: 'channelId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getChannels', + }, + required: true, + default: '', + displayOptions: { + show: { + resource: [ + 'message', + ], + operation: [ + 'delete', + ], + }, + }, + description: 'Channel containing the message to be deleted.', + }, + { + displayName: 'Timestamp', + name: 'ts', + type: 'string', + required: true, + default: '', + displayOptions: { + show: { + resource: [ + 'message', + ], + operation: [ + 'delete', + ], + }, + }, + description: `Timestamp of the message to be deleted.`, + }, ] as INodeProperties[]; diff --git a/packages/nodes-base/nodes/Slack/Slack.node.ts b/packages/nodes-base/nodes/Slack/Slack.node.ts index 75d597b3fe..96df14e2c9 100644 --- a/packages/nodes-base/nodes/Slack/Slack.node.ts +++ b/packages/nodes-base/nodes/Slack/Slack.node.ts @@ -795,6 +795,17 @@ export class Slack implements INodeType { Object.assign(body, updateFields); responseData = await slackApiRequest.call(this, 'POST', '/chat.update', body, qs); } + //https://api.slack.com/methods/chat.delete + if (operation === 'delete') { + const channel = this.getNodeParameter('channelId', i) as string; + const ts = this.getNodeParameter('ts', i) as string; + const body: IDataObject = { + channel, + ts, + }; + // Add all the other options to the request + responseData = await slackApiRequest.call(this, 'POST', '/chat.delete', body, qs); + } //https://api.slack.com/methods/chat.getPermalink if (operation === 'getPermalink') { const channel = this.getNodeParameter('channelId', i) as string;