Skip to content

Commit 17ae289

Browse files
committed
Zoho Desk - new help center actions
1 parent 4c1a754 commit 17ae289

File tree

8 files changed

+517
-1
lines changed

8 files changed

+517
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import zohoDesk from "../../zoho_desk.app.mjs";
2+
3+
export default {
4+
key: "zoho_desk-get-article",
5+
name: "Get Article",
6+
description: "Retrieves the details of a knowledge base article. [See the docs here](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase_Getarticle)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
zohoDesk,
16+
orgId: {
17+
propDefinition: [
18+
zohoDesk,
19+
"orgId",
20+
],
21+
},
22+
portalId: {
23+
propDefinition: [
24+
zohoDesk,
25+
"portalId",
26+
({ orgId }) => ({
27+
orgId,
28+
}),
29+
],
30+
},
31+
articleId: {
32+
propDefinition: [
33+
zohoDesk,
34+
"articleId",
35+
],
36+
},
37+
},
38+
async run({ $ }) {
39+
const {
40+
portalId,
41+
articleId,
42+
} = this;
43+
44+
const article = await this.zohoDesk.getKnowledgeBaseArticle({
45+
articleId,
46+
params: {
47+
portalId,
48+
},
49+
});
50+
51+
$.export("$summary", `Fetched article ${article.title || articleId}.`);
52+
53+
return article;
54+
},
55+
};
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import zohoDesk from "../../zoho_desk.app.mjs";
2+
3+
export default {
4+
key: "zoho_desk-list-articles",
5+
name: "List Articles",
6+
description: "Lists knowledge base articles for a help center. [See the docs here](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase#KnowledgeBase_Listarticles)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
zohoDesk,
16+
orgId: {
17+
propDefinition: [
18+
zohoDesk,
19+
"orgId",
20+
],
21+
},
22+
portalId: {
23+
propDefinition: [
24+
zohoDesk,
25+
"portalId",
26+
({ orgId }) => ({
27+
orgId,
28+
}),
29+
],
30+
},
31+
categoryId: {
32+
type: "string",
33+
label: "Category ID",
34+
description: "Filter by the ID(s) of the categories the articles belong to. Use comma-separated IDs to include multiple categories.",
35+
optional: true,
36+
},
37+
sortBy: {
38+
type: "string",
39+
label: "Sort By",
40+
description: "Sort articles by the specified attribute.",
41+
optional: true,
42+
options: [
43+
"createdTime",
44+
"modifiedTime",
45+
"likeCount",
46+
"viewCount",
47+
"unlikeCount",
48+
],
49+
default: "createdTime",
50+
},
51+
tag: {
52+
type: "string",
53+
label: "Tag",
54+
description: "Filter articles by a tag.",
55+
optional: true,
56+
},
57+
maxResults: {
58+
type: "integer",
59+
label: "Max Results",
60+
description: "Maximum number of articles to return. Leave blank to return all available results.",
61+
optional: true,
62+
},
63+
},
64+
async run({ $ }) {
65+
const {
66+
portalId,
67+
categoryId,
68+
sortBy,
69+
tag,
70+
maxResults,
71+
} = this;
72+
73+
const params = {
74+
portalId,
75+
categoryId,
76+
sortBy,
77+
tag,
78+
};
79+
80+
const articles = [];
81+
const stream = this.zohoDesk.listKnowledgeBaseArticlesStream({
82+
params,
83+
});
84+
for await (const article of stream) {
85+
articles.push(article);
86+
if (maxResults && articles.length >= maxResults) {
87+
break;
88+
}
89+
}
90+
91+
$.export("$summary", `Retrieved ${articles.length} article${articles.length === 1
92+
? ""
93+
: "s"}.`);
94+
95+
return articles;
96+
},
97+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import zohoDesk from "../../zoho_desk.app.mjs";
2+
3+
export default {
4+
key: "zoho_desk-list-help-centers",
5+
name: "List Help Centers",
6+
description: "Lists the help centers configured in an organization. [See the docs here](https://desk.zoho.com/portal/APIDocument.do#HelpCenters_Listhelpcenters)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
zohoDesk,
16+
orgId: {
17+
propDefinition: [
18+
zohoDesk,
19+
"orgId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const { orgId } = this;
25+
26+
const { data: helpCenters = [] } =
27+
await this.zohoDesk.listHelpCenters({
28+
params: {
29+
orgId,
30+
},
31+
});
32+
33+
$.export("$summary", `Retrieved ${helpCenters.length} help center${helpCenters.length === 1
34+
? ""
35+
: "s"}.`);
36+
37+
return helpCenters;
38+
},
39+
};
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import zohoDesk from "../../zoho_desk.app.mjs";
2+
3+
export default {
4+
key: "zoho_desk-list-root-categories",
5+
name: "List Root Categories",
6+
description: "Lists root knowledge base categories for a help center. [See the docs here](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase_Listallrootcategoriesofthehelpcenter)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
zohoDesk,
16+
orgId: {
17+
propDefinition: [
18+
zohoDesk,
19+
"orgId",
20+
],
21+
},
22+
portalId: {
23+
propDefinition: [
24+
zohoDesk,
25+
"portalId",
26+
({ orgId }) => ({
27+
orgId,
28+
}),
29+
],
30+
},
31+
sortBy: {
32+
type: "string",
33+
label: "Sort By",
34+
description: "Sort the categories by the specified attribute.",
35+
optional: true,
36+
options: [
37+
"name",
38+
"order",
39+
],
40+
},
41+
searchValue: {
42+
type: "string",
43+
label: "Search Value",
44+
description: "Filter categories whose names match the provided value.",
45+
optional: true,
46+
},
47+
visibility: {
48+
type: "string",
49+
label: "Visibility",
50+
description: "Filter categories by visibility (e.g. ALL_USERS).",
51+
optional: true,
52+
},
53+
departmentId: {
54+
type: "string",
55+
label: "Department ID",
56+
description: "Filter categories associated with the specified department.",
57+
optional: true,
58+
},
59+
hasArticles: {
60+
type: "boolean",
61+
label: "Has Articles",
62+
description: "Return only categories that contain articles when set to `true`.",
63+
optional: true,
64+
},
65+
maxResults: {
66+
type: "integer",
67+
label: "Max Results",
68+
description: "Maximum number of categories to return. Leave blank to return all available results.",
69+
optional: true,
70+
},
71+
},
72+
async run({ $ }) {
73+
const {
74+
portalId,
75+
sortBy,
76+
searchValue,
77+
visibility,
78+
departmentId,
79+
hasArticles,
80+
maxResults,
81+
} = this;
82+
83+
const params = {
84+
portalId,
85+
sortBy,
86+
searchValue,
87+
visibility,
88+
departmentId,
89+
hasArticles,
90+
};
91+
92+
const categories = [];
93+
const stream = this.zohoDesk.listKnowledgeBaseRootCategoriesStream({
94+
params,
95+
});
96+
for await (const category of stream) {
97+
categories.push(category);
98+
if (maxResults && categories.length >= maxResults) {
99+
break;
100+
}
101+
}
102+
103+
$.export("$summary", `Retrieved ${categories.length} root categor${categories.length === 1
104+
? "y"
105+
: "ies"}.`);
106+
107+
return categories;
108+
},
109+
};

0 commit comments

Comments
 (0)