diff --git a/components/slack/actions/find-message/find-message.mjs b/components/slack/actions/find-message/find-message.mjs index 2eebe5b19f440..105f993901c8b 100644 --- a/components/slack/actions/find-message/find-message.mjs +++ b/components/slack/actions/find-message/find-message.mjs @@ -4,7 +4,7 @@ export default { key: "slack-find-message", name: "Find Message", description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)", - version: "0.0.23", + version: "0.0.24", type: "action", props: { slack, @@ -21,12 +21,41 @@ export default { ], optional: true, }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of messages to return", + default: 100, + optional: true, + }, + sort: { + type: "string", + label: "Sort", + description: "Return matches sorted by either `score` or `timestamp`", + options: [ + "score", + "timestamp", + ], + optional: true, + }, + sortDirection: { + type: "string", + label: "Sort Direction", + description: "Sort ascending (asc) or descending (desc)`", + options: [ + "desc", + "asc", + ], + optional: true, + }, }, async run({ $ }) { const matches = []; const params = { query: this.query, team_id: this.teamId, + sort: this.sort, + sort_dir: this.sortDirection, page: 1, }; let hasMore; @@ -34,10 +63,17 @@ export default { do { const { messages } = await this.slack.searchMessages(params); matches.push(...messages.matches); + if (matches.length >= this.maxResults) { + break; + } hasMore = messages?.length; params.page++; } while (hasMore); + if (matches.length > this.maxResults) { + matches.length = this.maxResults; + } + $.export("$summary", `Found ${matches.length} matching message${matches.length === 1 ? "" : "s"}`); diff --git a/components/slack/package.json b/components/slack/package.json index ff314623396bd..69615f0b47077 100644 --- a/components/slack/package.json +++ b/components/slack/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/slack", - "version": "0.9.2", + "version": "0.9.3", "description": "Pipedream Slack Components", "main": "slack.app.mjs", "keywords": [