Skip to content

Freshdesk - add support for notes #17598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all 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/brave_search_api/brave_search_api.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));
},
},
};
};
104 changes: 104 additions & 0 deletions components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import freshdesk from "../../freshdesk.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "freshdesk-add-note-to-ticket",
name: "Add Note to Ticket",
description: "Add a note or conversation to an existing ticket. [See the documentation](https://developers.freshdesk.com/api/#add_note_to_a_ticket).",
version: "0.0.1",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
body: {
type: "string",
label: "Note Body",
description: "Content of the note in HTML format",
},
private: {
type: "boolean",
label: "Private Note",
description: "Set to true if the note is private (internal)",
default: false,
},
incoming: {
type: "boolean",
label: "Incoming",
description: "Set to true if the note should be marked as incoming (false for outgoing)",
default: false,
optional: true,
},
user_id: {
propDefinition: [
freshdesk,
"agentId",
],
label: "User ID",
description: "ID of the user creating the note (defaults to the API user)",
optional: true,
},
notify_emails: {
type: "string[]",
label: "Notify Emails",
description: "Array of email addresses to notify about this note",
optional: true,
},
},
async run({ $ }) {
const {
freshdesk,
ticketId,
body,
private: isPrivate,
incoming,
user_id,
notify_emails,
} = this;

if (!body || !body.trim()) {
throw new ConfigurationError("Note body cannot be empty");
}

const ticketName = await freshdesk.getTicketName(ticketId) || "Unknown Ticket";

const data = {
body,
private: isPrivate,
};

if (incoming !== undefined) {
data.incoming = incoming;
}

if (user_id) {
const userId = Number(user_id);
if (isNaN(userId)) {
throw new ConfigurationError("User ID must be a valid number");
}
data.user_id = userId;
}

if (notify_emails && notify_emails.length > 0) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
const invalidEmails = notify_emails.filter((email) => !emailRegex.test(email));
if (invalidEmails.length > 0) {
throw new ConfigurationError(`Invalid email addresses: ${invalidEmails.join(", ")}`);
}
data.notify_emails = notify_emails;
}

const response = await freshdesk.addNoteToTicket({
$,
ticketId: Number(ticketId),
data,
});

$.export("$summary", `Note added to ticket "${ticketName}" (ID: ${ticketId})`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Add Ticket Tags",
description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
freshdesk,
ticketId: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-assign-ticket-to-agent",
name: "Assign Ticket to Agent",
description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-assign-ticket-to-group",
name: "Assign Ticket to Group",
description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
2 changes: 1 addition & 1 deletion components/freshdesk/actions/close-ticket/close-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-close-ticket",
name: "Close Ticket",
description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-create-company",
name: "Create a Company",
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "freshdesk-create-contact",
name: "Create a Contact",
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-create-ticket",
name: "Create a Ticket",
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
version: "0.0.6",
version: "0.0.7",
type: "action",
props: {
freshdesk,
Expand Down
2 changes: 1 addition & 1 deletion components/freshdesk/actions/get-ticket/get-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-get-ticket",
name: "Get Ticket Details",
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
version: "0.1.3",
version: "0.1.4",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "List Tickets",
description:
"Fetch up to 100 tickets according to the selected filters. [See the documentation](https://developers.freshdesk.com/api/#list_all_tickets)",
version: "0.2.3",
version: "0.2.4",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Remove Ticket Tags",
description: "Remove specific tags from a ticket. [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
freshdesk,
ticketId: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-set-ticket-priority",
name: "Set Ticket Priority",
description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "freshdesk-set-ticket-status",
name: "Set Ticket Status",
description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
name: "Set Ticket Tags",
description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
type: "action",
version: "0.0.1",
version: "0.0.2",
props: {
freshdesk,
ticketId: {
Expand Down
5 changes: 2 additions & 3 deletions components/freshdesk/actions/update-ticket/update-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "freshdesk-update-ticket",
name: "Update a Ticket",
description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
freshdesk,
Expand Down Expand Up @@ -100,7 +100,7 @@ export default {

const data = removeNullEntries(fields);

const ticketName = await freshdesk.getTicketName(ticketId);
const ticketName = await freshdesk.getTicketName(ticketId) || "Unknown Ticket";

if (!Object.keys(data).length) {
throw new Error("Please provide at least one field to update.");
Expand All @@ -119,4 +119,3 @@ export default {
return response;
},
};

38 changes: 34 additions & 4 deletions components/freshdesk/freshdesk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,17 @@ export default {
});
},
async getTicketName(ticketId) {
const ticket = await this.getTicket({
ticketId,
});
return ticket.subject;
try {
const ticket = await this.getTicket({
ticketId,
});
return ticket.subject;
} catch (error) {
if (error.response?.status === 404) {
return null;
}
throw error;
}
},
parseIfJSONString(input) {
if (typeof input === "string") {
Expand All @@ -272,6 +279,29 @@ export default {
}
return input;
},
/**
* Add a note to a Freshdesk ticket
* @param {Object} options - The options object
* @param {number} options.ticketId - The ID of the ticket to add the note to
* @param {Object} options.data - The note data object
* @param {string} options.data.body - Content of the note in HTML format
* @param {boolean} [options.data.private=false] - Whether the note is private
* @param {boolean} [options.data.incoming] - Whether the note is incoming
* @param {number} [options.data.user_id] - ID of the user creating the note
* @param {string[]} [options.data.notify_emails] - Array of email addresses to notify
* @param {...*} args - Additional arguments passed to _makeRequest
* @returns {Promise<Object>} The API response containing the created note
*/
async addNoteToTicket({
ticketId, data, ...args
}) {
return this._makeRequest({
url: `/tickets/${ticketId}/notes`,
method: "post",
data,
...args,
});
},
/**
* Set tags on a ticket (replaces all existing tags)
* @param {object} args - Arguments object
Expand Down
2 changes: 1 addition & 1 deletion components/freshdesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/freshdesk",
"version": "0.3.0",
"version": "0.3.1",
"description": "Pipedream Freshdesk Components",
"main": "freshdesk.app.mjs",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion components/freshdesk/sources/new-contact/new-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "freshdesk-new-contact",
name: "New Contact Created",
description: "Emit new event when a contact is created. [See the documentation](https://developers.freshdesk.com/api/#filter_contacts)",
version: "0.0.6",
version: "0.0.7",
type: "source",
props: {
freshdesk,
Expand Down
2 changes: 1 addition & 1 deletion components/freshdesk/sources/new-ticket/new-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "freshdesk-new-ticket",
name: "New Ticket Created",
description: "Emit new event when a ticket is created. [See the documentation](https://developers.freshdesk.com/api/#filter_tickets)",
version: "0.0.6",
version: "0.0.7",
type: "source",
props: {
freshdesk,
Expand Down
2 changes: 1 addition & 1 deletion components/rewiser/rewiser.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/snipe_it/snipe_it.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));
},
},
};
};
6 changes: 2 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading