Chatbot Service
Overview
Chatbot service is a chatbot which provides functionality to the user to access PGR module services like filing complaints, tracking complaints, and notifications from WhatsApp. Currently, the citizen has three options - to start a conversation scan the QR code, give a missed call or directly send a message to configured WhatsApp number.
Pre-requisites
Prior knowledge of Java/J2EE.
Prior knowledge of SpringBoot.
Prior knowledge of PostgreSQL.
Prior knowledge of REST APIs and related concepts like path parameters, headers, JSON etc.
Prior knowledge of JSONQuery in Postgres. (Similar to PostgreSQL with a few aggregate functions.)
Dependencies
egov-user-chatbot
: For creating a user without name validation and logging in the useregov-user
: For searching usersegov-localization
: The chatbot is made such that it will store localization codes and the actual text value will be fetched only at the end. This way we can provide multi-lingual support. Localization service is also used to construct messages from templates. This dependency can be eliminated if you want to pass values instead of localization codes.egov-filestore
: It is a dependency if you want to send/receive any file. This includes sending PDF/Image files.egov-url-shortening
: For shortening links sent to the useregov-mdms-service
: For loading MDMS dataegov-location
: For loading locality datarainmaker-pgr
: For creating/searching PGR complaints
Functionalities
Chatbot service allows citizens to access PGR service through WhatsApp. Citizens can provide all details required to create a PGR complaint through the question-and-answer method. The service continuously listens to the PGR update Kafka topic and sends notifications to users associated with the PGR record. On any message from a citizen which is forwarded by a WhatsApp provider, the chatbot processes the messages by passing messages through various stages. For instance - validations, enrichment, transformations etc and at the end sends the final response to the user by calling the endpoint of the WhatsApp provider.
Configuration Details
There are two types of configurations for chatbot states:-
Configuration for each state in chatbot, ex:-
Graph adjacency list configuration:- to define flow between chatbot states,ex:-
Flow Diagrams
High-Level diagram of chatbot interactions
Flow Diagram of Chatbot-User conversation
Flow Diagram of Chatbot notifications
Deployment Details
Add configs required for chatbot service.
Deploy the latest version of the chatbot service.
Add role-action mapping for APIs.
Integration Details
Integration Scope
The chatbot service is used to communicate with the users, lodge their complaints or provide miscellaneous/ad-hoc services which citizens avail from ULBs in an interactive way over WhatsApp.
Integration Benefits
Can perform service-specific business logic without impacting the other module.
In the future, if we want to expose the application to citizens then it can be done easily.
The workflow or Service-specific workflow can be enabled at the chatbot level at any time without changing the design.
Integration Steps
To integrate, the host of the chatbot module should be overwritten in the helm chart.
POST /messages
should be added as the endpoint for receiving user-sent messages and forwarding them to the chatbot core logic for further processing and sending back the response.GET /messages
should be added as the endpoint for receiving user-sent messages and forwarding them to chatbot core logic for further processing and sending back responses.
Reference Docs
Doc Links
Title | Link |
---|---|
API Swagger Documentation |
API Details
a) POST /messages
Receive the user-sent messages and forward them to chatbot core logic for further processing and sending back responses.
If the
media_type
parameter value istext
then user input would be sent in the parametertext
, in other cases wheremedia_type
have some other value ex:- image, location etc, the user input would be sent in a parametermedia_data
b) GET /messages
Receive the user-sent message and forward it to the chatbot core logic for further processing and sending back responses.
If the
media_type
parameter value istext
then user input would be sent in the parametertext
, in other cases wheremedia_type
have some other value ex:- image, location etc, the user input would be sent in a parametermedia_data
Kafka Consumers
update-pgr-service
: used inupdate.pgr.service.topic
application property, the chatbot listens on this topic to listen for updates on PGR records and then to send notifications to users.The service uses consumers for internal processing also between different stages.
Kafka Producers
send-message-localized
: chatbot sends data to this topic for telemetry indexing and for internal processing.The service uses producers for internal processing also between different stages.
Last updated