@pipedream/freshdesk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/add-ticket-tags/add-ticket-tags.mjs +45 -0
- package/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs +41 -0
- package/actions/assign-ticket-to-group/assign-ticket-to-group.mjs +42 -0
- package/actions/close-ticket/close-ticket.mjs +33 -0
- package/actions/create-company/create-company.mjs +1 -1
- package/actions/create-contact/create-contact.mjs +1 -1
- package/actions/create-ticket/create-ticket.mjs +1 -1
- package/actions/get-ticket/get-ticket.mjs +1 -1
- package/actions/list-all-tickets/list-all-tickets.mjs +1 -1
- package/actions/remove-ticket-tags/remove-ticket-tags.mjs +45 -0
- package/actions/set-ticket-priority/set-ticket-priority.mjs +51 -0
- package/actions/set-ticket-status/set-ticket-status.mjs +53 -0
- package/actions/set-ticket-tags/set-ticket-tags.mjs +45 -0
- package/actions/update-ticket/update-ticket.mjs +122 -0
- package/freshdesk.app.mjs +138 -0
- package/package.json +1 -1
- package/sources/new-contact/new-contact.mjs +1 -1
- package/sources/new-ticket/new-ticket.mjs +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "freshdesk-add-ticket-tags",
|
|
6
|
+
name: "Add Ticket Tags",
|
|
7
|
+
description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
freshdesk,
|
|
12
|
+
ticketId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
freshdesk,
|
|
15
|
+
"ticketId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
ticketTags: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
freshdesk,
|
|
21
|
+
"ticketTags",
|
|
22
|
+
],
|
|
23
|
+
description: "Array of tags to add to the ticket. These will be added to any existing tags.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ $ }) {
|
|
27
|
+
const {
|
|
28
|
+
ticketId,
|
|
29
|
+
ticketTags,
|
|
30
|
+
} = this;
|
|
31
|
+
|
|
32
|
+
if (!ticketTags || ticketTags.length === 0) {
|
|
33
|
+
throw new ConfigurationError("At least one tag must be provided");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const response = await this.freshdesk.addTicketTags({
|
|
37
|
+
ticketId,
|
|
38
|
+
tags: ticketTags,
|
|
39
|
+
$,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
$.export("$summary", `Successfully added ${ticketTags.length} tag(s) to ticket ${ticketId}`);
|
|
43
|
+
return response;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
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. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
freshdesk,
|
|
11
|
+
ticketId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
freshdesk,
|
|
14
|
+
"ticketId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
responder_id: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
freshdesk,
|
|
20
|
+
"agentId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
|
|
26
|
+
const ticketName = await this.freshdesk.getTicketName(this.ticketId);
|
|
27
|
+
|
|
28
|
+
const response = await this.freshdesk._makeRequest({
|
|
29
|
+
$,
|
|
30
|
+
method: "PUT",
|
|
31
|
+
url: `/tickets/${this.ticketId}`,
|
|
32
|
+
data: {
|
|
33
|
+
responder_id: this.responder_id,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
$.export("$summary",
|
|
37
|
+
`Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to agent ${this.responder_id}`);
|
|
38
|
+
|
|
39
|
+
return response;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
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 [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
freshdesk,
|
|
11
|
+
ticketId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
freshdesk,
|
|
14
|
+
"ticketId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
group_id: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
freshdesk,
|
|
20
|
+
"groupId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
|
|
26
|
+
const ticketName = await this.freshdesk.getTicketName(this.ticketId);
|
|
27
|
+
|
|
28
|
+
const response = await this.freshdesk._makeRequest({
|
|
29
|
+
$,
|
|
30
|
+
method: "PUT",
|
|
31
|
+
url: `/tickets/${this.ticketId}`,
|
|
32
|
+
data: {
|
|
33
|
+
group_id: this.group_id,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$.export("$summary",
|
|
38
|
+
`Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to group ${this.group_id}`);
|
|
39
|
+
|
|
40
|
+
return response;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -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.2",
|
|
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
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "freshdesk-create-company",
|
|
5
5
|
name: "Create a Company",
|
|
6
6
|
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.5",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
freshdesk,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "freshdesk-create-contact",
|
|
6
6
|
name: "Create a Contact",
|
|
7
7
|
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.5",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
freshdesk,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "freshdesk-create-ticket",
|
|
5
5
|
name: "Create a Ticket",
|
|
6
6
|
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
freshdesk,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "freshdesk-get-ticket",
|
|
5
5
|
name: "Get Ticket Details",
|
|
6
6
|
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
freshdesk,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Tickets",
|
|
6
6
|
description:
|
|
7
7
|
"Fetch up to 100 tickets according to the selected filters. [See the documentation](https://developers.freshdesk.com/api/#list_all_tickets)",
|
|
8
|
-
version: "0.2.
|
|
8
|
+
version: "0.2.3",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
freshdesk,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "freshdesk-remove-ticket-tags",
|
|
6
|
+
name: "Remove Ticket Tags",
|
|
7
|
+
description: "Remove specific tags from a ticket. [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
freshdesk,
|
|
12
|
+
ticketId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
freshdesk,
|
|
15
|
+
"ticketId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
ticketTags: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
freshdesk,
|
|
21
|
+
"ticketTags",
|
|
22
|
+
],
|
|
23
|
+
description: "Array of tags to remove from the ticket. Only these specific tags will be removed.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ $ }) {
|
|
27
|
+
const {
|
|
28
|
+
ticketId,
|
|
29
|
+
ticketTags,
|
|
30
|
+
} = this;
|
|
31
|
+
|
|
32
|
+
if (!ticketTags || ticketTags.length === 0) {
|
|
33
|
+
throw new ConfigurationError("At least one tag must be provided");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const response = await this.freshdesk.removeTicketTags({
|
|
37
|
+
ticketId,
|
|
38
|
+
tags: ticketTags,
|
|
39
|
+
$,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
$.export("$summary", `Successfully removed ${ticketTags.length} tag(s) from ticket ${ticketId}`);
|
|
43
|
+
return response;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "freshdesk-set-ticket-priority",
|
|
5
|
+
name: "Set Ticket Priority",
|
|
6
|
+
description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
|
|
7
|
+
version: "0.0.2",
|
|
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
|
+
|
|
26
|
+
const ticketName = await this.freshdesk.getTicketName(this.ticketId);
|
|
27
|
+
|
|
28
|
+
const response = await this.freshdesk._makeRequest({
|
|
29
|
+
$,
|
|
30
|
+
method: "PUT",
|
|
31
|
+
url: `/tickets/${this.ticketId}`,
|
|
32
|
+
data: {
|
|
33
|
+
priority: this.ticketPriority,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const priorityLabels = {
|
|
38
|
+
1: "Low",
|
|
39
|
+
2: "Medium",
|
|
40
|
+
3: "High",
|
|
41
|
+
4: "Urgent",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const priorityLabel = priorityLabels[this.ticketPriority] || this.ticketPriority;
|
|
45
|
+
|
|
46
|
+
$.export("$summary",
|
|
47
|
+
`Ticket ${ticketName} (ID: ${this.ticketId}) priority updated to "${priorityLabel}".`);
|
|
48
|
+
|
|
49
|
+
return response;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "freshdesk-set-ticket-status",
|
|
5
|
+
name: "Set Ticket Status",
|
|
6
|
+
description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
|
|
7
|
+
version: "0.0.2",
|
|
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
|
+
|
|
26
|
+
const ticketName = await this.freshdesk.getTicketName(this.ticketId);
|
|
27
|
+
|
|
28
|
+
const response = await this.freshdesk._makeRequest({
|
|
29
|
+
$,
|
|
30
|
+
method: "PUT",
|
|
31
|
+
url: `/tickets/${this.ticketId}`,
|
|
32
|
+
data: {
|
|
33
|
+
status: this.ticketStatus,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const statusLabels = {
|
|
38
|
+
2: "Open",
|
|
39
|
+
3: "Pending",
|
|
40
|
+
4: "Resolved",
|
|
41
|
+
5: "Closed",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const statusLabel = statusLabels[this.ticketStatus] || this.ticketStatus;
|
|
45
|
+
|
|
46
|
+
$.export(
|
|
47
|
+
"$summary",
|
|
48
|
+
`Ticket "${ticketName}" (ID: ${this.ticketId}) status updated to "${statusLabel}".`,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return response;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "freshdesk-set-ticket-tags",
|
|
6
|
+
name: "Set Ticket Tags",
|
|
7
|
+
description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
|
|
8
|
+
type: "action",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
props: {
|
|
11
|
+
freshdesk,
|
|
12
|
+
ticketId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
freshdesk,
|
|
15
|
+
"ticketId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
ticketTags: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
freshdesk,
|
|
21
|
+
"ticketTags",
|
|
22
|
+
],
|
|
23
|
+
description: "Array of tags to set on the ticket. This will replace all existing tags.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ $ }) {
|
|
27
|
+
const {
|
|
28
|
+
ticketId,
|
|
29
|
+
ticketTags,
|
|
30
|
+
} = this;
|
|
31
|
+
|
|
32
|
+
if (!ticketTags || ticketTags.length === 0) {
|
|
33
|
+
throw new ConfigurationError("At least one tag must be provided");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const response = await this.freshdesk.setTicketTags({
|
|
37
|
+
ticketId,
|
|
38
|
+
tags: ticketTags,
|
|
39
|
+
$,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
$.export("$summary", `Successfully set ${ticketTags.length} tag(s) on ticket ${ticketId}`);
|
|
43
|
+
return response;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import freshdesk from "../../freshdesk.app.mjs";
|
|
2
|
+
import { removeNullEntries } from "../../common/utils.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "freshdesk-update-ticket",
|
|
6
|
+
name: "Update a Ticket",
|
|
7
|
+
description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).",
|
|
8
|
+
version: "0.0.2",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
freshdesk,
|
|
12
|
+
ticketId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
freshdesk,
|
|
15
|
+
"ticketId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
status: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
freshdesk,
|
|
21
|
+
"ticketStatus",
|
|
22
|
+
],
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
25
|
+
priority: {
|
|
26
|
+
propDefinition: [
|
|
27
|
+
freshdesk,
|
|
28
|
+
"ticketPriority",
|
|
29
|
+
],
|
|
30
|
+
optional: true,
|
|
31
|
+
},
|
|
32
|
+
subject: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Subject",
|
|
35
|
+
description: "Ticket subject",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
description: {
|
|
39
|
+
type: "string",
|
|
40
|
+
label: "Description",
|
|
41
|
+
description: "Detailed ticket description (HTML allowed)",
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
group_id: {
|
|
45
|
+
propDefinition: [
|
|
46
|
+
freshdesk,
|
|
47
|
+
"groupId",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
responder_id: {
|
|
51
|
+
propDefinition: [
|
|
52
|
+
freshdesk,
|
|
53
|
+
"agentId",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
email: {
|
|
57
|
+
type: "string",
|
|
58
|
+
label: "Requester Email (replaces requester)",
|
|
59
|
+
description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.",
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
phone: {
|
|
63
|
+
type: "string",
|
|
64
|
+
label: "Requester Phone (replaces requester)",
|
|
65
|
+
description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.",
|
|
66
|
+
optional: true,
|
|
67
|
+
},
|
|
68
|
+
name: {
|
|
69
|
+
type: "string",
|
|
70
|
+
label: "Requester Name (required with phone if no email)",
|
|
71
|
+
description: "Used when creating a contact with phone but no email.",
|
|
72
|
+
optional: true,
|
|
73
|
+
},
|
|
74
|
+
type: {
|
|
75
|
+
type: "string",
|
|
76
|
+
label: "Type",
|
|
77
|
+
description: "Type of ticket (must match one of the allowed values)",
|
|
78
|
+
optional: true,
|
|
79
|
+
options: [
|
|
80
|
+
"Question",
|
|
81
|
+
"Incident",
|
|
82
|
+
"Problem",
|
|
83
|
+
"Feature Request",
|
|
84
|
+
"Refund",
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
custom_fields: {
|
|
88
|
+
type: "object",
|
|
89
|
+
label: "Custom Fields",
|
|
90
|
+
description: "Custom fields as key-value pairs (make sure types match your config)",
|
|
91
|
+
optional: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
async run({ $ }) {
|
|
95
|
+
const {
|
|
96
|
+
freshdesk,
|
|
97
|
+
ticketId,
|
|
98
|
+
...fields
|
|
99
|
+
} = this;
|
|
100
|
+
|
|
101
|
+
const data = removeNullEntries(fields);
|
|
102
|
+
|
|
103
|
+
const ticketName = await freshdesk.getTicketName(ticketId);
|
|
104
|
+
|
|
105
|
+
if (!Object.keys(data).length) {
|
|
106
|
+
throw new Error("Please provide at least one field to update.");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (data.custom_fields) freshdesk.parseIfJSONString(data.custom_fields);
|
|
110
|
+
|
|
111
|
+
const response = await freshdesk._makeRequest({
|
|
112
|
+
$,
|
|
113
|
+
method: "PUT",
|
|
114
|
+
url: `/tickets/${ticketId}`,
|
|
115
|
+
data,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
$.export("$summary", `Ticket "${ticketName}" (ID: ${this.ticketId}) updated successfully`);
|
|
119
|
+
return response;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
package/freshdesk.app.mjs
CHANGED
|
@@ -19,6 +19,7 @@ export default {
|
|
|
19
19
|
}));
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
+
|
|
22
23
|
ticketId: {
|
|
23
24
|
type: "integer",
|
|
24
25
|
label: "Ticket ID",
|
|
@@ -37,6 +38,48 @@ export default {
|
|
|
37
38
|
}));
|
|
38
39
|
},
|
|
39
40
|
},
|
|
41
|
+
agentId: {
|
|
42
|
+
type: "integer",
|
|
43
|
+
label: "Agent",
|
|
44
|
+
description: "Select an agent to assign the ticket to",
|
|
45
|
+
async options({ page = 0 }) {
|
|
46
|
+
const response = await this._makeRequest({
|
|
47
|
+
method: "GET",
|
|
48
|
+
url: "/agents",
|
|
49
|
+
params: {
|
|
50
|
+
page: page + 1,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return response.map((agent) => ({
|
|
55
|
+
label: agent.contact?.name
|
|
56
|
+
? `${agent.contact.name} (${agent.contact.email || "No email"})`
|
|
57
|
+
: `Agent ${agent.id}`,
|
|
58
|
+
value: agent.id,
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
groupId: {
|
|
63
|
+
type: "integer",
|
|
64
|
+
label: "Group",
|
|
65
|
+
description: "Select a group to assign the ticket to.",
|
|
66
|
+
async options({ page = 0 }) {
|
|
67
|
+
const groups = await this._makeRequest({
|
|
68
|
+
method: "GET",
|
|
69
|
+
url: "/groups",
|
|
70
|
+
params: {
|
|
71
|
+
page: page + 1,
|
|
72
|
+
per_page: 100,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return groups.map((group) => ({
|
|
77
|
+
label: group.name || `Group ${group.id}`,
|
|
78
|
+
value: group.id,
|
|
79
|
+
}));
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
|
|
40
83
|
ticketStatus: {
|
|
41
84
|
type: "integer",
|
|
42
85
|
label: "Status",
|
|
@@ -73,6 +116,12 @@ export default {
|
|
|
73
116
|
}));
|
|
74
117
|
},
|
|
75
118
|
},
|
|
119
|
+
ticketTags: {
|
|
120
|
+
type: "string[]",
|
|
121
|
+
label: "Tags",
|
|
122
|
+
description: "Array of tags to apply to the ticket. Each tag must be 32 characters or less.",
|
|
123
|
+
optional: true,
|
|
124
|
+
},
|
|
76
125
|
},
|
|
77
126
|
methods: {
|
|
78
127
|
setLastDateChecked(db, value) {
|
|
@@ -207,5 +256,94 @@ export default {
|
|
|
207
256
|
...args,
|
|
208
257
|
});
|
|
209
258
|
},
|
|
259
|
+
async getTicketName(ticketId) {
|
|
260
|
+
const ticket = await this.getTicket({
|
|
261
|
+
ticketId,
|
|
262
|
+
});
|
|
263
|
+
return ticket.subject;
|
|
264
|
+
},
|
|
265
|
+
parseIfJSONString(input) {
|
|
266
|
+
if (typeof input === "string") {
|
|
267
|
+
try {
|
|
268
|
+
return JSON.parse(input);
|
|
269
|
+
} catch (error) {
|
|
270
|
+
return input;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return input;
|
|
274
|
+
},
|
|
275
|
+
/**
|
|
276
|
+
* Set tags on a ticket (replaces all existing tags)
|
|
277
|
+
* @param {object} args - Arguments object
|
|
278
|
+
* @param {string|number} args.ticketId - The ticket ID
|
|
279
|
+
* @param {string[]} args.tags - Array of tags to set
|
|
280
|
+
* @returns {Promise<object>} API response
|
|
281
|
+
*/
|
|
282
|
+
async setTicketTags({
|
|
283
|
+
ticketId, tags, ...args
|
|
284
|
+
}) {
|
|
285
|
+
return this._makeRequest({
|
|
286
|
+
url: `/tickets/${ticketId}`,
|
|
287
|
+
method: "PUT",
|
|
288
|
+
data: {
|
|
289
|
+
tags,
|
|
290
|
+
},
|
|
291
|
+
...args,
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* Add tags to a ticket (appends to existing tags)
|
|
296
|
+
* @param {object} args - Arguments object
|
|
297
|
+
* @param {string|number} args.ticketId - The ticket ID
|
|
298
|
+
* @param {string[]} args.tags - Array of tags to add
|
|
299
|
+
* @returns {Promise<object>} API response
|
|
300
|
+
*/
|
|
301
|
+
async addTicketTags({
|
|
302
|
+
ticketId, tags, ...args
|
|
303
|
+
}) {
|
|
304
|
+
// Get current ticket to merge tags
|
|
305
|
+
const ticket = await this.getTicket({
|
|
306
|
+
ticketId,
|
|
307
|
+
...args,
|
|
308
|
+
});
|
|
309
|
+
const currentTags = ticket.tags || [];
|
|
310
|
+
const newTags = [
|
|
311
|
+
...new Set([
|
|
312
|
+
...currentTags,
|
|
313
|
+
...tags,
|
|
314
|
+
]),
|
|
315
|
+
]; // Remove duplicates
|
|
316
|
+
|
|
317
|
+
return this.setTicketTags({
|
|
318
|
+
ticketId,
|
|
319
|
+
tags: newTags,
|
|
320
|
+
...args,
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
/**
|
|
324
|
+
* Remove specific tags from a ticket
|
|
325
|
+
* @param {object} args - Arguments object
|
|
326
|
+
* @param {string|number} args.ticketId - The ticket ID
|
|
327
|
+
* @param {string[]} args.tags - Array of tags to remove
|
|
328
|
+
* @returns {Promise<object>} API response
|
|
329
|
+
*/
|
|
330
|
+
async removeTicketTags({
|
|
331
|
+
ticketId, tags, ...args
|
|
332
|
+
}) {
|
|
333
|
+
// Get current ticket to filter tags
|
|
334
|
+
const ticket = await this.getTicket({
|
|
335
|
+
ticketId,
|
|
336
|
+
...args,
|
|
337
|
+
});
|
|
338
|
+
const currentTags = ticket.tags || [];
|
|
339
|
+
const tagsToRemove = new Set(tags);
|
|
340
|
+
const remainingTags = currentTags.filter((tag) => !tagsToRemove.has(tag));
|
|
341
|
+
|
|
342
|
+
return this.setTicketTags({
|
|
343
|
+
ticketId,
|
|
344
|
+
tags: remainingTags,
|
|
345
|
+
...args,
|
|
346
|
+
});
|
|
347
|
+
},
|
|
210
348
|
},
|
|
211
349
|
};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "freshdesk-new-contact",
|
|
7
7
|
name: "New Contact Created",
|
|
8
8
|
description: "Emit new event when a contact is created. [See the documentation](https://developers.freshdesk.com/api/#filter_contacts)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.6",
|
|
10
10
|
type: "source",
|
|
11
11
|
props: {
|
|
12
12
|
freshdesk,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "freshdesk-new-ticket",
|
|
7
7
|
name: "New Ticket Created",
|
|
8
8
|
description: "Emit new event when a ticket is created. [See the documentation](https://developers.freshdesk.com/api/#filter_tickets)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.6",
|
|
10
10
|
type: "source",
|
|
11
11
|
props: {
|
|
12
12
|
freshdesk,
|