Skip to content

Commit 5db4929

Browse files
authored
Enhance Freshdesk component with new actions and properties (#19127)
* Enhance Freshdesk component with new actions and properties - Added new actions: `createMessageForThread`, `createReply`, and `createThread` to facilitate message handling in threads and replies. - Introduced new properties for `fromEmail` and `threadId` in the Freshdesk app. - Updated existing methods for improved functionality and consistency. - Incremented package version to 0.7.0 in package.json. * Update Freshdesk action versions for consistency and improvements - Incremented version numbers for multiple Freshdesk actions and sources to reflect recent updates. - Updated versions include: - `add-note-to-ticket` to 0.0.4 - `add-ticket-tags` to 0.0.5 - `assign-ticket-to-agent`, `assign-ticket-to-group`, `close-ticket`, `set-ticket-priority`, `set-ticket-status` to 0.0.6 - `create-agent`, `create-solution-article`, `create-company`, `create-contact`, `create-ticket-field`, `download-attachment`, `get-contact`, `get-solution-article`, `list-agents`, `list-category-folders`, `list-folder-articles`, `list-solution-categories`, `list-ticket-conversations`, `list-ticket-fields`, `remove-ticket-tags`, `update-agent`, `update-contact`, `update-solution-article`, `update-ticket-field` to 0.0.3 - `create-ticket` to 0.0.10 - `list-all-tickets` to 0.2.7 - `list-ticket-fields` to 0.0.3 - `new-contact` and `new-ticket` to 0.0.9 - `contact-updated`, `ticket-updated` to 0.0.2 - Ensured all updates align with the latest API documentation for improved functionality.
1 parent 4827f85 commit 5db4929

File tree

41 files changed

+371
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+371
-72
lines changed

components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "freshdesk-add-note-to-ticket",
66
name: "Add Note to Ticket",
77
description: "Add a note or conversation to an existing ticket. [See the documentation](https://developers.freshdesk.com/api/#add_note_to_a_ticket).",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/freshdesk/actions/add-ticket-tags/add-ticket-tags.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "Add Ticket Tags",
77
description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
88
type: "action",
9-
version: "0.0.4",
9+
version: "0.0.5",
1010
annotations: {
1111
destructiveHint: true,
1212
openWorldHint: true,

components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "freshdesk-assign-ticket-to-agent",
55
name: "Assign Ticket to Agent",
66
description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "freshdesk-assign-ticket-to-group",
55
name: "Assign Ticket to Group",
66
description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/freshdesk/actions/close-ticket/close-ticket.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "freshdesk-close-ticket",
55
name: "Close Ticket",
66
description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
7-
version: "0.0.5",
7+
version: "0.0.6",
88
annotations: {
99
destructiveHint: true,
1010
openWorldHint: true,

components/freshdesk/actions/create-agent/create-agent.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "freshdesk-create-agent",
66
name: "Create Agent",
77
description: "Create an agent in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#create_agent)",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,

components/freshdesk/actions/create-company/create-company.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "freshdesk-create-company",
55
name: "Create a Company",
66
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
7-
version: "0.0.8",
7+
version: "0.0.9",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/freshdesk/actions/create-contact/create-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "freshdesk-create-contact",
66
name: "Create a Contact",
77
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
8-
version: "0.0.8",
8+
version: "0.0.9",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import freshdesk from "../../freshdesk.app.mjs";
3+
4+
export default {
5+
key: "freshdesk-create-message-for-thread",
6+
name: "Create Message For Thread",
7+
description: "Create message for a thread. [See the documentation](https://developers.freshdesk.com/api/#create_message_for_thread).",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
type: "action",
15+
props: {
16+
freshdesk,
17+
ticketId: {
18+
propDefinition: [
19+
freshdesk,
20+
"ticketId",
21+
],
22+
label: "Ticket ID",
23+
description: "ID of the ticket to create the message for.",
24+
},
25+
threadId: {
26+
propDefinition: [
27+
freshdesk,
28+
"threadId",
29+
({ ticketId }) => ({
30+
ticketId,
31+
}),
32+
],
33+
label: "Thread ID",
34+
description: "ID of the thread to create the message for.",
35+
},
36+
body: {
37+
type: "string",
38+
label: "Body",
39+
description: "Content of the note in HTML format.",
40+
optional: true,
41+
},
42+
participants: {
43+
type: "string[]",
44+
label: "Participants",
45+
description: "List of the participants to be added to the message.",
46+
optional: true,
47+
},
48+
},
49+
async run({ $ }) {
50+
const response = await this.freshdesk.createMessageForThread({
51+
$,
52+
data: {
53+
body: this.body,
54+
participants: {
55+
email: {
56+
to: parseObject(this.participants),
57+
},
58+
},
59+
thread_id: this.threadId,
60+
},
61+
});
62+
63+
$.export("$summary", `Message created successfully with ID: ${response.id}`);
64+
return response;
65+
},
66+
};
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { getFileStreamAndMetadata } from "@pipedream/platform";
2+
import FormData from "form-data";
3+
import { parseObject } from "../../common/utils.mjs";
4+
import freshdesk from "../../freshdesk.app.mjs";
5+
6+
export default {
7+
key: "freshdesk-create-reply",
8+
name: "Create a Reply",
9+
description: "Create a reply to a ticket. [See the documentation](https://developers.freshdesk.com/api/#reply_ticket).",
10+
version: "0.0.1",
11+
annotations: {
12+
destructiveHint: false,
13+
openWorldHint: true,
14+
readOnlyHint: false,
15+
},
16+
type: "action",
17+
props: {
18+
freshdesk,
19+
ticketId: {
20+
propDefinition: [
21+
freshdesk,
22+
"ticketId",
23+
],
24+
},
25+
body: {
26+
type: "string",
27+
label: "Body",
28+
description: "Content of the note in HTML format.",
29+
},
30+
attachments: {
31+
type: "string[]",
32+
label: "Attachments",
33+
description: "The total size of all the ticket's attachments (not just this note) cannot exceed 20MB.",
34+
optional: true,
35+
},
36+
fromEmail: {
37+
propDefinition: [
38+
freshdesk,
39+
"fromEmail",
40+
],
41+
optional: true,
42+
},
43+
userId: {
44+
propDefinition: [
45+
freshdesk,
46+
"agentId",
47+
],
48+
label: "User ID",
49+
description: "ID of the agent who is adding the note.",
50+
optional: true,
51+
},
52+
ccEmails: {
53+
type: "string[]",
54+
label: "CC Emails",
55+
description: "Email address added in the 'cc' field of the outgoing ticket email.",
56+
optional: true,
57+
},
58+
bccEmails: {
59+
type: "string[]",
60+
label: "BCC Emails",
61+
description: "Email address added in the 'bcc' field of the outgoing ticket email.",
62+
optional: true,
63+
},
64+
},
65+
async run({ $ }) {
66+
const formData = new FormData();
67+
formData.append("body", this.body);
68+
69+
if (this.fromEmail) {
70+
formData.append("from_email", this.fromEmail.label);
71+
}
72+
if (this.userId) {
73+
formData.append("user_id", this.userId);
74+
}
75+
const parsedCcEmails = parseObject(this.ccEmails);
76+
if (parsedCcEmails) {
77+
parsedCcEmails.forEach((ccEmail) => {
78+
formData.append("cc_emails[]", ccEmail);
79+
});
80+
}
81+
const parsedBccEmails = parseObject(this.bccEmails);
82+
if (parsedBccEmails) {
83+
parsedBccEmails.forEach((bccEmail) => {
84+
formData.append("bcc_emails[]", bccEmail);
85+
});
86+
}
87+
88+
const parsedAttachments = parseObject(this.attachments);
89+
if (parsedAttachments) {
90+
for (const attachment of parsedAttachments) {
91+
const {
92+
stream, metadata,
93+
} = await getFileStreamAndMetadata(attachment);
94+
formData.append("attachments[]", stream, {
95+
contentType: metadata.contentType,
96+
knownLength: metadata.size,
97+
filename: metadata.name,
98+
});
99+
};
100+
}
101+
const response = await this.freshdesk.createReply({
102+
$,
103+
ticketId: this.ticketId,
104+
data: formData,
105+
headers: formData.getHeaders(),
106+
});
107+
108+
$.export("$summary", `Reply created successfully with ID: ${response.id}`);
109+
return response;
110+
},
111+
};

0 commit comments

Comments
 (0)