KnowledgeService plugin
Note: Please subscribe to ready event before calling any KnowledgeService plugin commands.
When KnowledgeService plugin is ready to accept commands, it will publish ready event. It's recommended to subscribe to this event before calling any commands in this plugin. If the ready event is already published before you subscribe to it, it will simply republish again ensuring your callback function gets executed.
Here is an example of the KnowledgeService.getSuggestions command being invoked once the KnowledgeService plugin has been initialized.
Genesys('subscribe', 'KnowledgeService.ready', () => {
Genesys(
'command',
'KnowledgeService.getSuggestions',
{
pageSize: 3,
query: 'Genesys',
},
(data) => {
/*fulfilled callback*/
data ? console.log(data) : null;
console.log('Suggestions returned successfully');
},
(error) => {
/*rejected callback*/
error ? console.log(error) : null;
console.log('Error returning suggestions');
}
);
});
KnowledgeService plugin commands
KnowledgeService.search
Invokes the Search API to perform request to return search result data.
Resolutions:
Name | Description | Return | Event published |
resolved | When the Search api returns the result. | Search result object. | If there is result:KnowledgeService.searchResults with the search result object. If there is no result:KnowledgeService.noSearchResultsFound |
rejected | When there is an error during the API call. | Error object | KnowledgeService.error with the error object |
Genesys("command", "KnowledgeService.search",
{
"pageSize": 3,
"query": "how",
"queryType": "ManualSearch"
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
query | string | Query to search content in the knowledge base. | required |
pageSize | integer | Page size of the returned results. | optional |
queryType | string | The type of the query that initiates the search. Valid Values: | optional |
ManualSearch - If the search triggered by manual user action | \ | ||
Suggestion - If the search triggered by auto-complete suggestion | \ | ||
AutoSearch - If the search triggered by automation |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"searchId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": [
{
"confidence": 0.2098388671875,
"document": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "How to request new channels?",
"alternatives": [],
"state": "Published",
"dateCreated": "2022-04-14T10:20:23.613Z",
"dateModified": "2022-04-14T10:26:06.968Z",
"documentVersion": {},
"variations": [
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"body": {
"blocks": [
{
"type": "Paragraph",
"paragraph": {
"blocks": [
{
"type": "Text",
"text": {
"text": "How to request new channels?"
}
}
]
}
}
]
},
"dateCreated": "2022-04-14T10:26:06.968Z",
"dateModified": "2022-04-14T10:26:06.993Z",
"documentVersion": {}
}
]
}
}
]
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getSuggestions
Invokes the Suggestions API to perform request to return suggestion result data.
Resolutions:
Name | Description | Return | Event published |
resolved | When the Suggestion api returns the result. | Suggestion result object. | If there is result:KnowledgeService.suggestions with the suggestion result object. If there is no result:KnowledgeService.noSuggestionsFound |
rejected | When there is an error during the API call. | Error object | KnowledgeService.error with the error object |
Genesys("command", "KnowledgeService.getSuggestions",
{
"pageSize": 3,
"query": "how"
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
query | string | Query to get autocomplete suggestions for the matching knowledge documents. | required |
pageSize | integer | Page size of the returned results. | optional |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": [
{
"matchedPhrase": "How many devices can I simultaneously watch on?"
},
{
"matchedPhrase": "How to request new shows?"
},
{
"matchedPhrase": "How to request new channels?"
}
]
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getCategories
Invokes the Category API to perform request to return category result data.
Resolutions:
Name | Description | Return | Event published |
resolved | When the Category api returns the result. | Category result object. | If there is result:KnowledgeService.categories with the category result object. If there is no result:KnowledgeService.noCategoriesFound |
rejected | When there is an error during the API call. | Error object | KnowledgeService.error with the error object |
Genesys("command", "KnowledgeService.getCategories", {}, (data) => { console.log(data); });
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": [
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"name": "Category 1"
},
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"name": "Category 2",
"parentId": "123abcd4-e567-890f-g123-456h789abc0d"
}
]
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getArticle
Invokes the Article API to perform request to return article result data.
Resolutions:
Name | Description | Return | Event published |
resolved | When the Article api returns the result. | Article result object. | If there is result:KnowledgeService.article with the article result object. If there is no result:KnowledgeService.noArticleFound |
rejected | When there is an error during the API call. | Error object | KnowledgeService.error with the error object |
Genesys("command", "KnowledgeService.getArticle",
{
"articleId": "123abcd4-e567-890f-g123-456h789abc0d",
"searchId": "123abcd4-e567-890f-g123-456h789abc0d",
"queryType": "ManualSearch"
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
articleId | string | The id of the document. | required |
searchId | string | The search that surfaced the document. Register the document as selected answer for analytics purpose. | optional |
queryType | string | The type of the query that surfaced the document. Valid Values: | optional |
Unknown - Default value, if the queryType was not specified | \ | ||
Article - If the opened document was surfaced via direct link | \ | ||
Category - If the opened document was surfaced via category browsing | \ | ||
ManualSearch - If the opened document was surfaced via manual search | \ | ||
Recommendation - If the opened document was surfaced via recommendations/top viewed articles | \ | ||
Suggestion - If the opened document was surfaced via accepted auto-complete suggestion | \ | ||
AutoSearch - If the opened document was surfaced via automation |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "What devices can I watch SportsTube on?",
"visible": true,
"alternatives": [],
"state": "Published",
"dateCreated": "2022-04-14T10:02:47.460Z",
"dateModified": "2022-04-14T10:08:19.806Z",
"createdBy": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"selfUri": "/api/v2/users/123abcd4-e567-890f-g123-456h789abc0d"
},
"modifiedBy": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"selfUri": "/api/v2/users/123abcd4-e567-890f-g123-456h789abc0d"
},
"variations": [
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"body": {
"blocks": [
{
"type": "Paragraph",
"paragraph": {
"blocks": [
{
"type": "Text",
"text": {
"text": "You can watch SportsTube on your computer, iPhone, iPad, Android phone and tablet, Roku, Apple TV, Xbox, Chromecast and Amazon Fire TV."
}
}
]
}
}
]
},
"dateCreated": "2022-04-14T10:08:19.806Z",
"dateModified": "2022-04-14T10:08:19.823Z",
"documentVersion": {
"id": "123abcd4-e567-890f-g123-456h789abc0d"
},
"contexts": [],
"document": {
"id": "123abcd4-e567-890f-g123-456h789abc0d"
}
}
],
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"selfUri": "/api/v2/knowledge/guest/sessions/123abcd4-e567-890f-g123-456h789abc0d/documents/123abcd4-e567-890f-g123-456h789abc0d"
}
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getArticlesByCategory
Get articles belongs to a given category.
Resolutions:
Name | Description | Return | Event published |
resolved | When the documents api returns the result. | Articles result object. | If there is result:KnowledgeService.articlesByCategory with the articles result object. If there is no result:KnowledgeService.noArticlesByCategoryFound |
rejected | When there is an error during the API call. | Error object | KnowledgeService.error with the error object |
Genesys("command", "KnowledgeService.getArticlesByCategory",
{
"categoryId": "123abcd4-e567-890f-g123-456h789abc0d"
}, (data) => { console.log(data); });
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": [
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "Do you screen rugby?"
}
]
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getTopViewedArticles
Get the most viewed articles.
Resolutions:
Name | Description | Return | Event published |
resolved | When the documents api returns the result. | Articles result object. | If there is result: KnowledgeService.topViewedArticles with the articles result object. If there is no result: KnowledgeService.noTopViewedArticlesFound |
rejected | When there is an error during the API call. | Error object. | KnowledgeService.error with the error object. |
Genesys("command", "KnowledgeService.getTopViewedArticles",
{
"pageSize": 3
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
pageSize | integer | Length of the top viewed articles list. Default value: 5. | optional |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": [
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "How to request new channels?"
},
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "Do you screen rugby?"
},
{
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"title": "What devices can I watch SportsTube on?"
}
]
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.sendFeedback
Give feedback on a document.
Resolutions:
Name | Description | Return | Event published |
resolved | When the documents api returns the result. | Feedback result object. | KnowledgeService.feedbackSent with the feedback result object. |
rejected | When there is an error during the API call. | Error object. | KnowledgeService.error with the error object. |
Genesys("command", "KnowledgeService.sendFeedback",
{
"documentId": "123abcd4-e567-890f-g123-456h789abc0d",
"documentVersionId": "123abcd4-e567-890f-g123-456h789abc0d",
"documentVariationId": "123abcd4-e567-890f-g123-456h789abc0d",
"rating": "Positive",
"searchId": "123abcd4-e567-890f-g123-456h789abc0d",
"reason": "SearchResults",
"comment": "My comment",
"queryType": "ManualSearch"
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
documentId | string | The document on which feedback was given. | required |
documentVersionId | string | The version of the document on which feedback was given. | required |
documentVariationId | string | The variation of the document on which feedback was given. | required |
rating | string | Feedback rating. Valid Values: Negative, Positive. | required |
searchId | string | The search that surfaced the document on which feedback was given. | optional |
reason | string | Feedback reason. Valid Values: DocumentContent, SearchResults. | optional |
comment | string | Free-text comment of the feedback. Maximum length: 2000 characters. | optional |
queryType | string | The type of the query that surfaced the document. Valid Values: | optional |
Unknown - Default value, if the queryType was not specified | \ | ||
Article - If the opened document was surfaced via direct link | \ | ||
Category - If the opened document was surfaced via category browsing | \ | ||
ManualSearch - If the opened document was surfaced via manual search | \ | ||
Recommendation - If the opened document was surfaced via recommendations/top viewed articles | \ | ||
Suggestion - If the opened document was surfaced via accepted auto-complete suggestion | \ | ||
AutoSearch - If the opened document was surfaced via automation |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"documentVariation": {
"id": "123abcd4-e567-890f-g123-456h789abc0d"
},
"rating": "Positive",
"reason": "SearchResults",
"comment": "My comment",
"search": {
"id": "123abcd4-e567-890f-g123-456h789abc0d"
},
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"dateCreated": "2022-12-05T13:44:03.447Z",
"document": {
"id": "123abcd4-e567-890f-g123-456h789abc0d",
"versionId": "123abcd4-e567-890f-g123-456h789abc0d"
},
"application": {
"type": "MessengerKnowledgeApp",
"deployment": {
"id": "123abcd4-e567-890f-g123-456h789abc0d"
}
}
}
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService.getSession
Get the current session, or create one if it is not exists.
Resolutions:
Name | Description | Return | Event published |
resolved | When the api returns the result. | Session result object. | None. |
rejected | When there is an error during the API call. | Error object. | KnowledgeService.error with the error object. |
Genesys("command", "KnowledgeService.getSession", {
"appType": "SupportCenter"
}, (data) => { console.log(data); });
Options:
Name | Data type | Description | Status |
appType | string | The type of the app to get the session from. Valid Values: MessengerKnowledgeApp, SupportCenter. Default value: MessengerKnowledgeApp | optional |
Result object:
{
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d",
"deploymentId": "123abcd4-e567-890f-g123-456h789abc0d",
"result": {
"sessionId": "123abcd4-e567-890f-g123-456h789abc0d"
}
}
Error object:
{
"code": "unknown.error",
"message": "Something went wrong. Please try again later."
}
KnowledgeService plugin events
KnowledgeService.ready
Published when the KnowledgeService plugin registered every command.
Genesys("subscribe", "KnowledgeService.ready", () => console.log("KnowledgeService: ready"));
KnowledgeService.error
Published when there is an error during command execution.
Genesys("subscribe", "KnowledgeService.error", (err) => console.log(err));
KnowledgeService.searchResults
Published when the doSearch command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.searchResults", (data) => console.log(data)); // same as search command return value
KnowledgeService.noSearchResultsFound
Published when the doSearch command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noSearchResultsFound", () => console.log("KnowledgeService: no search results found"));
KnowledgeService.suggestions
Published when the getSuggestions command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.suggestions", (data) => console.log(data)); // same as getSuggestions command return value
KnowledgeService.noSuggestionsFound
Published when the getSuggestions command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noSuggestionsFound", () => console.log("KnowledgeService: no suggestions found"));
KnowledgeService.categories
Published when the getCategories command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.categories", (data) => console.log(data)); // same as getCategories command return value
KnowledgeService.noCategoriesFound
Published when the getCategories command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noCategoriesFound", () => console.log("KnowledgeService: no categories found"));
KnowledgeService.article
Published when the getArticle command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.article", (data) => console.log(data)); // same as getArticle command return value
KnowledgeService.noArticleFound
Published when the getArticle command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noArticleFound", () => console.log("KnowledgeService: no article found"));
KnowledgeService.articlesByCategory
Published when the getArticlesByCategory command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.articlesByCategory", (data) => console.log(data)); // same as getArticlesByCategory command return value
KnowledgeService.noArticlesByCategoryFound
Published when the getArticlesByCategory command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noArticlesByCategoryFound", () => console.log("KnowledgeService: no articles by category found"));
KnowledgeService.topViewedArticles
Published when the getTopViewedArticles command finished execution with not empty result set.
Genesys("subscribe", "KnowledgeService.topViewedArticles", (data) => console.log(data)); // same as getTopViewedArticles command return value
KnowledgeService.noTopViewedArticlesFound
Published when the getTopViewedArticles command finished execution with empty result set.
Genesys("subscribe", "KnowledgeService.noTopViewedArticlesFound", () => console.log("KnowledgeService: no top viewed articles found"));
KnowledgeService.feedbackSent
Published when the sendFeedback command finished execution.
Genesys("subscribe", "KnowledgeService.feedbackSent", (data) => console.log(data)); // same as sendFeedback command return value