Article - How to enable WebHook communication in Kore.ai Web-SDK

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

  1. In this article we are only talking about Kore.ai Web-SDK V1.
  2. We are not going further into JWT token generation service creation.

Pre-requisites

  1. 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.
  2. 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.
  3. 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

  1. 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

  1. 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 the kore-config.js
  2. 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

  1. Invoke the Web-SDK on your local and open browser developer tools → Network tab.
  2. Click and Talk to Bot and converse with the bot.
  3. Note that all the communication is via Webhook API calls and no WebSocket connection is established.

Limitations

  1. The Webhook channel is synchronous by default. Some functionalities like Agent Transfer may not work.
  2. 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.