Problem Statement
The Kore.ai standard Web-SDK supports the WebSocket protocol. Some organizations may not allow WebSocket protocol. Is the Kore Web-SDK capable of working over a Webhook rather than a WebSocket? If yes, how to enable Webhook for Kore Web-SDK?
Solution
Scope
- In this article we are only talking about Kore.ai Web-SDK V1.
- We are not going further into JWT token generation service creation.
Pre-requisites
- The VA/Bot should have a WebHook channel enabled, published, and working (Please test the same from Postman to ensure it is working). Note - It is not a part of this article to help enable the WebHook channel on the bot. Please follow the documentation.
- Prefer WebHook V2 and enable “Polling” if you intend to use it for Kore.ai Web-SDK configured to use WebHook. The above documentation should show how.
- It is expected that you have a JWT token service at your end. Please ensure it is working via Postman and have the URL ready. As per the documentation, the prescribed JWT payload expected is as below. Note - “iss” can be used in place of “appId”. Prefer to use appId but iss (old) is also supported for backward compatibility purposes.
{
"appId": "{{clientId of the bot for the app that was published for the WebHook channel}}",
"sub" : "{{random number. This can be the same as userIdentity}}"
"userIdentity": "{{unique user identity. Please check on the documentation on its significance and when this can be omitted.}}",
"iat" : 161639822
}
If you do not have JWT service, please look for “SDKApp” in https://developer.kore.ai/docs/bots/sdks/kore-ai-web-sdk-tutorial/ and download it. It is an example Nodejs application and has a route “users.js”. You may install it, and use that too for running on your local and provide the link as http://localhost:3000/api/users/sts
- The bot messages use Web/Mobile channel override and the JS templates used (if any) must be Kore.ai templates. If JS is used in all channel response, it will not render correctly. First test the bot over “Talk to Bot” and ensure the messages and templates are rendering fine.
Steps for configuring Web-SDK
- Follow the readme.md section How to enable API based (webhook channel) message communication of the Kore.ai Web-SDK, please enable the same in
kore-config.js
.
This is an example screenshot of thekore-config.js
- Follow https://developer.kore.ai/docs/bots/sdks/kore-ai-web-sdk-tutorial/ Or GitHub - Koredotcom/web-kore-sdk: web client sdk code for setting up the Web-SDK.
Testing
- Invoke the Web-SDK on your local and open browser developer tools → Network tab.
- Click and Talk to Bot and converse with the bot.
- Note that all the communication is via Webhook API calls and no WebSocket connection is established.
Limitations
- The Webhook channel is synchronous by default. Some functionalities like Agent Transfer may not work.
- There is a 15 second timeout for our SaaS over the Webhook channel. So if some service nodes etc. take a long time, do not use this.