Inbenta created a special build method to allow authorization through the SDK, using Hyperchat credentials: buildWithHCCredentials(configuration)
The configuration parameter is almost the same as in the build method. The difference is that the authorization is now handled internally.
This example shows how to:
For more information in each adapter:
force
parameter must be set to true
).We will be using all the default configuration, and will only set the needed parameters:
The following examples use both adapters from the internal code.
Example
<!DOCTYPE html>
<html>
<head>
<title>SDK Test</title>
<meta charset="utf-8">
</head>
<body>
<script>
window.buildUI = function () {
var rejectedEscalation = 'What else can I do for you?';
var noAgentsAvailable = 'There are no agents available just now.';
// question configuration
var questions = [
{
label: 'FIRST_NAME',
text: 'What\'s your name?',
validationErrorMessage: 'Name cannot be empty',
validate: function(value) {
if (value !== '') {
return true;
}
return false;
}
},
{
label: 'EMAIL_ADDRESS',
text: 'What\s your email?',
validationErrorMessage: 'The email format is not correct',
validate: function(value) {
return /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/.test(value);
}
},
];
SDKHCAdapter.configure({
apiKey: '<chat_api_key>', // former "appId"
region: '<chat_app_region>',
room: function () {
return SDKHCAdapter.helpers.getQueryParameterValue('q');
},
lang: function () {
return 'en'; // If the instance has languages configured and 'en' is not one of them, this should be changed to the code of a configured language.
},
});
var configuration = {
launcher: {
title: "HyperChatbot Demo"
},
adapters: [
SDKHCAdapter.build(),
SDKcreateHtmlEscalationForm(SDKHCAdapter.checkEscalationConditions, questions, rejectedEscalation, noAgentsAvailable, false)
]
};
InbentaChatbotSDK.buildWithHCCredentials(configuration);
};
</script>
<script src="https://sdk.inbenta.io/chatbot/1/inbenta-chatbot-sdk.js" onload="buildUI()"></script>
</body>
</html>
The appId
parameter is DEPRECATED in favor of apiKey
, for consistency with Inbenta terminology. If you use appId
, Inbenta recommends that you update your configuration.