Skip to content

Commit eccf8d3

Browse files
seynadioAfstklaclaudeandrewjschuang
authored
Freshdesk - add support for notes (#17598)
* fix issues * Refactor Freshdesk: Create separate add-note-to-ticket action - Created dedicated add-note-to-ticket action for better separation of concerns - Removed note functionality from update-ticket action to maintain single responsibility - Added addNoteToTicket method to freshdesk.app.mjs - Bumped update-ticket version to 0.0.3 This provides a cleaner API where each action has a clear, single purpose. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Update pnpm-lock.yaml * Update update-ticket.mjs * whitespace * fix: Address PR review comments - Add JSDoc documentation to addNoteToTicket method - Add error handling for missing tickets in getTicketName (returns null for 404) - Add validation for user_id parameter to ensure valid number - Add email validation for notify_emails array - Update ticket name handling to use fallback when null 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * pnpm * bump version * bump version --------- Co-authored-by: Job Nijenhuis <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Job <[email protected]> Co-authored-by: Andrew Chuang <[email protected]>
1 parent d4763f3 commit eccf8d3

File tree

23 files changed

+161
-30
lines changed

23 files changed

+161
-30
lines changed

components/brave_search_api/brave_search_api.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: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "freshdesk-add-note-to-ticket",
6+
name: "Add Note to Ticket",
7+
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.1",
9+
type: "action",
10+
props: {
11+
freshdesk,
12+
ticketId: {
13+
propDefinition: [
14+
freshdesk,
15+
"ticketId",
16+
],
17+
},
18+
body: {
19+
type: "string",
20+
label: "Note Body",
21+
description: "Content of the note in HTML format",
22+
},
23+
private: {
24+
type: "boolean",
25+
label: "Private Note",
26+
description: "Set to true if the note is private (internal)",
27+
default: false,
28+
},
29+
incoming: {
30+
type: "boolean",
31+
label: "Incoming",
32+
description: "Set to true if the note should be marked as incoming (false for outgoing)",
33+
default: false,
34+
optional: true,
35+
},
36+
user_id: {
37+
propDefinition: [
38+
freshdesk,
39+
"agentId",
40+
],
41+
label: "User ID",
42+
description: "ID of the user creating the note (defaults to the API user)",
43+
optional: true,
44+
},
45+
notify_emails: {
46+
type: "string[]",
47+
label: "Notify Emails",
48+
description: "Array of email addresses to notify about this note",
49+
optional: true,
50+
},
51+
},
52+
async run({ $ }) {
53+
const {
54+
freshdesk,
55+
ticketId,
56+
body,
57+
private: isPrivate,
58+
incoming,
59+
user_id,
60+
notify_emails,
61+
} = this;
62+
63+
if (!body || !body.trim()) {
64+
throw new ConfigurationError("Note body cannot be empty");
65+
}
66+
67+
const ticketName = await freshdesk.getTicketName(ticketId) || "Unknown Ticket";
68+
69+
const data = {
70+
body,
71+
private: isPrivate,
72+
};
73+
74+
if (incoming !== undefined) {
75+
data.incoming = incoming;
76+
}
77+
78+
if (user_id) {
79+
const userId = Number(user_id);
80+
if (isNaN(userId)) {
81+
throw new ConfigurationError("User ID must be a valid number");
82+
}
83+
data.user_id = userId;
84+
}
85+
86+
if (notify_emails && notify_emails.length > 0) {
87+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
88+
const invalidEmails = notify_emails.filter((email) => !emailRegex.test(email));
89+
if (invalidEmails.length > 0) {
90+
throw new ConfigurationError(`Invalid email addresses: ${invalidEmails.join(", ")}`);
91+
}
92+
data.notify_emails = notify_emails;
93+
}
94+
95+
const response = await freshdesk.addNoteToTicket({
96+
$,
97+
ticketId: Number(ticketId),
98+
data,
99+
});
100+
101+
$.export("$summary", `Note added to ticket "${ticketName}" (ID: ${ticketId})`);
102+
return response;
103+
},
104+
};

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.1",
9+
version: "0.0.2",
1010
props: {
1111
freshdesk,
1212
ticketId: {

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.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
freshdesk,

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.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
freshdesk,

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.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
freshdesk,

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.5",
7+
version: "0.0.6",
88
type: "action",
99
props: {
1010
freshdesk,

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.5",
8+
version: "0.0.6",
99
type: "action",
1010
props: {
1111
freshdesk,

components/freshdesk/actions/create-ticket/create-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-create-ticket",
55
name: "Create a Ticket",
66
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
7-
version: "0.0.6",
7+
version: "0.0.7",
88
type: "action",
99
props: {
1010
freshdesk,

components/freshdesk/actions/get-ticket/get-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-get-ticket",
55
name: "Get Ticket Details",
66
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
7-
version: "0.1.3",
7+
version: "0.1.4",
88
type: "action",
99
props: {
1010
freshdesk,

0 commit comments

Comments
 (0)