-
Couldn't load subscription status.
- Fork 5.5k
Human in the loop for apps #15628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Human in the loop for apps #15628
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
components/gmail/actions/approve-workflow/approve-workflow.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
components/microsoft_outlook/actions/approve-workflow/approve-workflow.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
| }, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
components/slack/actions/approve-workflow/approve-workflow.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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, | ||
| }); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| $.export("$summary", "Successfully sent message"); | ||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.