@pipedream/freshdesk 0.3.0 → 0.4.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.
Files changed (39) hide show
  1. package/actions/add-note-to-ticket/add-note-to-ticket.mjs +104 -0
  2. package/actions/add-ticket-tags/add-ticket-tags.mjs +1 -1
  3. package/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs +1 -1
  4. package/actions/assign-ticket-to-group/assign-ticket-to-group.mjs +1 -1
  5. package/actions/close-ticket/close-ticket.mjs +1 -1
  6. package/actions/create-agent/create-agent.mjs +103 -0
  7. package/actions/create-company/create-company.mjs +1 -1
  8. package/actions/create-contact/create-contact.mjs +1 -1
  9. package/actions/create-solution-article/create-solution-article.mjs +72 -0
  10. package/actions/create-ticket/create-ticket.mjs +1 -1
  11. package/actions/create-ticket-field/create-ticket-field.mjs +109 -0
  12. package/actions/delete-solution-article/delete-solution-article.mjs +44 -0
  13. package/actions/get-contact/get-contact.mjs +26 -0
  14. package/actions/get-solution-article/get-solution-article.mjs +44 -0
  15. package/actions/get-ticket/get-ticket.mjs +1 -1
  16. package/actions/list-agents/list-agents.mjs +66 -0
  17. package/actions/list-all-tickets/list-all-tickets.mjs +1 -1
  18. package/actions/list-category-folders/list-category-folders.mjs +28 -0
  19. package/actions/list-folder-articles/list-folder-articles.mjs +47 -0
  20. package/actions/list-solution-categories/list-solution-categories.mjs +21 -0
  21. package/actions/list-ticket-fields/list-ticket-fields.mjs +32 -0
  22. package/actions/remove-ticket-tags/remove-ticket-tags.mjs +1 -1
  23. package/actions/set-ticket-priority/set-ticket-priority.mjs +1 -1
  24. package/actions/set-ticket-status/set-ticket-status.mjs +1 -1
  25. package/actions/set-ticket-tags/set-ticket-tags.mjs +1 -1
  26. package/actions/update-agent/update-agent.mjs +112 -0
  27. package/actions/update-contact/update-contact.mjs +64 -0
  28. package/actions/update-solution-article/update-solution-article.mjs +84 -0
  29. package/actions/update-ticket/update-ticket.mjs +2 -3
  30. package/actions/update-ticket-field/update-ticket-field.mjs +106 -0
  31. package/common/constants.mjs +38 -0
  32. package/common/utils.mjs +27 -0
  33. package/freshdesk.app.mjs +330 -6
  34. package/package.json +1 -1
  35. package/sources/common/polling.mjs +63 -0
  36. package/sources/contact-updated/contact-updated.mjs +28 -0
  37. package/sources/new-contact/new-contact.mjs +18 -40
  38. package/sources/new-ticket/new-ticket.mjs +18 -43
  39. package/sources/ticket-updated/ticket-updated.mjs +28 -0
@@ -0,0 +1,28 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "freshdesk-list-category-folders",
5
+ name: "List Category Folders",
6
+ description: "List category folders in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_folder_attributes)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ freshdesk,
11
+ categoryId: {
12
+ propDefinition: [
13
+ freshdesk,
14
+ "categoryId",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const response = await this.freshdesk.listCategoryFolders({
20
+ $,
21
+ categoryId: this.categoryId,
22
+ });
23
+ $.export("$summary", `Successfully listed ${response.length} solution folder${response.length === 1
24
+ ? ""
25
+ : "s"}`);
26
+ return response;
27
+ },
28
+ };
@@ -0,0 +1,47 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "freshdesk-list-folder-articles",
5
+ name: "List Folder Articles",
6
+ description: "List folder articles in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_article_attributes)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ freshdesk,
11
+ categoryId: {
12
+ propDefinition: [
13
+ freshdesk,
14
+ "categoryId",
15
+ ],
16
+ },
17
+ folderId: {
18
+ propDefinition: [
19
+ freshdesk,
20
+ "folderId",
21
+ (c) => ({
22
+ categoryId: c.categoryId,
23
+ }),
24
+ ],
25
+ },
26
+ maxResults: {
27
+ propDefinition: [
28
+ freshdesk,
29
+ "maxResults",
30
+ ],
31
+ },
32
+ },
33
+ async run({ $ }) {
34
+ const results = await this.freshdesk.getPaginatedResources({
35
+ fn: this.freshdesk.listFolderArticles,
36
+ args: {
37
+ $,
38
+ folderId: this.folderId,
39
+ },
40
+ max: this.maxResults,
41
+ });
42
+ $.export("$summary", `Successfully listed ${results.length} solution article${results.length === 1
43
+ ? ""
44
+ : "s"}`);
45
+ return results;
46
+ },
47
+ };
@@ -0,0 +1,21 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "freshdesk-list-solution-categories",
5
+ name: "List Solution Categories",
6
+ description: "List solution categories in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_category_attributes)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ freshdesk,
11
+ },
12
+ async run({ $ }) {
13
+ const response = await this.freshdesk.listSolutionCategories({
14
+ $,
15
+ });
16
+ $.export("$summary", `Successfully listed ${response.length} solution category${response.length === 1
17
+ ? ""
18
+ : "s"}`);
19
+ return response;
20
+ },
21
+ };
@@ -0,0 +1,32 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "freshdesk-list-ticket-fields",
5
+ name: "List Ticket Fields",
6
+ description: "List all ticket fields in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#list_all_ticket_fields)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ freshdesk,
11
+ maxResults: {
12
+ propDefinition: [
13
+ freshdesk,
14
+ "maxResults",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const results = await this.freshdesk.getPaginatedResources({
20
+ fn: this.freshdesk.listTicketFields,
21
+ args: {
22
+ $,
23
+ },
24
+ max: this.maxResults,
25
+ });
26
+
27
+ $.export("$summary", `Successfully listed ${results.length} ticket field${results.length === 1
28
+ ? ""
29
+ : "s"}`);
30
+ return results;
31
+ },
32
+ };
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Remove Ticket Tags",
7
7
  description: "Remove specific tags from a ticket. [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
8
8
  type: "action",
9
- version: "0.0.1",
9
+ version: "0.0.3",
10
10
  props: {
11
11
  freshdesk,
12
12
  ticketId: {
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-set-ticket-priority",
5
5
  name: "Set Ticket Priority",
6
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",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "freshdesk-set-ticket-status",
5
5
  name: "Set Ticket Status",
6
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",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  freshdesk,
@@ -6,7 +6,7 @@ export default {
6
6
  name: "Set Ticket Tags",
7
7
  description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developers.freshdesk.com/api/#update_ticket)",
8
8
  type: "action",
9
- version: "0.0.1",
9
+ version: "0.0.3",
10
10
  props: {
11
11
  freshdesk,
12
12
  ticketId: {
@@ -0,0 +1,112 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ key: "freshdesk-update-agent",
6
+ name: "Update Agent",
7
+ description: "Update an agent in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#update_agent)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ freshdesk,
12
+ agentId: {
13
+ propDefinition: [
14
+ freshdesk,
15
+ "agentId",
16
+ ],
17
+ },
18
+ email: {
19
+ type: "string",
20
+ label: "Email",
21
+ description: "Email address of the Agent.",
22
+ optional: true,
23
+ },
24
+ ticketScope: {
25
+ type: "integer",
26
+ label: "Ticket Scope",
27
+ description: "Ticket permission of the agent. Current logged in agent can't update his/her ticket_scope",
28
+ options: constants.TICKET_SCOPE,
29
+ optional: true,
30
+ },
31
+ occasional: {
32
+ type: "boolean",
33
+ label: "Occasional",
34
+ description: "Set to true if this is an occasional agent (true => occasional, false => full-time)",
35
+ optional: true,
36
+ },
37
+ signature: {
38
+ type: "string",
39
+ label: "Signature",
40
+ description: "Signature of the agent in HTML format",
41
+ optional: true,
42
+ },
43
+ skillIds: {
44
+ propDefinition: [
45
+ freshdesk,
46
+ "skillIds",
47
+ ],
48
+ },
49
+ groupIds: {
50
+ propDefinition: [
51
+ freshdesk,
52
+ "groupId",
53
+ ],
54
+ type: "string[]",
55
+ label: "Group IDs",
56
+ description: "Array of group IDs",
57
+ optional: true,
58
+ },
59
+ roleIds: {
60
+ propDefinition: [
61
+ freshdesk,
62
+ "roleIds",
63
+ ],
64
+ },
65
+ agentType: {
66
+ type: "integer",
67
+ label: "Agent Type",
68
+ description: "Type of the agent",
69
+ options: constants.AGENT_TYPE,
70
+ optional: true,
71
+ },
72
+ language: {
73
+ type: "string",
74
+ label: "Language",
75
+ description: " Language of the Agent. Default language is `en`",
76
+ optional: true,
77
+ },
78
+ timeZone: {
79
+ type: "string",
80
+ label: "Time Zone",
81
+ description: "Time zone of the agent. Default value is time zone of the domain.",
82
+ optional: true,
83
+ },
84
+ focusMode: {
85
+ type: "boolean",
86
+ label: "Focus Mode",
87
+ description: "Focus mode of the agent. Default value is `true`",
88
+ optional: true,
89
+ },
90
+ },
91
+ async run({ $ }) {
92
+ const response = await this.freshdesk.updateAgent({
93
+ $,
94
+ agentId: this.agentId,
95
+ data: {
96
+ email: this.email,
97
+ ticket_scope: this.ticketScope,
98
+ occasional: this.occasional,
99
+ signature: this.signature,
100
+ skill_ids: this.skillIds,
101
+ group_ids: this.groupIds,
102
+ role_ids: this.roleIds,
103
+ agent_type: this.agentType,
104
+ language: this.language,
105
+ time_zone: this.timeZone,
106
+ focus_mode: this.focusMode,
107
+ },
108
+ });
109
+ $.export("$summary", `Agent ${this.email} updated successfully`);
110
+ return response;
111
+ },
112
+ };
@@ -0,0 +1,64 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+
3
+ export default {
4
+ key: "freshdesk-update-contact",
5
+ name: "Update Contact",
6
+ description: "Update a contact in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#update_contact)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ freshdesk,
11
+ contactId: {
12
+ propDefinition: [
13
+ freshdesk,
14
+ "contactId",
15
+ ],
16
+ },
17
+ name: {
18
+ type: "string",
19
+ label: "Name",
20
+ description: "Name of the contact.",
21
+ optional: true,
22
+ },
23
+ email: {
24
+ type: "string",
25
+ label: "Email Address",
26
+ description: "Primary email address of the contact",
27
+ optional: true,
28
+ },
29
+ otherEmails: {
30
+ type: "string[]",
31
+ label: "Additional Email Addresses",
32
+ description: "One or more additional email addresses for the contact",
33
+ optional: true,
34
+ },
35
+ phone: {
36
+ type: "string",
37
+ label: "Phone Number",
38
+ description: "Phone number of the contact",
39
+ optional: true,
40
+ },
41
+ companyId: {
42
+ propDefinition: [
43
+ freshdesk,
44
+ "companyId",
45
+ ],
46
+ optional: true,
47
+ },
48
+ },
49
+ async run({ $ }) {
50
+ const response = await this.freshdesk.updateContact({
51
+ $,
52
+ contactId: this.contactId,
53
+ data: {
54
+ name: this.name,
55
+ email: this.email,
56
+ other_emails: this.otherEmails,
57
+ phone: this.phone,
58
+ company_id: this.companyId,
59
+ },
60
+ });
61
+ $.export("$summary", `Contact successfully updated: ${response.name}`);
62
+ return response;
63
+ },
64
+ };
@@ -0,0 +1,84 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+ import { parseObject } from "../../common/utils.mjs";
4
+
5
+ export default {
6
+ key: "freshdesk-update-solution-article",
7
+ name: "Update Solution Article",
8
+ description: "Update a solution article in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_article_attributes)",
9
+ version: "0.0.1",
10
+ type: "action",
11
+ props: {
12
+ freshdesk,
13
+ categoryId: {
14
+ propDefinition: [
15
+ freshdesk,
16
+ "categoryId",
17
+ ],
18
+ },
19
+ folderId: {
20
+ propDefinition: [
21
+ freshdesk,
22
+ "folderId",
23
+ (c) => ({
24
+ categoryId: c.categoryId,
25
+ }),
26
+ ],
27
+ },
28
+ articleId: {
29
+ propDefinition: [
30
+ freshdesk,
31
+ "articleId",
32
+ (c) => ({
33
+ folderId: c.folderId,
34
+ }),
35
+ ],
36
+ },
37
+ title: {
38
+ type: "string",
39
+ label: "Title",
40
+ description: "Title of the article",
41
+ optional: true,
42
+ },
43
+ description: {
44
+ type: "string",
45
+ label: "Description",
46
+ description: "Description of the article",
47
+ optional: true,
48
+ },
49
+ status: {
50
+ type: "integer",
51
+ label: "Status",
52
+ description: "Status of the article",
53
+ options: constants.ARTICLE_STATUS,
54
+ optional: true,
55
+ },
56
+ seoData: {
57
+ type: "object",
58
+ label: "SEO Data",
59
+ description: "Meta data for search engine optimization. Allows meta_title, meta_description and meta_keywords",
60
+ optional: true,
61
+ },
62
+ tags: {
63
+ type: "string[]",
64
+ label: "Tags",
65
+ description: "Tags for the article",
66
+ optional: true,
67
+ },
68
+ },
69
+ async run({ $ }) {
70
+ const response = await this.freshdesk.updateArticle({
71
+ $,
72
+ articleId: this.articleId,
73
+ data: {
74
+ title: this.title,
75
+ description: this.description,
76
+ status: this.status,
77
+ seo_data: parseObject(this.seoData),
78
+ tags: this.tags,
79
+ },
80
+ });
81
+ $.export("$summary", `Successfully updated solution article ${this.title}`);
82
+ return response;
83
+ },
84
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "freshdesk-update-ticket",
6
6
  name: "Update a Ticket",
7
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",
8
+ version: "0.0.4",
9
9
  type: "action",
10
10
  props: {
11
11
  freshdesk,
@@ -100,7 +100,7 @@ export default {
100
100
 
101
101
  const data = removeNullEntries(fields);
102
102
 
103
- const ticketName = await freshdesk.getTicketName(ticketId);
103
+ const ticketName = await freshdesk.getTicketName(ticketId) || "Unknown Ticket";
104
104
 
105
105
  if (!Object.keys(data).length) {
106
106
  throw new Error("Please provide at least one field to update.");
@@ -119,4 +119,3 @@ export default {
119
119
  return response;
120
120
  },
121
121
  };
122
-
@@ -0,0 +1,106 @@
1
+ import freshdesk from "../../freshdesk.app.mjs";
2
+ import { parseObject } from "../../common/utils.mjs";
3
+
4
+ export default {
5
+ key: "freshdesk-update-ticket-field",
6
+ name: "Update Ticket Field",
7
+ description: "Update a ticket field in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#update_ticket_field)",
8
+ version: "0.0.1",
9
+ type: "action",
10
+ props: {
11
+ freshdesk,
12
+ ticketFieldId: {
13
+ propDefinition: [
14
+ freshdesk,
15
+ "ticketFieldId",
16
+ ],
17
+ },
18
+ label: {
19
+ type: "string",
20
+ label: "Label",
21
+ description: "Display the name of the Ticket Field",
22
+ optional: true,
23
+ },
24
+ labelForCustomers: {
25
+ type: "string",
26
+ label: "Label for Customers",
27
+ description: "The label for the field as seen by customers",
28
+ optional: true,
29
+ },
30
+ customersCanEdit: {
31
+ type: "boolean",
32
+ label: "Customers Can Edit",
33
+ description: "Whether customers can edit the field",
34
+ optional: true,
35
+ },
36
+ displayedToCustomers: {
37
+ type: "boolean",
38
+ label: "Displayed to Customers",
39
+ description: "Whether the field is displayed to customers",
40
+ optional: true,
41
+ },
42
+ position: {
43
+ type: "integer",
44
+ label: "Position",
45
+ description: "The position of the fieldPosition in which the ticket field is displayed in the form. If not given, it will be displayed on top",
46
+ optional: true,
47
+ },
48
+ requiredForClosure: {
49
+ type: "boolean",
50
+ label: "Required for Closure",
51
+ description: "Set to `true` if the field is mandatory for closing the ticket",
52
+ optional: true,
53
+ },
54
+ requiredForAgents: {
55
+ type: "boolean",
56
+ label: "Required for Agents",
57
+ description: "Set to `true` if the field is mandatory for agents",
58
+ optional: true,
59
+ },
60
+ requiredForCustomers: {
61
+ type: "boolean",
62
+ label: "Required for Customers",
63
+ description: "Set to `true` if the field is mandatory for customers",
64
+ optional: true,
65
+ },
66
+ choices: {
67
+ type: "string[]",
68
+ label: "Choices",
69
+ description: "Array of key, value pairs containing the value and position of dropdown choices. Example: `[{ \"value\": \"Refund\", \"position\": 1 }, { \"value\": \"FaultyProduct\", \"position\": 2 }]`",
70
+ optional: true,
71
+ },
72
+ dependentFields: {
73
+ type: "string[]",
74
+ label: "Dependent Fields",
75
+ description: "Applicable only for dependent fields, this contains details of nested fields Example: `[{ \"label\": \"District\", \"label_for_customers\": \"District\", \"level\": 2 }, { \"label\": \"Branch\", \"label_for_customers\": \"Branch\", \"level\": 3 }]`",
76
+ optional: true,
77
+ },
78
+ sectionMappings: {
79
+ type: "string[]",
80
+ label: "Section Mappings",
81
+ description: "Applicable only if the field is part of a section. This contains the details of a section (ID, position) for which it is been a part of. Example: `[{ \"position\": 3, \"section_id\": 1 }]`",
82
+ optional: true,
83
+ },
84
+ },
85
+ async run({ $ }) {
86
+ const response = await this.freshdesk.updateTicketField({
87
+ $,
88
+ ticketFieldId: this.ticketFieldId,
89
+ data: {
90
+ label: this.label,
91
+ label_for_customers: this.labelForCustomers,
92
+ customers_can_edit: this.customersCanEdit,
93
+ displayed_to_customers: this.displayedToCustomers,
94
+ position: this.position,
95
+ required_for_closure: this.requiredForClosure,
96
+ required_for_agents: this.requiredForAgents,
97
+ required_for_customers: this.requiredForCustomers,
98
+ choices: parseObject(this.choices),
99
+ dependent_fields: parseObject(this.dependentFields),
100
+ section_mappings: parseObject(this.sectionMappings),
101
+ },
102
+ });
103
+ $.export("$summary", `Successfully updated ticket field: ${response.label}`);
104
+ return response;
105
+ },
106
+ };
@@ -37,4 +37,42 @@ export default {
37
37
  value: 4,
38
38
  },
39
39
  ],
40
+ TICKET_SCOPE: [
41
+ {
42
+ label: "Global Access",
43
+ value: 1,
44
+ },
45
+ {
46
+ label: "Group Access",
47
+ value: 2,
48
+ },
49
+ {
50
+ label: "Restricted Access",
51
+ value: 3,
52
+ },
53
+ ],
54
+ AGENT_TYPE: [
55
+ {
56
+ label: "Support Agent",
57
+ value: 1,
58
+ },
59
+ {
60
+ label: "Field Agent",
61
+ value: 2,
62
+ },
63
+ {
64
+ label: "Collaborator",
65
+ value: 3,
66
+ },
67
+ ],
68
+ ARTICLE_STATUS: [
69
+ {
70
+ label: "Draft",
71
+ value: 1,
72
+ },
73
+ {
74
+ label: "Published",
75
+ value: 2,
76
+ },
77
+ ],
40
78
  };
package/common/utils.mjs CHANGED
@@ -22,6 +22,33 @@ const removeNullEntries = (obj) =>
22
22
  : acc;
23
23
  }, {});
24
24
 
25
+ const parseObject = (obj) => {
26
+ if (!obj) {
27
+ return undefined;
28
+ }
29
+ if (typeof obj === "string") {
30
+ try {
31
+ return JSON.parse(obj);
32
+ } catch (e) {
33
+ return obj;
34
+ }
35
+ }
36
+ if (Array.isArray(obj)) {
37
+ return obj.map(parseObject);
38
+ }
39
+ if (typeof obj === "object") {
40
+ return Object.fromEntries(Object.entries(obj).map(([
41
+ key,
42
+ value,
43
+ ]) => [
44
+ key,
45
+ parseObject(value),
46
+ ]));
47
+ }
48
+ return obj;
49
+ };
50
+
25
51
  export {
26
52
  removeNullEntries,
53
+ parseObject,
27
54
  };