SDK Methods
Bot Accessible SDK
The SDK upon loading exposes a Javascript SDK that can then be used to programmatically control some of the behaviour of the SDK.
Methods
A Reference is similar to a page URL. It can take 2 possible formats:
- block id (e.g.
f60ea240-4cda-d1f9-032f-05eba5794059). You can get block id from dashboard`s URL: dashboard.eu-pl.koda.ai/bot/{bot_id}/create-bot/{block_id}- custom string set on promotion widget in a dashboard (e.g.
lead-form). It's useful if You want to get additional analytics metrics.
open(reference?: string) => void
Open Chatbot Window with start reference
<script>
window.initKBWebSDK = function (SDK) {
const bot = SDK.initKBChatbot({
"token": "TOKEN"
});
setTimeout(function() {
bot.open('f60ea240-4cda-d1f9-032f-05eba5794059');
}, 5000);
}
</script>
trigger(triggerName?: string) => void
Execute the automation set from the dashboard.
<script>
window.initKBWebSDK = function (SDK) {
const bot = SDK.initKBChatbot({
"token": "TOKEN"
});
bot.trigger("dark_mode")
}
</script>
close() => void
Close chat window
setRef(reference: string) => void
Unlike the open method, this method doesn't open chat window, but only set reference block.
show() => void
Show the chatbot button and tooltip.
Note: By default, the button is shown to users on start. You can disable this behavior using the
show_button_on_startoption in Advanced Styles Configuration.
<script>
window.initKBWebSDK = function (SDK) {
const bot = SDK.initKBChatbot({
"token": "TOKEN"
});
// Show button after some condition
bot.show();
}
</script>
hide() => void
Hide the chatbot button and tooltip.
<script>
window.initKBWebSDK = function (SDK) {
const bot = SDK.initKBChatbot({
"token": "TOKEN"
});
// Hide button based on some condition
bot.hide();
}
</script>