Skip to content

Commit 5799ddf

Browse files
committed
Initial
1 parent 65e79d1 commit 5799ddf

File tree

11 files changed

+424
-1
lines changed

11 files changed

+424
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-assign-ticket-to-agent",
5+
name: "Assign Ticket to Agent",
6+
description: "Assign a Freshdesk ticket to a specific agent",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
16+
},
17+
responder_id: {
18+
type: "integer",
19+
label: "Agent ID",
20+
description: "ID of the agent to assign this ticket to",
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.freshdesk._makeRequest({
25+
$,
26+
method: "PUT",
27+
url: `/tickets/${this.ticketId}`,
28+
data: {
29+
responder_id: this.responder_id,
30+
},
31+
});
32+
$.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`);
33+
return response;
34+
},
35+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-assign-ticket-to-group",
5+
name: "Assign Ticket to Group",
6+
description: "Assign a Freshdesk ticket to a specific group",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
16+
},
17+
group_id: {
18+
type: "integer",
19+
label: "Group ID",
20+
description: "ID of the group to assign this ticket to",
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.freshdesk._makeRequest({
25+
$,
26+
method: "PUT",
27+
url: `/tickets/${this.ticketId}`,
28+
data: {
29+
group_id: this.group_id,
30+
},
31+
});
32+
$.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`);
33+
return response;
34+
},
35+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-close-ticket",
5+
name: "Close Ticket",
6+
description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed'
20+
21+
const response = await this.freshdesk._makeRequest({
22+
$,
23+
method: "PUT",
24+
url: `/tickets/${this.ticketId}`,
25+
data: {
26+
status: CLOSED_STATUS,
27+
},
28+
});
29+
30+
$.export("$summary", `Ticket ${this.ticketId} closed successfully`);
31+
return response;
32+
},
33+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-set-ticket-priority-test",
5+
name: "Set Ticket Priority",
6+
description: "Update the priority of a ticket in Freshdesk",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
16+
},
17+
ticketPriority: {
18+
propDefinition: [
19+
freshdesk,
20+
"ticketPriority",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.freshdesk._makeRequest({
26+
$,
27+
method: "PUT",
28+
url: `/tickets/${this.ticketId}`,
29+
data: {
30+
priority: this.ticketPriority,
31+
},
32+
});
33+
$.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`);
34+
return response;
35+
},
36+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-set-ticket-status-test",
5+
name: "Set Ticket Status",
6+
description: "Update the status of a ticket in Freshdesk",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
ticketId: {
12+
propDefinition: [
13+
freshdesk,
14+
"ticketId",
15+
],
16+
},
17+
ticketStatus: {
18+
propDefinition: [
19+
freshdesk,
20+
"ticketStatus",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.freshdesk._makeRequest({
26+
$,
27+
method: "PUT",
28+
url: `/tickets/${this.ticketId}`,
29+
data: {
30+
status: this.ticketStatus,
31+
},
32+
});
33+
$.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`);
34+
return response;
35+
},
36+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
2+
3+
// 🔧 Replace these with your real values
4+
const API_KEY = "YfaK2hd0KP3og3KbqV";
5+
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
6+
7+
const createGroup = async () => {
8+
const res = await fetch(`https://${DOMAIN}/api/v2/groups`, {
9+
method: "POST",
10+
headers: {
11+
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
12+
"Content-Type": "application/json",
13+
},
14+
body: JSON.stringify({
15+
name: "My Team",
16+
}),
17+
});
18+
19+
const data = await res.json();
20+
if (!res.ok) {
21+
console.error("❌ Group create error:", data);
22+
return;
23+
}
24+
console.log("✅ Group created:", data);
25+
};
26+
27+
createGroup();
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import fetch from "node-fetch"; // if you're using Node 18+, native fetch is available
2+
3+
// 🔧 Replace these with your real values
4+
const API_KEY = "YfaK2hd0KP3og3KbqV";
5+
const DOMAIN = "falc1.freshdesk.com"; // e.g. support.freshdesk.com
6+
7+
// 🎟️ Ticket payload
8+
const payload = {
9+
subject: "Test ticket for full update suite",
10+
description: "<strong>This is a test ticket</strong><br>With rich HTML content.",
11+
type: "Question",
12+
priority: 2, // Medium
13+
status: 2, // Open
14+
tags: ["api-test", "pipedream", "full-update"],
15+
email: "[email protected]", //
16+
// Uncomment and customize if you have these
17+
group_id: 157001089898,
18+
responder_id: 157005992678, //Agent ID
19+
custom_fields: {
20+
// Example: "cf_customer_type": "premium"
21+
},
22+
};
23+
24+
const createTicket = async () => {
25+
const response = await fetch(`https://${DOMAIN}/api/v2/tickets`, {
26+
method: "POST",
27+
headers: {
28+
"Authorization": "Basic " + Buffer.from(`${API_KEY}:X`).toString("base64"),
29+
"Content-Type": "application/json",
30+
},
31+
body: JSON.stringify(payload),
32+
});
33+
34+
if (!response.ok) {
35+
console.error("❌ Failed to create ticket", response.status, await response.text());
36+
return;
37+
}
38+
39+
const data = await response.json();
40+
console.log("✅ Ticket created:", data);
41+
};
42+
43+
createTicket();

0 commit comments

Comments
 (0)