Skip to content

Commit a3b4c4d

Browse files
authored
Human in the loop for apps (#15628)
* new components * fix key
1 parent 3fecef2 commit a3b4c4d

File tree

6 files changed

+171
-3
lines changed

6 files changed

+171
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import gmail from "../../gmail.app.mjs";
2+
3+
export default {
4+
key: "gmail-approve-workflow",
5+
name: "Approve Workflow",
6+
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
gmail,
11+
to: {
12+
propDefinition: [
13+
gmail,
14+
"to",
15+
],
16+
},
17+
subject: {
18+
propDefinition: [
19+
gmail,
20+
"subject",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
resume_url, cancel_url,
27+
} = $.flow.suspend();
28+
const opts = await this.gmail.getOptionsToSendEmail($, {
29+
body: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`,
30+
...this,
31+
});
32+
const response = await this.gmail.sendEmail(opts);
33+
$.export("$summary", `Successfully sent email to ${this.to}`);
34+
return response;
35+
},
36+
};

components/gmail/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gmail",
3-
"version": "0.1.14",
3+
"version": "0.2.0",
44
"description": "Pipedream Gmail Components",
55
"main": "gmail.app.mjs",
66
"keywords": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import microsoftOutlook from "../../microsoft_outlook.app.mjs";
2+
3+
export default {
4+
key: "microsoft_outlook-approve-workflow",
5+
name: "Approve Workflow",
6+
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
microsoftOutlook,
11+
recipients: {
12+
propDefinition: [
13+
microsoftOutlook,
14+
"recipients",
15+
],
16+
optional: false,
17+
},
18+
subject: {
19+
propDefinition: [
20+
microsoftOutlook,
21+
"subject",
22+
],
23+
optional: false,
24+
},
25+
},
26+
async run({ $ }) {
27+
const {
28+
resume_url, cancel_url,
29+
} = $.flow.suspend();
30+
const opts = {
31+
content: `Click here to approve the workflow: ${resume_url}, \nand cancel here: ${cancel_url}`,
32+
ccRecipients: [],
33+
bccRecipients: [],
34+
...this,
35+
};
36+
const response = await this.microsoftOutlook.sendEmail({
37+
$,
38+
data: {
39+
message: {
40+
...this.microsoftOutlook.prepareMessageBody(opts),
41+
},
42+
},
43+
});
44+
$.export("$summary", "Email has been sent.");
45+
return response;
46+
},
47+
};

components/microsoft_outlook/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/microsoft_outlook",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Pipedream Microsoft Outlook Components",
55
"main": "microsoft_outlook.app.mjs",
66
"keywords": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import slack from "../../slack.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "slack-approve-workflow",
6+
name: "Approve Workflow",
7+
description: "Suspend the workflow until approved by a slack message. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
slack,
12+
channelType: {
13+
type: "string",
14+
label: "Channel Type",
15+
description: "The type of channel to send to. User/Direct Message (im), Group (mpim), Private Channel or Public Channel",
16+
async options() {
17+
return constants.CHANNEL_TYPE_OPTIONS;
18+
},
19+
},
20+
conversation: {
21+
propDefinition: [
22+
slack,
23+
"conversation",
24+
(c) => ({
25+
types: c.channelType === "Channels"
26+
? [
27+
constants.CHANNEL_TYPE.PUBLIC,
28+
constants.CHANNEL_TYPE.PRIVATE,
29+
]
30+
: [
31+
c.channelType,
32+
],
33+
}),
34+
],
35+
},
36+
message: {
37+
type: "string",
38+
label: "Message",
39+
description: "A text message to include with the Approve and Cancel Buttons",
40+
},
41+
},
42+
async run({ $ }) {
43+
const {
44+
resume_url, cancel_url,
45+
} = $.flow.suspend();
46+
47+
const response = await this.slack.sdk().chat.postMessage({
48+
text: "Click here to approve or cancel workflow",
49+
blocks: [
50+
{
51+
type: "section",
52+
text: {
53+
type: "mrkdwn",
54+
text: this.message,
55+
},
56+
},
57+
{
58+
type: "actions",
59+
elements: [
60+
{
61+
type: "button",
62+
text: {
63+
type: "plain_text",
64+
text: "Approve",
65+
},
66+
url: resume_url,
67+
},
68+
{
69+
type: "button",
70+
text: {
71+
type: "plain_text",
72+
text: "Cancel",
73+
},
74+
url: cancel_url,
75+
},
76+
],
77+
},
78+
],
79+
channel: this.conversation,
80+
});
81+
82+
$.export("$summary", "Successfully sent message");
83+
return response;
84+
},
85+
};

components/slack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/slack",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "Pipedream Slack Components",
55
"main": "slack.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)