Skip to content

[ACTIONS] Freshdesk. Add update-ticket and SET actions #16450

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 7 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-assign-ticket-to-agent",
name: "Assign Ticket to Agent",
description: "Assign a Freshdesk ticket to a specific agent",
version: "0.0.3",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
responder_id: {
type: "integer",
label: "Agent ID",
description: "ID of the agent to assign this ticket to",
},
},
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
responder_id: this.responder_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-assign-ticket-to-group",
name: "Assign Ticket to Group",
description: "Assign a Freshdesk ticket to a specific group",
version: "0.0.3",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
group_id: {
type: "integer",
label: "Group ID",
description: "ID of the group to assign this ticket to",
},
},
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
group_id: this.group_id,
},
});
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
return response;
},
};
33 changes: 33 additions & 0 deletions components/freshdesk/actions/close-ticket/close-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import freshdesk from "../../freshdesk.app.mjs";

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.3",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
},
async run({ $ }) {
const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed'

const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
status: CLOSED_STATUS,
},
});

$.export("$summary", `Ticket ${this.ticketId} closed successfully`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-set-ticket-priority",
name: "Set Ticket Priority",
description: "Update the priority of a ticket in Freshdesk",
version: "0.0.3",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
ticketPriority: {
propDefinition: [
freshdesk,
"ticketPriority",
],
},
},
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
priority: this.ticketPriority,
},
});
$.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-set-ticket-status",
name: "Set Ticket Status",
description: "Update the status of a ticket in Freshdesk",
version: "0.0.3",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
ticketStatus: {
propDefinition: [
freshdesk,
"ticketStatus",
],
},
},
async run({ $ }) {
const response = await this.freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${this.ticketId}`,
data: {
status: this.ticketStatus,
},
});
$.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`);
return response;
},
};
140 changes: 140 additions & 0 deletions components/freshdesk/actions/update-ticket/update-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import freshdesk from "../../freshdesk.app.mjs";
import { removeNullEntries } from "../../common/utils.mjs";

export default {
key: "freshdesk-update-ticket",
name: "Update a Ticket",
description: "Update status, priority, subject, description, agent, group, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
version: "0.0.12",
type: "action",
props: {
freshdesk,
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
ticketStatus: {
propDefinition: [
freshdesk,
"ticketStatus",
],
optional: true,
},
ticketPriority: {
propDefinition: [
freshdesk,
"ticketPriority",
],
optional: true,
},
subject: {
type: "string",
label: "Subject",
description: "Ticket subject",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Detailed ticket description (HTML allowed)",
optional: true,
},
group_id: {
type: "integer",
label: "Group ID",
description: "ID of the group to assign this ticket to",
optional: true,
},
responder_id: {
type: "integer",
label: "Agent ID",
description: "ID of the agent to assign this ticket to",
optional: true,
},
email: {
type: "string",
label: "Requester Email (replaces requester)",
description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.",
optional: true,
},
phone: {
type: "string",
label: "Requester Phone (replaces requester)",
description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.",
optional: true,
},
name: {
type: "string",
label: "Requester Name (required with phone if no email)",
description: "Used when creating a contact with phone but no email.",
optional: true,
},
type: {
type: "string",
label: "Type",
description: "Type of ticket (must match one of the allowed values)",
optional: true,
options: [
"Question",
"Incident",
"Problem",
"Feature Request",
"Refund",
],
},
custom_fields: {
type: "object",
label: "Custom Fields",
description: "Custom fields as key-value pairs (make sure types match your config)",
optional: true,
},
},
async run({ $ }) {
const {
freshdesk,
ticketId,
ticketStatus,
ticketPriority,
subject,
description,
type,
group_id,
responder_id,
email,
phone,
name,
custom_fields,
} = this;

const data = removeNullEntries({
status: ticketStatus,
priority: ticketPriority,
subject,
description,
type,
group_id,
responder_id,
email,
phone,
name,
custom_fields,
});

if (!Object.keys(data).length) {
throw new Error("Please provide at least one field to update.");
}

const response = await freshdesk._makeRequest({
$,
method: "PUT",
url: `/tickets/${ticketId}`,
data,
});

$.export("$summary", `Ticket ${ticketId} updated successfully`);
return response;
},
};

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.1.1",
"version": "0.1.3",
"description": "Pipedream Freshdesk Components",
"main": "freshdesk.app.mjs",
"keywords": [
Expand Down
Loading