Skip to content

Commit e62b984

Browse files
authored
New Components - richpanel (#15108)
* richpanel init * [Components] richpanel #15105 Sources - New Ticket - New Message - New Ticket Status Change Actions - Create Ticket - Add Ticket Message - Update Ticket Status * pnpm update * [Components] richpanel #15105 Sources - New Ticket - New Message Actions - Create Ticket - Add Ticket Message - Update Ticket Status * pnpm update * fix import * Add some props
1 parent ef15a0d commit e62b984

File tree

20 files changed

+702
-14
lines changed

20 files changed

+702
-14
lines changed

components/azure_storage/azure_storage.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/elevio/elevio.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/homerun/homerun.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/ragie/ragie.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/refiner/refiner.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import richpanel from "../../richpanel.app.mjs";
2+
3+
export default {
4+
key: "richpanel-add-ticket-message",
5+
name: "Add Ticket Message",
6+
description: "Adds a message to an existing ticket. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
richpanel,
11+
conversationId: {
12+
propDefinition: [
13+
richpanel,
14+
"conversationId",
15+
],
16+
},
17+
commentBody: {
18+
propDefinition: [
19+
richpanel,
20+
"commentBody",
21+
],
22+
},
23+
commentSenderType: {
24+
propDefinition: [
25+
richpanel,
26+
"commentSenderType",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
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.conversationId} successfully`);
44+
return response;
45+
},
46+
};
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { VIA_CHANNEL_OPTIONS } from "../../common/constants.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
4+
import richpanel from "../../richpanel.app.mjs";
5+
6+
export default {
7+
key: "richpanel-create-ticket",
8+
name: "Create Ticket",
9+
description: "Creates a new support ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/create-conversation).",
10+
version: "0.0.1",
11+
type: "action",
12+
props: {
13+
richpanel,
14+
id: {
15+
propDefinition: [
16+
richpanel,
17+
"createId",
18+
],
19+
optional: true,
20+
},
21+
status: {
22+
propDefinition: [
23+
richpanel,
24+
"status",
25+
],
26+
},
27+
subject: {
28+
type: "string",
29+
label: "Subject",
30+
description: "The subject of the ticket.",
31+
optional: true,
32+
},
33+
commentBody: {
34+
propDefinition: [
35+
richpanel,
36+
"commentBody",
37+
],
38+
},
39+
priority: {
40+
type: "string",
41+
label: "Priority",
42+
description: "The priority of the ticket.",
43+
options: [
44+
"HIGH",
45+
"LOW",
46+
],
47+
optional: true,
48+
},
49+
commentSenderType: {
50+
propDefinition: [
51+
richpanel,
52+
"commentSenderType",
53+
],
54+
},
55+
viaChannel: {
56+
type: "string",
57+
label: "Via Channel",
58+
description: "The channel via which the ticket is created.",
59+
reloadProps: true,
60+
options: VIA_CHANNEL_OPTIONS,
61+
},
62+
viaSourceFromAddress: {
63+
type: "string",
64+
label: "Via Source From Address",
65+
description: "The email address of the source from.",
66+
hidden: true,
67+
},
68+
viaSourceFromName: {
69+
type: "string",
70+
label: "Via Source From Name",
71+
description: "The name of the source from.",
72+
hidden: true,
73+
},
74+
viaSourceToAddress: {
75+
type: "string",
76+
label: "Via Source To Address",
77+
description: "The email address of the source to.",
78+
hidden: true,
79+
},
80+
viaSourceToName: {
81+
type: "string",
82+
label: "Via Source To Name",
83+
description: "The name of the source to.",
84+
hidden: true,
85+
},
86+
viaSourceFromNumber: {
87+
type: "string",
88+
label: "Via Source From Number",
89+
description: "The phone number of the source from.",
90+
hidden: true,
91+
},
92+
viaSourceToNumber: {
93+
type: "string",
94+
label: "Via Source To Number",
95+
description: "The phone number of the source to.",
96+
hidden: true,
97+
},
98+
viaSourceFrom: {
99+
type: "object",
100+
label: "Via Source From",
101+
description: "The object source from which the ticket was created. **Examples: {\"address\": \"abc@email.com\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
102+
hidden: true,
103+
},
104+
viaSourceTo: {
105+
type: "object",
106+
label: "Via Source To",
107+
description: "The object source to which the ticket was created. **Examples: {\"address\": \"abc@email.com\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
108+
hidden: true,
109+
},
110+
tags: {
111+
propDefinition: [
112+
richpanel,
113+
"tags",
114+
],
115+
optional: true,
116+
},
117+
},
118+
async additionalProps(props) {
119+
switch (this.viaChannel) {
120+
case "email" :
121+
props.viaSourceFromAddress.hidden = false;
122+
props.viaSourceFromName.hidden = false;
123+
props.viaSourceToAddress.hidden = false;
124+
props.viaSourceToName.hidden = false;
125+
props.viaSourceFrom.hidden = true;
126+
props.viaSourceTo.hidden = true;
127+
props.viaSourceFromNumber.hidden = true;
128+
props.viaSourceToNumber.hidden = true;
129+
break;
130+
case "aircall" :
131+
props.viaSourceFromNumber.hidden = false;
132+
props.viaSourceToNumber.hidden = false;
133+
props.viaSourceFrom.hidden = true;
134+
props.viaSourceTo.hidden = true;
135+
props.viaSourceFromAddress.hidden = true;
136+
props.viaSourceFromName.hidden = true;
137+
props.viaSourceToAddress.hidden = true;
138+
props.viaSourceToName.hidden = true;
139+
break;
140+
default:
141+
props.viaSourceFrom.hidden = false;
142+
props.viaSourceTo.hidden = false;
143+
props.viaSourceFromAddress.hidden = true;
144+
props.viaSourceFromName.hidden = true;
145+
props.viaSourceToAddress.hidden = true;
146+
props.viaSourceToName.hidden = true;
147+
props.viaSourceFromNumber.hidden = true;
148+
props.viaSourceToNumber.hidden = true;
149+
}
150+
return {};
151+
},
152+
async run({ $ }) {
153+
try {
154+
const source = {};
155+
switch (this.viaChannel) {
156+
case "email" :
157+
source.from = {
158+
address: this.viaSourceFromAddress,
159+
name: this.viaSourceFromName,
160+
};
161+
source.to = {
162+
address: this.viaSourceToAddress,
163+
name: this.viaSourceToName,
164+
};
165+
break;
166+
case "aircall" :
167+
source.from = {
168+
id: this.viaSourceFromNumber,
169+
};
170+
source.to = {
171+
id: this.viaSourceToNumber,
172+
};
173+
break;
174+
default:
175+
source.from = parseObject(this.viaSourceFrom);
176+
source.to = parseObject(this.viaSourceTo);
177+
}
178+
179+
const response = await this.richpanel.createTicket({
180+
$,
181+
data: {
182+
ticket: {
183+
id: this.id,
184+
status: this.status,
185+
subject: this.subject,
186+
comment: {
187+
body: this.commentBody,
188+
sender_type: this.commentSenderType,
189+
},
190+
priority: this.priority,
191+
via: {
192+
channel: this.viaChannel,
193+
source,
194+
},
195+
tags: parseObject(this.tags),
196+
},
197+
},
198+
});
199+
200+
$.export("$summary", `Created ticket ${response.ticket.id}`);
201+
return response;
202+
} catch ({ response }) {
203+
throw new ConfigurationError(response?.data?.error?.message);
204+
}
205+
},
206+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import richpanel from "../../richpanel.app.mjs";
2+
3+
export default {
4+
key: "richpanel-update-ticket-status",
5+
name: "Update Ticket Status",
6+
description: "Updates the status of an existing ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
richpanel,
11+
conversationId: {
12+
propDefinition: [
13+
richpanel,
14+
"conversationId",
15+
],
16+
},
17+
status: {
18+
propDefinition: [
19+
richpanel,
20+
"status",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.richpanel.updateTicket({
26+
$,
27+
conversationId: this.conversationId,
28+
data: {
29+
ticket: {
30+
status: this.status,
31+
},
32+
},
33+
});
34+
$.export("$summary", `Updated ticket ${this.conversationId} to status ${this.status}`);
35+
return response;
36+
},
37+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
export const STATUS_OPTIONS = [
2+
{
3+
label: "Open",
4+
value: "OPEN",
5+
},
6+
{
7+
label: "Closed",
8+
value: "CLOSED",
9+
},
10+
];
11+
12+
export const COMMENT_SENDER_TYPE_OPTIONS = [
13+
{
14+
label: "Customer",
15+
value: "customer",
16+
},
17+
{
18+
label: "Operator",
19+
value: "operator",
20+
},
21+
];
22+
23+
export const VIA_CHANNEL_OPTIONS = [
24+
{
25+
label: "Email",
26+
value: "email",
27+
},
28+
{
29+
label: "Messenger",
30+
value: "messenger",
31+
},
32+
{
33+
label: "Facebook Message",
34+
value: "facebook_message",
35+
},
36+
{
37+
label: "Instagram",
38+
value: "instagram",
39+
},
40+
{
41+
label: "Aircall",
42+
value: "aircall",
43+
},
44+
{
45+
label: "Phone",
46+
value: "phone",
47+
},
48+
{
49+
label: "WhatsApp",
50+
value: "whatsapp",
51+
},
52+
];

0 commit comments

Comments
 (0)