Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { parseObject } from "../../common/utils.mjs";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-create-message-for-thread",
name: "Create Message For Thread",
description: "Create message for a thread. [See the documentation](https://developers.freshdesk.com/api/#create_message_for_thread).",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
label: "Ticket ID",
description: "ID of the ticket to create the message for.",
},
threadId: {
propDefinition: [
freshdesk,
"threadId",
({ ticketId }) => ({
ticketId,
}),
],
label: "Thread ID",
description: "ID of the thread to create the message for.",
},
body: {
type: "string",
label: "Body",
description: "Content of the note in HTML format.",
optional: true,
},
participants: {
type: "string[]",
label: "Participants",
description: "List of the participants to be added to the message.",
optional: true,
},
},
async run({ $ }) {
const response = await this.freshdesk.createMessageForThread({
$,
data: {
body: this.body,
participants: {
email: {
to: parseObject(this.participants),
},
},
thread_id: this.threadId,
},
});

$.export("$summary", `Message created successfully with ID: ${response.id}`);
return response;
},
};
111 changes: 111 additions & 0 deletions components/freshdesk/actions/create-reply/create-reply.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { getFileStreamAndMetadata } from "@pipedream/platform";
import FormData from "form-data";
import { parseObject } from "../../common/utils.mjs";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-create-reply",
name: "Create a Reply",
description: "Create a reply to a ticket. [See the documentation](https://developers.freshdesk.com/api/#reply_ticket).",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
body: {
type: "string",
label: "Body",
description: "Content of the note in HTML format.",
},
attachments: {
type: "string[]",
label: "Attachments",
description: "The total size of all the ticket's attachments (not just this note) cannot exceed 20MB.",
optional: true,
},
fromEmail: {
propDefinition: [
freshdesk,
"fromEmail",
],
optional: true,
},
userId: {
propDefinition: [
freshdesk,
"agentId",
],
label: "User ID",
description: "ID of the agent who is adding the note.",
optional: true,
},
ccEmails: {
type: "string[]",
label: "CC Emails",
description: "Email address added in the 'cc' field of the outgoing ticket email.",
optional: true,
},
bccEmails: {
type: "string[]",
label: "BCC Emails",
description: "Email address added in the 'bcc' field of the outgoing ticket email.",
optional: true,
},
},
async run({ $ }) {
const formData = new FormData();
formData.append("body", this.body);

if (this.fromEmail) {
formData.append("from_email", this.fromEmail.label);
}
if (this.userId) {
formData.append("user_id", this.userId);
}
const parsedCcEmails = parseObject(this.ccEmails);
if (parsedCcEmails) {
parsedCcEmails.forEach((ccEmail) => {
formData.append("cc_emails[]", ccEmail);
});
}
const parsedBccEmails = parseObject(this.bccEmails);
if (parsedBccEmails) {
parsedBccEmails.forEach((bccEmail) => {
formData.append("bcc_emails[]", bccEmail);
});
}

const parsedAttachments = parseObject(this.attachments);
if (parsedAttachments) {
for (const attachment of parsedAttachments) {
const {
stream, metadata,
} = await getFileStreamAndMetadata(attachment);
formData.append("attachments[]", stream, {
contentType: metadata.contentType,
knownLength: metadata.size,
filename: metadata.name,
});
};
}
const response = await this.freshdesk.createReply({
$,
ticketId: this.ticketId,
data: formData,
headers: formData.getHeaders(),
});

$.export("$summary", `Reply created successfully with ID: ${response.id}`);
return response;
},
};
60 changes: 60 additions & 0 deletions components/freshdesk/actions/create-thread/create-thread.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-create-thread",
name: "Create a Thread",
description: "Create a thread to a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_a_thread).",
version: "0.0.1",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
type: "action",
props: {
freshdesk,
type: {
type: "string",
label: "Type",
description: "Type of the thread.",
options: [
"forward",
"discussion",
],
},
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
label: "Parent ID",
description: "The ID of the ticket to create the thread for.",
},
emailConfigId: {
propDefinition: [
freshdesk,
"fromEmail",
],
label: "Email Config ID",
description: "The ID of the email config to use for the thread.",
},
},
async run({ $ }) {
const response = await this.freshdesk.createThread({
$,
data: {
type: this.type,
parent: {
id: this.ticketId,
type: "ticket",
},
additional_info: {
email_config_id: this.emailConfigId.value,
},
},
});

$.export("$summary", `Thread created successfully with ID: ${response.id}`);
return response;
},
};
Loading
Loading