Server scripts
Go to Content > Knowledge > Advanced > Server scripts
Here you can add javascript functions that can be used when configuring a knowledge, as for example.

In server scripts, you can add elements to retrieve information from the server: getHostType, getHostName, getServerType.
Console
The console object is used to feed the logs present in the BMS console page for the different log levels
function logs() {
console.debug("un message debug");
console.info("un message info");
console.warn("un message warn");
console.error("un message error");
}
CallApi
To trigger the call to an API from a server script, you must use the following syntax.
var result = JSON.parse(callApi.process(apiName, params));
with apiName containing the name of the defined web service and params containing a JSON object containing a mapping between the keys used by the web service and the values to use. Example params below :
{
'capture.latitude': latitude,
'capture.longitude': longitude,
'capture.zoom': '2'
}
Capture
The server script can read variables from the current conversation via the capture object. For example to know the caller's number for the callbot this can be done as in the example below:
function logNumero() {
console.info('Appel reçu du numéro ' + capture.callbot_client_phone);
}
Dialog
The dialog object allows us to retrieve a lot of information, among which we could find:
The name of the consultation space currently in use in the conversation:
function logSpace() {
var space = dialog.currentConsultationSpace();
console.info('current space ' + space);
}
The language used : dialog.language()
function getDialoglanguage() {
var language = dialog.language();
console.info('current language ' + language);
}
The current URL: dialog.userURL()
function getDialogUrl() {
var url = dialog.userURL();
console.info('current Url ' + Url);
}
The user ID (IP adress, ..) : dialog.userIdentification()
function getDialogId() {
var id = dialog.userIdentification();
console.info('current ID ' + ID);
}
The operating system (OS) used : dialog.userOs()
function getDialogOs() {
var Os = dialog.userOs();
console.info('current Os ' + Os);
}
The browser used : dialog.userBrowser()
function getDialogBrowser() {
var Browser = dialog.userBrowser();
console.info('current Browser ' + Browser);
}
The different user queries: dialog.currentUserSentence()
function userSentenceFromScript() {
return dialog.currentUserSentence()
}
Last updated
Was this helpful?