Contents
API Commands
Once you've registered your own plugin on the bus, you can call commands on other registered plugins. Below we'll quickly register a new plugin on the bus using the global bus object.
var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');
oMyPlugin.command('KnowledgeCenterService.search');
configure
Internal use only. The main App plugin shares configuration settings to widgets using each widget’s configure command. The configure command can only be called once at startup. Calling configure again after startup may result in unpredictable behavior.
Example
oMyPlugin.command('KnowledgeCenterService.configure', {
host: 'http://localhost:8080/foo/bar',
knowledgebases: [ 1, 2, 3, 4, 5 ],
lang: 'eng'
}).done(function(e){
// KnowledgeCenterService configured successfully
}).fail(function(e){
// KnowledgeCenterService failed to configure
});
Options
Option | Type | Description |
---|---|---|
host | string | Knowledge Center Server API URL |
knowledgebases | object | Array of knowledge base IDs for all further requests |
lang | string | Default language for all further requests |
media | string | Media that content needs to be searched for |
apiClientId | string | Default Client ID of application using knowledge |
apiClientMediaType | string | Default Media knowledge is used on |
apiVersion | string | Knowledge Center Server API Version. 'v2' for 9.0 Knowledge Center, 'v1' for 8.5 Knowledge Center. |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When configuration options are provided and set | n/a |
rejected | When no configuration options are provided | 'Invalid configuration' |
getTrending
Fetch trending documents
Example
oMyPlugin.command('KnowledgeCenterService.getTrending', {size: 25}).done(function(e){
// KnowledgeCenterService got trending documents successfully
// e == Object with trending categories and documents
}).fail(function(e){
// KnowledgeCenterService failed to get trending documents
});
Options
Option | Type | Description |
---|---|---|
size | number | Maximum number of returned items |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | Object with trending categories |
rejected | When KC Server returns error | 'KC Server error' |
search
Search documents relevant to query
Example
oMyPlugin.command('KnowledgeCenterService.search', {
query: 'topic',
size: 10,
categories: [ 1, 2, 3, 4, 5 ]
}).done(function(e){
// KnowledgeCenterService search executed successfully
// e == Object with search results
}).fail(function(e){
// KnowledgeCenterService failed to execute search
});
Options
Option | Type | Description |
---|---|---|
query | string | Search query |
size | number | Maximum number of returned items |
categories | object | Array of Category IDs for additional filter |
knowledgebases | object | Array of knowledge base IDs for all further requests. Overwrites knowledgeCenterServer widget settings |
lang | string | Default language for all further requests. Overwrites knowledgeCenterServer widget settings |
media | string | Media that content needs to be searched for. Overwrites knowledgeCenterServer widget settings |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
getSuggestions
Search suggestions for autocomplete functionality
Example
oMyPlugin.command('KnowledgeCenterService.getSuggestions', {
query: 'topic',
size: 10,
categories: [ 1, 2, 3, 4, 5 ]
}).done(function(e){
// KnowledgeCenterService got suggested documents successfully
// e == Object with suggestions
}).fail(function(e){
// KnowledgeCenterService failed to get suggested documents
});
Options
Option | Type | Description |
---|---|---|
query | string | Search query |
size | number | Maximum number of returned items |
categories | object | Array of Categories ID for additional filter |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
getCategories
Get list of categories
Example
oMyPlugin.command('KnowledgeCenterService.getCategories').done(function(e){
// KnowledgeCenterService got categories successfully
// e == Object with categories
}).fail(function(e){
// KnowledgeCenterService failed to get categories
});
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | Object containing categories |
rejected | When KC Server returns error | 'KC Server error' |
getFullContent
Get full document content
Example
oMyPlugin.command('KnowledgeCenterService.getFullContent', {
docId: '12345',
kbId: '1'
}).done(function(e){
// KnowledgeCenterService got full content successfully
// e == Object with content of a document
}).fail(function(e){
// KnowledgeCenterService failed to get full content
});
Options
Option | Type | Description |
---|---|---|
docId | string | Document ID |
kbId | string | Knowledge base ID where the document is located |
lang | string | Default language for all further requests |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
visit
Mark a document as opened
Example
oMyPlugin.command('KnowledgeCenterService.visit', {
docId: '12345',
kbId: '1'
}).done(function(e){
// KnowledgeCenterService marked as visited successfully
}).fail(function(e){
// KnowledgeCenterService failed to mark as visited
});
Options
Option | Type | Description |
---|---|---|
docId | string | Document ID |
kbId | string | Knowledge base ID where the document is located |
query | string | Used query for prior search |
categories | object | Used categories filter for prior search |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
vote
Provide relevancy feedback (relevant/irrelevant)
Example
oMyPlugin.command('KnowledgeCenterService.vote', {
docId: '12345',
kbId: '1',
query: 'search',
relevant: 'true'
}).done(function(e){
// KnowledgeCenterService voted successfully
}).fail(function(e){
// KnowledgeCenterService failed to vote
});
Options
Option | Type | Description |
---|---|---|
docId | string | Document ID |
kbId | string | Knowledge base ID where the document is located |
query | string | Used query for prior search |
categories | object | Used categories filter for prior search |
relevant | boolean | Whether the document was relevant |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
unanswered
Mark search result as the one that does not contain relevant documents
Example
oMyPlugin.command('KnowledgeCenterService.unanswered', {
kbId: '12345',
query: 'text'
}).done(function(e){
// KnowledgeCenterService marked search result as irrelevant successfully
}).fail(function(e){
// KnowledgeCenterService failed mark search result as irrelevant
});
Options
Option | Type | Description |
---|---|---|
kbId | string | Knowledge base ID where search were executed |
query | string | Used query |
categories | object | Used categories filter |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When KC Server returns appropriate response | n/a |
rejected | When KC Server returns error | 'KC Server error' |
sessionInfo
Retrieves parameters of the current knowledge session
Example
oMyPlugin.command('KnowledgeCenterService.sessionInfo').done(function(e){
// KnowledgeCenterService got session info successfully
// e == {sessionId: "<sessionId>", language: "<languageCode>", media: "<mediaType>"}
}).fail(function(e){
// KnowledgeCenterService failed to get session info
});
Resolutions
Status | When | Returns |
---|---|---|
resolved | When there is existing knowledge session | {sessionId: "<sessionId>", language: "<languageCode>", media: "<mediaType>"} |
rejected | When knowledge session is not established yet | 'Knowledge center session is not started yet' |