Skip to content

Add Zendesk Help Center article search and retrieval actions #16978

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
79 changes: 79 additions & 0 deletions components/zendesk/actions/get-article/get-article.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-get-article",
name: "Get Article",
description: "Retrieves the full content and metadata of a specific help center article by ID. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#show-article).",
type: "action",
version: "0.1.0",
props: {
app,
articleId: {
type: "integer",
label: "Article ID",
description: "The unique ID of the article to retrieve",
},
locale: {
type: "string",
label: "Locale",
description: "The locale for the article (e.g., 'en-us')",
default: "en-us",
optional: true,
},
includeTranslations: {
type: "boolean",
label: "Include Translations",
description: "Whether to include article translations in the response",
default: false,
optional: true,
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
methods: {
getArticle(args = {}) {
const {
articleId,
customSubdomain,
params,
...otherArgs
} = args;

Check failure on line 45 in components/zendesk/actions/get-article/get-article.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
return this.app.makeRequest({
path: `/help_center/articles/${articleId}`,
customSubdomain,
params,
...otherArgs,
});
},
},
async run({ $: step }) {
const {
articleId,
locale,

Check failure on line 57 in components/zendesk/actions/get-article/get-article.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'locale' is assigned a value but never used
includeTranslations,
customSubdomain,
} = this;

const params = {};

Check failure on line 63 in components/zendesk/actions/get-article/get-article.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
if (includeTranslations) {
params.include = "translations";
}
Comment on lines +55 to +66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing locale parameter in API request.

The locale parameter is extracted but never added to the params object, following the same pattern as the other actions.

Apply this diff to include the locale parameter:

 const params = {};
 
+if (locale) {
+  params.locale = locale;
+}
 if (includeTranslations) {
   params.include = "translations";
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const {
articleId,
locale,
includeTranslations,
customSubdomain,
} = this;
const params = {};
if (includeTranslations) {
params.include = "translations";
}
const {
articleId,
locale,
includeTranslations,
customSubdomain,
} = this;
const params = {};
if (locale) {
params.locale = locale;
}
if (includeTranslations) {
params.include = "translations";
}
🤖 Prompt for AI Agents
In components/zendesk/actions/get-article/get-article.mjs around lines 55 to 66,
the locale parameter is extracted but not added to the params object for the API
request. To fix this, add a line to include locale in the params object, similar
to how includeTranslations is handled, ensuring the locale is passed correctly
in the API call.


const response = await this.getArticle({
step,
articleId,
customSubdomain,
params,
});

step.export("$summary", `Successfully retrieved article: "${response.article?.title || 'Unknown'}"`);

Check failure on line 75 in components/zendesk/actions/get-article/get-article.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Strings must use doublequote
return response;
},
};
// This code defines a Zendesk action to retrieve a specific help center article by its ID.

Check failure on line 79 in components/zendesk/actions/get-article/get-article.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Newline required at end of file but not found
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-list-articles-in-section",
name: "List Articles in Section",
description: "Lists all articles within a specific help center section. Useful after identifying relevant sections. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#list-articles).",
type: "action",
version: "0.1.0",
props: {
app,
sectionId: {
type: "integer",
label: "Section ID",
description: "The unique ID of the section to list articles from",
},
locale: {
type: "string",
label: "Locale",
description: "The locale for the articles (e.g., 'en-us')",
default: "en-us",
optional: true,
},
sortBy: {
type: "string",
label: "Sort By",
description: "Sort articles by specified field",
options: [
"position",
"title",
"created_at",
"updated_at",
"edited_at",
],
default: "position",
optional: true,
},
sortOrder: {
type: "string",
label: "Sort Order",
description: "Order of the results",
options: [
"asc",
"desc",
],
default: "asc",
optional: true,
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
methods: {
listArticlesInSection(args = {}) {
const {
sectionId,
customSubdomain,
params,
...otherArgs
} = args;

Check failure on line 63 in components/zendesk/actions/list-articles-in-section/list-articles-in-section.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
return this.app.makeRequest({
path: `/help_center/sections/${sectionId}/articles`,
customSubdomain,
params,
...otherArgs,
});
},
},
async run({ $: step }) {
const {
sectionId,
locale,

Check failure on line 75 in components/zendesk/actions/list-articles-in-section/list-articles-in-section.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'locale' is assigned a value but never used
sortBy,
sortOrder,
customSubdomain,
} = this;

const params = {};

Check failure on line 82 in components/zendesk/actions/list-articles-in-section/list-articles-in-section.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
Comment on lines +75 to +88
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing locale parameter in API request.

The locale parameter is extracted from props but never added to the params object. This means the locale setting will be ignored in the API request.

Apply this diff to include the locale parameter:

 const params = {};
 
+if (locale) {
+  params.locale = locale;
+}
 if (sortBy) {
   params.sort_by = sortBy;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
locale,
sortBy,
sortOrder,
customSubdomain,
} = this;
const params = {};
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
locale,
sortBy,
sortOrder,
customSubdomain,
} = this;
const params = {};
if (locale) {
params.locale = locale;
}
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
🤖 Prompt for AI Agents
In
components/zendesk/actions/list-articles-in-section/list-articles-in-section.mjs
around lines 75 to 88, the locale parameter is extracted but not added to the
params object, causing it to be omitted from the API request. To fix this, add a
condition to check if locale exists and then assign it to params.locale so the
API request includes the locale setting properly.


const response = await this.listArticlesInSection({
step,
sectionId,
customSubdomain,
params,
});

step.export("$summary", `Successfully retrieved ${response.articles?.length || 0} articles from section ${sectionId}`);
return response;
},
};

Check failure on line 100 in components/zendesk/actions/list-articles-in-section/list-articles-in-section.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Newline required at end of file but not found
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-list-help-center-sections",
name: "List Help Center Sections",
description: "Lists all sections in the help center to understand content organization. Useful for browsing articles by topic area. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/sections/#list-sections).",
type: "action",
version: "0.1.0",
props: {
app,
locale: {
type: "string",
label: "Locale",
description: "The locale for the sections (e.g., 'en-us')",
default: "en-us",
optional: true,
},
sortBy: {
type: "string",
label: "Sort By",
description: "Sort sections by specified field",
options: [
"position",
"name",
"created_at",
"updated_at",
],
default: "position",
optional: true,
},
sortOrder: {
type: "string",
label: "Sort Order",
description: "Order of the results",
options: [
"asc",
"desc",
],
default: "asc",
optional: true,
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
methods: {
listSections(args = {}) {
const {
customSubdomain,
params,
...otherArgs
} = args;

Check failure on line 56 in components/zendesk/actions/list-help-center-sections/list-help-center-sections.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Trailing spaces not allowed
return this.app.makeRequest({
path: `/help_center/sections`,
customSubdomain,
params,
...otherArgs,
});
},
},
async run({ $: step }) {
const {
locale,
sortBy,
sortOrder,
customSubdomain,
} = this;

const params = {};

if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
Comment on lines +67 to +80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing locale parameter in API request.

Same issue as in the articles listing action - the locale parameter is extracted but never added to the params object.

Apply this diff to include the locale parameter:

 const params = {};
 
+if (locale) {
+  params.locale = locale;
+}
 if (sortBy) {
   params.sort_by = sortBy;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
locale,
sortBy,
sortOrder,
customSubdomain,
} = this;
const params = {};
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
locale,
sortBy,
sortOrder,
customSubdomain,
} = this;
const params = {};
if (locale) {
params.locale = locale;
}
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
🤖 Prompt for AI Agents
In
components/zendesk/actions/list-help-center-sections/list-help-center-sections.mjs
around lines 67 to 80, the locale parameter is extracted but not added to the
params object sent in the API request. To fix this, add a condition to check if
locale is defined and then assign it to params.locale so that the API request
includes the locale parameter properly.


const response = await this.listSections({
step,
customSubdomain,
params,
});

step.export("$summary", `Successfully retrieved ${response.sections?.length || 0} help center sections`);
return response;
},
};
110 changes: 110 additions & 0 deletions components/zendesk/actions/search-articles/search-articles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-search-articles",
name: "Search Articles",
description: "Searches for help center knowledge base articles using Zendesk's Help Center API. Can search by keywords, filter by labels, and sort results. [See the documentation](https://developer.zendesk.com/api-reference/help_center/help-center-api/articles/#list-articles).",
type: "action",
version: "0.1.0",
props: {
app,
searchQuery: {
type: "string",
label: "Search Query",
description: "Keywords to search for in article titles and content",
optional: true,
},
labelNames: {
type: "string",
label: "Label Names",
description: "Comma-separated list of label names to filter by (e.g., 'photos,camera')",
optional: true,
},
sortBy: {
type: "string",
label: "Sort By",
description: "Sort articles by specified field",
options: [
"position",
"title",
"created_at",
"updated_at",
"edited_at",
],
default: "position",
optional: true,
},
sortOrder: {
type: "string",
label: "Sort Order",
description: "Order of the results",
options: [
"asc",
"desc",
],
default: "asc",
optional: true,
},
locale: {
type: "string",
label: "Locale",
description: "The locale for the articles (e.g., 'en-us')",
default: "en-us",
optional: true,
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
methods: {
searchArticles(args = {}) {
const {
customSubdomain,
params,
...otherArgs
} = args;

return this.app.makeRequest({
path: `/help_center/articles`,
customSubdomain,
params,
...otherArgs,
});
},
},
async run({ $: step }) {
const {
searchQuery,
labelNames,
sortBy,
sortOrder,
locale,
customSubdomain,
} = this;

const params = {};

if (labelNames) {
params.label_names = labelNames;
}
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
Comment on lines +79 to +98
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing search query and locale parameters.

Two critical parameters are missing from the API request:

  1. searchQuery - the main search functionality is not implemented
  2. locale - extracted but not used

Apply this diff to include both parameters:

 const params = {};
 
+if (searchQuery) {
+  params.query = searchQuery;
+}
 if (labelNames) {
   params.label_names = labelNames;
 }
+if (locale) {
+  params.locale = locale;
+}
 if (sortBy) {
   params.sort_by = sortBy;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const {
searchQuery,
labelNames,
sortBy,
sortOrder,
locale,
customSubdomain,
} = this;
const params = {};
if (labelNames) {
params.label_names = labelNames;
}
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
const {
searchQuery,
labelNames,
sortBy,
sortOrder,
locale,
customSubdomain,
} = this;
const params = {};
if (searchQuery) {
params.query = searchQuery;
}
if (labelNames) {
params.label_names = labelNames;
}
if (locale) {
params.locale = locale;
}
if (sortBy) {
params.sort_by = sortBy;
}
if (sortOrder) {
params.sort_order = sortOrder;
}
🤖 Prompt for AI Agents
In components/zendesk/actions/search-articles/search-articles.mjs around lines
79 to 98, the API request parameters object is missing the critical searchQuery
and locale parameters. To fix this, add searchQuery as a parameter named 'query'
and locale as 'locale' to the params object, ensuring both are included in the
API request payload to enable proper search functionality and locale filtering.


const response = await this.searchArticles({
step,
customSubdomain,
params,
});

step.export("$summary", `Successfully found ${response.articles?.length || 0} articles`);
return response;
},
};
// This code defines a Pipedream action that allows users to search for articles in Zendesk's Help Center.
Loading