XState-Chatbot Integration Document

Overview

XState-Chatbot is a revamped version of the chatbot, which provides functionality to the user to access PGR module services like file complaint, track complaint, receives notifications on whats app for any updates regarding the complaints, It also allow user to view receipts and pay the bills for property tax , water service, sewerage service and other service module on whatsapp.

Key Functionalities

  • File PGR complaint

  • Track PGR complaint

  • Support images when filing complaints

  • Notifications to citizen when employee performs any action on complaint

  • Allow user to search and pay bills of different modules.

  • Allow user to search and view receipts of different modules.

  • Allow user to change the language of their choice to have better experience.

  • Put user interactions on elastic search for Telemetry.

Integration

Integration Scope

XState chatbot can be integrated with any other module to improve the ease of search and view bills/past payment receipts and to improve speed and convenience for bill payment. It can integrated with PGR module for easiness of creation and tracking of complaint.

Integration Benefits

  • Increase in convenience and ease of making bill payment.

  • Increase in number of users opting for online payment.

  • Improvement in demand collection efficiency

  • Creating a additional channel for payment.

  • Remove dependency on mobile/web app or counter.

Integration Details

Integration of New Whatsapp Provider :

Whatsapp provider is a third party service which works in the middle of a user's whatsapp client and  XState-Chatbot server. All messages coming/going to/from user pass through whatsapp provider. XState-Chatbot service calls whatsapp provider to send messages to user. When a user responds with any whatsapp message the whatsapp provider calls XState-Chatbot service’s configured endpoint with details ex:- user message, sender’s mobile number, type of message like text, location, media etc.

If any new whatsapp provider needs to be integrate with chatbot service, then code must be written to convert provider’s incoming messages to the format that chatbot understands and also final output from chatbot should be converted to whatsapp provider’s API request format.

Currently, the XState-Chatbot service is using ValueFirst as the WhatsApp Provider. This will require provider-specific environment variable to be configured. If the provider changes then, all these environment variable will also change. Few of those environment variable are stored as secrets, so these values need to be configured in env-secrets.yaml.
As this is a revamped version of the chatbot service, all of the secrets should already be present. There is no need to create new secrets.

Other details that need to be shared with value first:

  • For the whatsapp account received from valuefirst share the domain name and egress Ip’s with valuefirst to whitelist it.
    eg: Domain name:- https://qa.digit.org
    Egress IP's:-  65.2.250.000

  • Share the API which whatsapp provider will use to connect with chatbot.
    eg: https://qa.digit.org/xstate-chatbot/message (this API for sending message to chatbot)
    https://qa.digit.org/xstate-chatbot/status (this API is to receive Delivery report from value first)
    PS: Whitelist this above API in our environment also

  • Share the template details with value first team to get it approved. Below is the sample sheet

 

Integration of PGR complaint feature in XState-Chatbot:

The integration of PGR with chatbot can be enable and disable by making changes in this file.
By exporting the respective PGR service file, the PGR service feature can be enable and vice versa.

Configuration of PGR version in chatbot:

To configure the PGR module to use in Xstate-chatbot. The below variable values need to change in environment file as per the requirement.

  • pgrVersion

  • pgrUpdateTopic

To configure PGR v1 in XState chatbot then pgrVersion should be ‘v1' and pgrUpdateTopic should be 'update-pgr-service’.

For PGR v2, pgrVersion should be ‘v2' and pgrUpdateTopic should be 'update-pgr-request’.

Configuration of city and locality search with nlp-search engine

To enable the fuzzy search for city and locality selection in PGR complaint flow
The variable nlp-geoSearch has to be set true in the environment file.
To use the nlp-search engine with xstate chatbot, make sure that stable build is deployed and all the mdms data are present for that particular environment.
To know more about the nlp-search engine service please refer to the Reference document section.

 

Adding Information Image in PGR complaint creation and Open search information image

To configure the filestoreid for informational image follow the steps mention below

  1. Download the images from the section Information Images for PGR and Open Search

  2. Upload the image into filestore server. Use the upload file API from this postman collection(https://www.getpostman.com/collections/bdb059c5af698f0d81d6)

  3. For PGR information image mention the filestore id here in environment file .

  4. For Open search information image mention the filestore id here in environment file .

Configuration of push notification template messages

For Compliant status update notifications to citizen when employee performs any action on complaint.

Xstate chatbot is maintaining the template id of each message which get triggered on respective status or action perform on the complaint. The template id’s are maintain in environment file.
For any new push notification message not only for PGR complaint, its template id need to be mention in above file.

Each notification in different language will have different template ids. For example the complaint resolve notification in english will have template id as ‘12345' and same notification in hindi will have template id as ‘6789’. The order of mentioning the template id must be same as the order of the supported locale mentioned in env-variable.js file.

For example:

a) if supportedLocales: process.env.SUPPORTED_LOCALES || 'en_IN,hi_IN'

then valuefirst-notification-resolved-templateid: "12345,6789"

b) if supportedLocales: process.env.SUPPORTED_LOCALES || 'hi_IN,en_IN'

then valuefirst-notification-resolved-templateid: "6789,12345"

(Note: Both the list should not be empty, it must contain at least one element)


Configuration of push notification template messages with button

Template messages with button are maintained in the same way as describe in previous section (Configuration of push notification template messages)

There are two type of button message

  • Quick Reply

  • Call To Action

More details can be found in the value first document.

Integration of Bill Payment and Receipt Search feature in Xstate-Chatbot:

The integration of Bill payment and receipt search feature with chatbot can be enable and disable by making changes in this file. By exporting the respective bill service and receipt service file, the payment and receipt search feature can be enable and vice versa.

Configuration of module for Bill payment and Receipt search

To configure the list of module to be appear as option for payment and receipt, Add the module business service code in the list present in environment file.

For example:
If bill-supported-modules: "WS, PT, TL"
then Water and Sewerage, Property, Trade license module would appear for bill payment and
receipt search.

Also add the message bundle, validation and service code for locality searcher in egov-bill and egov-receipt file.

Configuration of Xstate-Chatbot localisation message

XState-Chatbot does not have any MDMS data, nor does it store any messages in localization-service. If any message needs to be modified, the changes will have to be made in the source code, then build the new docker image and deploy it.
For Configuration details of XState-chatbot localisation message please refer to the links in Reference Docs.

Below tables contains the details about some environment variables use in XState-Chatbot service which is present in this file:

Environment Variables

Description

WHATSAPP_BUSINESS_NUMBER

 The mobile number to be used on server

VALUEFIRST_USERNAME

Username for configured number for sending messages to user through whatsapp provider API calls

VALUEFIRST_PASSWORD

Password for configured number for sending messages to user through whatsapp provider API calls

GOOGLE_MAPS_API_KEY

Maps API key to access geocoding feature

ROOT_TENANTID

Contains state level tenantid value

SUPPORTED_LOCALES

This variable contains the list supported language in chatbot.
If there is a need to add new language in chatbot, then its respective locale need to add in this list.

PGR_VERSION

Contains PGR version value to use (i.e v1 or v2)

PGR_UPDATE_TOPIC

Depends on PGR version respective PGR update kafka topic name should mention here.
Example: If PGR_VERSION: 'v2' then PGR_UPDATE_TOPIC: 'update-pgr-request'

BILL_SEARCH_LIMIT

Limit for showing maximum number of bills on search.

RECEIPT_SEARCH_LIMIT

Limit for showing maximum number of receipts on search.

COMPLAINT_SEARCH_LIMIT

Limit for showing maximum number of complaints on search.

BILL_SUPPORTED_MODULES

Contains the list of modules to be use for bill payment and receipts search.

INFORMATION_IMAGE_FILESTORE_ID

Contains the filestoreid of informational image, which shows how to share the user current location.

OPEN_SEARCH_IMAGE_FILESTORE_ID

Contains the filestoreid of open search informational image, which shows how to use open search pay feature for bill payment

USER_SERVICE_HARDCODED_PASSWORD

This variable contain fixed value of login password and otp. This value has to configured in env-secrets.yaml. 

GEO_SEARCH

Boolean flag to enable and disable city / locality nlp search

Configuration of Telemetry File

Add this telemetry file in config repo and mention the filename in respective environment yaml file.


Searcher config file:


https://github.com/egovernments/configs/blob/qa/egov-searcher/localitySearcher.yml

Cron job mdms entry:

https://github.com/egovernments/egov-mdms-data/commit/30881ab4f759c8b607417be2047b46865ec953ef


Localisation for PGR service:


Information Images for PGR and Open Search

Location Share Image

 

Open Search Image

 

Reference Docs

Doc Links

Title

Link

Title

Link

Chatbot Message Localisation

Chatbot Message Localisation Doc

nlp-search engine

https://digit-discuss.atlassian.net/l/c/qNcRsW2b

API List