Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/azure_storage/azure_storage.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/elevio/elevio.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/homerun/homerun.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/ragie/ragie.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/refiner/refiner.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import richpanel from "../../richpanel.app.mjs";

export default {
key: "richpanel-add-ticket-message",
name: "Add Ticket Message",
description: "Adds a message to an existing ticket. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation)",
version: "0.0.1",
type: "action",
props: {
richpanel,
conversationId: {
propDefinition: [
richpanel,
"conversationId",
],
},
commentBody: {
propDefinition: [
richpanel,
"commentBody",
],
},
commentSenderType: {
propDefinition: [
richpanel,
"commentSenderType",
],
},
},
async run({ $ }) {
const response = await this.richpanel.updateTicket({
$,
conversationId: this.conversationId,
data: {
ticket: {
comment: {
body: this.commentBody,
sender_type: this.commentSenderType,
},
},
},
});
$.export("$summary", `Added message to ticket ${this.conversationId} successfully`);
return response;
},
};
93 changes: 93 additions & 0 deletions components/richpanel/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { ConfigurationError } from "@pipedream/platform";
import { VIA_CHANNEL_OPTIONS } from "../../common/constants.mjs";
import { parseObject } from "../../common/utils.mjs";
import richpanel from "../../richpanel.app.mjs";

export default {
key: "richpanel-create-ticket",
name: "Create Ticket",
description: "Creates a new support ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/create-conversation).",
version: "0.0.1",
type: "action",
props: {
richpanel,
id: {
propDefinition: [
richpanel,
"createId",
],
optional: true,
},
status: {
propDefinition: [
richpanel,
"status",
],
},
commentBody: {
propDefinition: [
richpanel,
"commentBody",
],
},
commentSenderType: {
propDefinition: [
richpanel,
"commentSenderType",
],
},
viaChannel: {
type: "string",
label: "Via Channel",
description: "The channel via which the ticket is created",
options: VIA_CHANNEL_OPTIONS,
},
viaSourceFrom: {
type: "object",
label: "Via Source From",
description: "The object source from which the ticket was created. **Examples: {\"address\": \"[email protected]\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
},
viaSourceTo: {
type: "object",
label: "Via Source To",
description: "The object source to which the ticket was created. **Examples: {\"address\": \"[email protected]\"} or {\"id\": \"+16692668044\"}. It depends on the selected channel**.",
},
tags: {
propDefinition: [
richpanel,
"tags",
],
optional: true,
},
},
async run({ $ }) {
try {
const response = await this.richpanel.createTicket({
$,
data: {
ticket: {
id: this.id,
status: this.status,
comment: {
body: this.commentBody,
sender_type: this.commentSenderType,
},
via: {
channel: this.viaChannel,
source: {
from: parseObject(this.viaSourceFrom),
to: parseObject(this.viaSourceTo),
},
},
tags: parseObject(this.tags),
},
},
});

$.export("$summary", `Created ticket ${response.ticket.id}`);
return response;
} catch ({ response }) {
throw new ConfigurationError(response?.data?.error?.message);
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import richpanel from "../../richpanel.app.mjs";

export default {
key: "richpanel-update-ticket-status",
name: "Update Ticket Status",
description: "Updates the status of an existing ticket in Richpanel. [See the documentation](https://developer.richpanel.com/reference/update-a-conversation).",
version: "0.0.1",
type: "action",
props: {
richpanel,
conversationId: {
propDefinition: [
richpanel,
"conversationId",
],
},
status: {
propDefinition: [
richpanel,
"status",
],
},
},
async run({ $ }) {
const response = await this.richpanel.updateTicket({
$,
conversationId: this.conversationId,
data: {
ticket: {
status: this.status,
},
},
});
$.export("$summary", `Updated ticket ${this.conversationId} to status ${this.status}`);
return response;
},
};
52 changes: 52 additions & 0 deletions components/richpanel/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export const STATUS_OPTIONS = [
{
label: "Open",
value: "OPEN",
},
{
label: "Closed",
value: "CLOSED",
},
];

export const COMMENT_SENDER_TYPE_OPTIONS = [
{
label: "Customer",
value: "customer",
},
{
label: "Operator",
value: "operator",
},
];

export const VIA_CHANNEL_OPTIONS = [
{
label: "Email",
value: "email",
},
{
label: "Messenger",
value: "messenger",
},
{
label: "Facebook Message",
value: "facebook_message",
},
{
label: "Instagram",
value: "instagram",
},
{
label: "Aircall",
value: "aircall",
},
{
label: "Phone",
value: "phone",
},
{
label: "WhatsApp",
value: "whatsapp",
},
];
26 changes: 26 additions & 0 deletions components/richpanel/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const parseObject = (obj) => {
if (!obj) return undefined;

if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};

export const camelToSnakeCase = (str) => str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
7 changes: 5 additions & 2 deletions components/richpanel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/richpanel",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Richpanel Components",
"main": "richpanel.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
Loading
Loading