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: app.kodabots.com/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.