It is very easy to start using the Web SDK on any webpage. Just include the script with the specified list of components and APIs you want to use, and set the SDK options. Then all exposed components in the namespaces will be available for your use.
init(options) : void
Set
options: Object |
Initialize SDK with options that will be used across all SDK components and APIs. options is a plain object like { host: 'vodafone.nanorep.co', account: 'vodafone', kb: 'English' } |
setPredefinedValues(values) : void
Set predefined values which can be used by contact forms to prepopulate field values. values
is a plain key-value object like: { subject: 'my predefined subject', name: 'John Predefined', email: 'predefined@example.com' }
values: Object |
Initial values object |
addChatProvider(providerName, providerProto) : void
Add custom chat provider implementation as described here
providerName: String |
Name of chat provider |
providerProto: Object |
Specific chat provider prototype object |
getDefaultPageContext() : Object
Get page context object like: { make: 'phone', model: 'iphone', version: '10.0'}
. Empty object in case of no context on page
preprocessInput(hook) : void
Just like in the widget this method allows to sanitize user input that is being sent to server. 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: nanorep.sdk.preprocessInput(function(input) { return input.replace(/[0-9]/g, '*') })
hook: Function |
Hook function to sanitize user input |
nanorep.sdk.on('escalate', function(channel, answer) {})
Called when user initiated escalation using channeling buttons
channel: Object |
Channel object |
answer: Object |
Answer object, that was escalated |
nanorep.sdk.on('feedback', function(feedbackInfo, answer) {})
Called after user feedback action. Feedback info object contains something like: { positive: false, type: 4, text: '' }
feedbackInfo: Object |
Object with information about feedback |
answer: Object |
Answer object, that was escalated |
nanorep.sdk.on('showAnswer', function(answer) {})
Called when answer becomes visible
answer: Object |
Answer object that has been showed |
nanorep.sdk.on('toggleAnswer', function(answer, isOpened) {})
Called when answer becomes visible or invisible
answer: Object |
Answer object |
isOpened: Boolean |
New state of answer |
nanorep.sdk.on('activateBlockquote', function(blockQuoteText, answerId, searchQuery) {})
Called when user clicks on "actionable blockquotes" (Touchpoints → Advanced → Actionable block quotes in answer text)
blockQuoteText: String |
Text of activated blockquote |
answerId: String |
Id of answer |
searchQuery: String |
Search query from query field |
(open browser console and activate feedback or channel)
// initialize SDK with common parameters nanorep.sdk.init({ host: 'nanorep.nanorep.co', account: 'nanorep', kb: 'English' }); // set predefined values for contact form nanorep.sdk.setPredefinedValues({ subject: 'my predefined subject', name: 'John Predefined', email: 'predefined@example.com' }); // add event listeners nanorep.sdk.on({ escalate: function (channel, answer) { console.log('user escalation:', channel, answer); }, feedback: function (feedbackInfo, answer) { console.log('user feedback:', feedbackInfo, answer); } }); // initialize demo component var articleActions = new nanorep.sdk.ArticleActions({ articleId: '1009685682', feedbackType: 'icons', enableFeedback: true, enableChanneling: true }, document.getElementById('example'));
<div id="example"></div>