showArticle

showArticle(articleId) : void

Force widget to display article by specified article id (method works for both Search and Conversational widgets)

Parameters

articleId: Number text
nanorep.floatingWidget.focus();
nanorep.floatingWidget.showArticle(1046126072);
        

defineDictionary

defineDictionary(languageCode, dictionary) : void

Override default widget localization like in SDK environment. More information here (method available at any time)

Parameters

languageCode: String Code of language
dictionary: Object Object with translations

setStorageOptions

setStorageOptions(options) : void

Use this method to enforce specific storage options like crossdomain support. (must be used only before widget is fully loaded)
For example:
nanorep.floatingWidget.setStorageOptions({ type: 'session', crossDomainHelper: 'https://<AccountName>.nanorep.co/web/assets/_storage.html' });

options: Object

Options to configure storage:

  • type (string) - either "session" (HTML5 sessionStorage) or "persistent" (HTML5 localStorage). Default: "persistent"
  • customKey (string) - use custom name for the "key" in the sessionStorage/localStorage. (Default: "widgetType." + "widgetMode." + "account." + "kbId")
  • crossDomainHelper (string) - URL of the HTML helper page that will enable single storage for widgets on different domains. For an example, please view the source at your https://<AccountName>.nanorep.co/web/assets/_storage.html page. Default: null

setFAQ

setFAQ(options) : void

Allows to programmatically control FAQ sections inside the widget (options is an object or an array of objects which describe FAQ section parameters).
It can use same filtering options like FAQ SDK and might look like following:
{ title: 'Top 5 questions:', filter: { days: 21, items: 5, labelId: '1D4AE1C' }, behavior: ['onNoResults', 'onWidgetLoad', 'onClearSearchField'] })

It can use same filtering options like FAQ SDK

{ title: 'Top 5 questions:', filter: { days: 21, items: 5, labelId: '1D4AE1C' }, behavior: ['onNoResults', 'onWidgetLoad', 'onClearSearchField'] }

setCustomParams

setCustomParams(params) : void

Define custom parameters that can be used inside the article title/body statements like {{brand}}.
"params" object should look like { name: 'John', age: 31 }
(method available after widget is fully loaded)

getContext

getContext() : Promise

Get current context of the widget (method available at any time)

setContext

setContext(context) : Promise

Set widget context (method available at any time)

Parameters

context: Object Plain object with new context

getPredefinedValues

getPredefinedValues() : Promise

Get current predefined values that can be used by contact form to prepopulate form field values (method available at any time)

setPredefinedValues

setPredefinedValues(values) : Object

Set predefined values that can be used by contact form to populate form fields (method available at any time)

Parameters

values: Object Plain object with predefined values

getInputValue

getInputValue() : Promise

Get current value from the query field (method available after widget is fully loaded)

nanorep.floatingWidget.getInputValue().then(alert);

getLastQuery

getLastQuery() : Promise

Get last search query in case of search widget or last statement in case of conversational widget (method available after widget is fully loaded)

nanorep.floatingWidget.getLastQuery().then(alert);

searchByLabels

searchByLabels(labels) : void

Filter search results by specified labels. Array of labels should look like ['32715845', '30840398']
(method available at any time)

Parameters

labels: Array Array of labels to search

preprocessInput

preprocessInput(hook) : void

This method allows to sanitize user input that is being sent to server

Parameters

hook: Function Hook function will be invoked for each string entered by user with single argument - string entered by user. (method available at any time)
Example usage: this.preprocessInput(function(input) { return input.replace(/[0-9]/g, '*') })

preprocessAnswers

preprocessAnswers(hook) : void

This method allows to install preprocessing hook on each answer that will be displayed inside the widget.

Parameters

hook: Function Hook function will be invoked for each answer model with single argument - answer model that can be modified inside this function. (method available at any time)
Example usage: this.preprocessAnswers(function(answer) { answer.title = '* ' + answer.title })

setAnswerDisplayMode

setAnswerDisplayMode(mode) : void

Set answer rendering mode. Two modes are supported - "iframe" and "default"
(method available at any time)

Parameters

mode: String One of "iframe" and "default"

toggleFollowMe

toggleFollowMe(enabled) : void

Enable or disable "Follow Me" feature (when widget is automatically showing last answered question after page reload/redirect)
(method available at any time)

Parameters

enabled: Boolean New state of FollowMe