Skip to main content

PWA Ecosystem

The PWA ecosystem is a group of components that act as a ready to go, web based, chat interface that is able to seamlessly connect with Bharat SahAIyak bots and is designed to be embeddable and fully pluggable in your own webpage or to be used as standalone application altogether.

In context of Bharat SahAIyak, PWA is just another channel which is supported just like Whatsapp, Telegram, etc. You can assume PWA as a self owned messaging channel.

The PWA ecosystem consists of the following services:

ChatUI

The ChatUI is the frontend component of the PWA, which works as a simple chat interface which helps users communicate with any bot.

Authentication

Transport Socket

Transport Socket is a simple socket based service that connects with ChatUI to enable socket communication. The Transport Socket in turn connects with inbound service to relay the messages to the Bharat SahAIyak system. In other channels this is done through webhooks.

User Service

Now that we have a frontend as well as a socket communication service to relay messages, we need some kind of auth to prevent unauthorized messages into the system.

The inbound service by default assumes that the incoming requests are already authenticated by the time it reaches the service. In case of other platforms, like Whatsapp and Telegram, where the request comes through a webhook, the request is already authenticated as there is no way to modify the request that comes through a webhook, since those are owned by the providers (like Gupshup in case of Whatsapp, or in case of Telegram the webhook is owned by Telegram itself).

In case of PWA the transport socket request is unauthenticated and open, hence an authentication system is required on ChatUI which can be verified on Transport Socket. This is where the role of User Service as an authentication mechanism comes into play. Here is how the basic authentication steps takes place.

  • The ChatUI presents a login flow to the user.
  • The user enters the necessary credentials for the login to take place.
  • The ChatUI uses these credentials to generate a JWT auth token by interacting with UserService.
  • When a user sends a message to Bharat SahAIyak system (to Transport Socket essentially), the JWT is verified against a JWKS provided by User Service.
  • If the JWT is verified, the request is further sent to Inbound service, or else the request fails with Unauthorized Error.

Here is a diagram which illustrates the working of Authentication System

Authentication