Skip to content

Commit 70cb6c3

Browse files
committed
[Components] richpanel #15105
Sources - New Ticket - New Message - New Ticket Status Change Actions - Create Ticket - Add Ticket Message - Update Ticket Status
1 parent 197eede commit 70cb6c3

File tree

14 files changed

+515
-491
lines changed

14 files changed

+515
-491
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,46 @@
11
import richpanel from "../../richpanel.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "richpanel-add-ticket-message",
65
name: "Add Ticket Message",
7-
description: "Adds a message to an existing ticket. [See the documentation]()",
6+
description: "Adds a message to an existing ticket. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation)",
87
version: "0.0.{{ts}}",
98
type: "action",
109
props: {
1110
richpanel,
12-
addMessageId: {
11+
conversationId: {
1312
propDefinition: [
1413
richpanel,
15-
"addMessageId",
14+
"conversationId",
1615
],
1716
},
18-
addMessageBody: {
17+
commentBody: {
1918
propDefinition: [
2019
richpanel,
21-
"addMessageBody",
20+
"commentBody",
2221
],
2322
},
24-
addMessageSenderType: {
23+
commentSenderType: {
2524
propDefinition: [
2625
richpanel,
27-
"addMessageSenderType",
26+
"commentSenderType",
2827
],
2928
},
3029
},
3130
async run({ $ }) {
32-
const response = await this.richpanel.addMessageToTicket();
33-
$.export("$summary", `Added message to ticket ${this.addMessageId} successfully`);
31+
const response = await this.richpanel.updateTicket({
32+
$,
33+
conversationId: this.conversationId,
34+
data: {
35+
ticket: {
36+
comment: {
37+
body: this.commentBody,
38+
sender_type: this.commentSenderType,
39+
},
40+
},
41+
},
42+
});
43+
$.export("$summary", `Added message to ticket ${this.messageId} successfully`);
3444
return response;
3545
},
3646
};
Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
13
import richpanel from "../../richpanel.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "richpanel-create-ticket",
67
name: "Create Ticket",
7-
description: "Creates a new support ticket in Richpanel. [See the documentation]().",
8-
version: "0.0.{{ts}}",
8+
description: "Creates a new support ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/create-conversation).",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
richpanel,
@@ -14,54 +15,81 @@ export default {
1415
richpanel,
1516
"createId",
1617
],
18+
optional: true,
1719
},
1820
status: {
1921
propDefinition: [
2022
richpanel,
21-
"createStatus",
23+
"status",
2224
],
2325
},
2426
commentBody: {
2527
propDefinition: [
2628
richpanel,
27-
"createCommentBody",
29+
"commentBody",
2830
],
2931
},
3032
commentSenderType: {
3133
propDefinition: [
3234
richpanel,
33-
"createCommentSenderType",
35+
"commentSenderType",
3436
],
3537
},
3638
viaChannel: {
3739
propDefinition: [
3840
richpanel,
39-
"createViaChannel",
41+
"viaChannel",
4042
],
4143
},
4244
viaSourceFrom: {
4345
propDefinition: [
4446
richpanel,
45-
"createViaSourceFrom",
47+
"viaSourceFrom",
4648
],
4749
},
4850
viaSourceTo: {
4951
propDefinition: [
5052
richpanel,
51-
"createViaSourceTo",
53+
"viaSourceTo",
5254
],
55+
optional: true,
5356
},
5457
tags: {
5558
propDefinition: [
5659
richpanel,
57-
"createTags",
60+
"tags",
5861
],
62+
optional: true,
5963
},
6064
},
6165
async run({ $ }) {
62-
const response = await this.richpanel.createTicket();
66+
try {
67+
const response = await this.richpanel.createTicket({
68+
$,
69+
data: {
70+
ticket: {
71+
id: this.id,
72+
status: this.status,
73+
comment: {
74+
body: this.commentBody,
75+
sender_type: this.commentSenderType,
76+
},
77+
via: {
78+
channel: this.viaChannel,
79+
source: {
80+
from: parseObject(this.viaSourceFrom),
81+
to: parseObject(this.viaSourceTo),
82+
},
83+
},
84+
tags: parseObject(this.tags),
85+
},
86+
},
87+
});
6388

64-
$.export("$summary", `Created ticket ${response.id}`);
65-
return response;
89+
$.export("$summary", `Created ticket ${response.ticket.id}`);
90+
return response;
91+
} catch ({ response }) {
92+
throw new ConfigurationError(response?.data?.error?.message);
93+
}
6694
},
6795
};
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
import richpanel from "../../richpanel.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "richpanel-update-ticket-status",
65
name: "Update Ticket Status",
7-
description: "Updates the status of an existing ticket in Richpanel. [See the documentation]().",
6+
description: "Updates the status of an existing ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation).",
87
version: "0.0.{{ts}}",
98
type: "action",
109
props: {
1110
richpanel,
12-
updateTicketId: {
11+
conversationId: {
1312
propDefinition: [
1413
richpanel,
15-
"updateTicketId",
14+
"conversationId",
1615
],
1716
},
18-
updateStatus: {
17+
status: {
1918
propDefinition: [
2019
richpanel,
21-
"updateStatus",
20+
"status",
2221
],
2322
},
2423
},
2524
async run({ $ }) {
26-
const response = await this.richpanel.updateTicketStatus();
27-
$.export("$summary", `Updated ticket ${this.updateTicketId} to status ${this.updateStatus}`);
25+
const response = await this.richpanel.updateTicket({
26+
$,
27+
data: {
28+
ticket: {
29+
status: this.status,
30+
},
31+
},
32+
});
33+
$.export("$summary", `Updated ticket ${this.conversationId} to status ${this.status}`);
2834
return response;
2935
},
3036
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export const STATUS_OPTIONS = [
2+
{
3+
label: "Open",
4+
value: "OPEN",
5+
},
6+
{
7+
label: "Closed",
8+
value: "CLOSED",
9+
},
10+
{
11+
label: "Snoozed",
12+
value: "SNOOZED",
13+
},
14+
];
15+
16+
export const COMMENT_SENDER_TYPE_OPTIONS = [
17+
{
18+
label: "Customer",
19+
value: "customer",
20+
},
21+
{
22+
label: "Operator",
23+
value: "operator",
24+
},
25+
];
26+
27+
export const VIA_CHANNEL_OPTIONS = [
28+
{
29+
label: "Email",
30+
value: "email",
31+
},
32+
{
33+
label: "Messenger",
34+
value: "messenger",
35+
},
36+
{
37+
label: "Facebook Message",
38+
value: "facebook_message",
39+
},
40+
{
41+
label: "Instagram",
42+
value: "instagram",
43+
},
44+
{
45+
label: "Aircall",
46+
value: "aircall",
47+
},
48+
{
49+
label: "Phone",
50+
value: "phone",
51+
},
52+
{
53+
label: "WhatsApp",
54+
value: "whatsapp",
55+
},
56+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

components/richpanel/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/richpanel",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Richpanel Components",
55
"main": "richpanel.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

0 commit comments

Comments
 (0)