diff --git a/components/gmail/actions/approve-workflow/approve-workflow.mjs b/components/gmail/actions/approve-workflow/approve-workflow.mjs new file mode 100644 index 0000000000000..e18b9a2227ce3 --- /dev/null +++ b/components/gmail/actions/approve-workflow/approve-workflow.mjs @@ -0,0 +1,36 @@ +import gmail from "../../gmail.app.mjs"; + +export default { + key: "gmail-approve-workflow", + name: "Approve Workflow", + description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)", + version: "0.0.1", + type: "action", + props: { + gmail, + to: { + propDefinition: [ + gmail, + "to", + ], + }, + subject: { + propDefinition: [ + gmail, + "subject", + ], + }, + }, + async run({ $ }) { + const { + resume_url, cancel_url, + } = $.flow.suspend(); + const opts = await this.gmail.getOptionsToSendEmail($, { + body: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`, + ...this, + }); + const response = await this.gmail.sendEmail(opts); + $.export("$summary", `Successfully sent email to ${this.to}`); + return response; + }, +}; diff --git a/components/gmail/package.json b/components/gmail/package.json index e76ef04375074..88d97cadb1de0 100644 --- a/components/gmail/package.json +++ b/components/gmail/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/gmail", - "version": "0.1.14", + "version": "0.2.0", "description": "Pipedream Gmail Components", "main": "gmail.app.mjs", "keywords": [ diff --git a/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs b/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs new file mode 100644 index 0000000000000..61b2771a4d46f --- /dev/null +++ b/components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs @@ -0,0 +1,47 @@ +import microsoftOutlook from "../../microsoft_outlook.app.mjs"; + +export default { + key: "microsoft_outlook-approve-workflow", + name: "Approve Workflow", + description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)", + version: "0.0.1", + type: "action", + props: { + microsoftOutlook, + recipients: { + propDefinition: [ + microsoftOutlook, + "recipients", + ], + optional: false, + }, + subject: { + propDefinition: [ + microsoftOutlook, + "subject", + ], + optional: false, + }, + }, + async run({ $ }) { + const { + resume_url, cancel_url, + } = $.flow.suspend(); + const opts = { + content: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`, + ccRecipients: [], + bccRecipients: [], + ...this, + }; + const response = await this.microsoftOutlook.sendEmail({ + $, + data: { + message: { + ...this.microsoftOutlook.prepareMessageBody(opts), + }, + }, + }); + $.export("$summary", "Email has been sent."); + return response; + }, +}; diff --git a/components/microsoft_outlook/package.json b/components/microsoft_outlook/package.json index 582c9520cea8f..872354b35d81d 100644 --- a/components/microsoft_outlook/package.json +++ b/components/microsoft_outlook/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/microsoft_outlook", - "version": "1.2.0", + "version": "1.3.0", "description": "Pipedream Microsoft Outlook Components", "main": "microsoft_outlook.app.mjs", "keywords": [ diff --git a/components/slack/actions/approve-workflow/approve-workflow.mjs b/components/slack/actions/approve-workflow/approve-workflow.mjs new file mode 100644 index 0000000000000..ce8daab1ecd91 --- /dev/null +++ b/components/slack/actions/approve-workflow/approve-workflow.mjs @@ -0,0 +1,85 @@ +import slack from "../../slack.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + key: "slack-approve-workflow", + name: "Approve Workflow", + description: "Suspend the workflow until approved by a slack message. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)", + version: "0.0.1", + type: "action", + props: { + slack, + channelType: { + type: "string", + label: "Channel Type", + description: "The type of channel to send to. User/Direct Message (im), Group (mpim), Private Channel or Public Channel", + async options() { + return constants.CHANNEL_TYPE_OPTIONS; + }, + }, + conversation: { + propDefinition: [ + slack, + "conversation", + (c) => ({ + types: c.channelType === "Channels" + ? [ + constants.CHANNEL_TYPE.PUBLIC, + constants.CHANNEL_TYPE.PRIVATE, + ] + : [ + c.channelType, + ], + }), + ], + }, + message: { + type: "string", + label: "Message", + description: "A text message to include with the Approve and Cancel Buttons", + }, + }, + async run({ $ }) { + const { + resume_url, cancel_url, + } = $.flow.suspend(); + + const response = await this.slack.sdk().chat.postMessage({ + text: "Click here to approve or cancel workflow", + blocks: [ + { + type: "section", + text: { + type: "mrkdwn", + text: this.message, + }, + }, + { + type: "actions", + elements: [ + { + type: "button", + text: { + type: "plain_text", + text: "Approve", + }, + url: resume_url, + }, + { + type: "button", + text: { + type: "plain_text", + text: "Cancel", + }, + url: cancel_url, + }, + ], + }, + ], + channel: this.conversation, + }); + + $.export("$summary", "Successfully sent message"); + return response; + }, +}; diff --git a/components/slack/package.json b/components/slack/package.json index b7b32ef6d1ee3..49c15480797ad 100644 --- a/components/slack/package.json +++ b/components/slack/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/slack", - "version": "0.8.1", + "version": "0.9.0", "description": "Pipedream Slack Components", "main": "slack.app.mjs", "keywords": [