I’m looking for a solution to open the chat bot using a particular key from the keyboard. I need have a custom Web/SDK code implementation where the chat bot opens on pressing the key on keyboard (ex: spacebar or enter).
Kindly suggest/help.
I’m looking for a solution to open the chat bot using a particular key from the keyboard. I need have a custom Web/SDK code implementation where the chat bot opens on pressing the key on keyboard (ex: spacebar or enter).
Kindly suggest/help.
@priya.mandal
Kore.ai webSDK is a JS and JQuery library. So if you simply google how to perform some action on a web page on key press, you should get the answer. All I am trying to say here is that the solution here is not Kore.ai platform specific.
I will share some code with you which may help you. Basically, based on a ‘keyup’ or event listener configured, one needs to click the minimized chat window (use an identifier - the id or class of the chat button - and click)
In kore-main.js, after$(document).ready(function ()
function if you write this code -
$(document).keyup(function (event) {
if (event.key == "Enter") {
//trigger chat icon click
$('.kore-chat-window .minimized').trigger('click');
}
});
Or the below for combination keys (Shift + B) [Refer to this for more details]
window.addEventListener('keydown', function (event) {
if (event.shiftKey && event.code === 'KeyB') {
$('.kore-chat-window .minimized').trigger('click');
}
});
Now when you open the bot index.html, based on the key press you have configured in your code, you can invoke the chat window now.
Credits: @rajasekhar.balla