Skip to content

Commit c79d7f3

Browse files
Afstklaclaude
andcommitted
Add separate add-note-to-ticket action for Freshdesk
- Created new action to add notes/conversations to tickets - Supports both public and private notes - Added addNoteToTicket method to freshdesk.app.mjs - Follows single responsibility principle 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 404d68f commit c79d7f3

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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);
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+
data.user_id = Number(user_id);
80+
}
81+
82+
if (notify_emails && notify_emails.length > 0) {
83+
data.notify_emails = notify_emails;
84+
}
85+
86+
const response = await freshdesk.addNoteToTicket({
87+
$,
88+
ticketId: Number(ticketId),
89+
data,
90+
});
91+
92+
$.export("$summary", `Note added to ticket "${ticketName}" (ID: ${ticketId})`);
93+
return response;
94+
},
95+
};

components/freshdesk/freshdesk.app.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,15 @@ export default {
266266
}
267267
return input;
268268
},
269+
async addNoteToTicket({
270+
ticketId, data, ...args
271+
}) {
272+
return this._makeRequest({
273+
url: `/tickets/${ticketId}/notes`,
274+
method: "post",
275+
data,
276+
...args,
277+
});
278+
},
269279
},
270280
};

0 commit comments

Comments
 (0)