...
Prerequisites
NodeJS
PostgreSQL
Kafka(optional)
Key Functionalities
Build a chat flow to facilitate a user to interact with rainmaker modules
Link a chat flow with backend services
Deployment Details
Deploy the latest version of xstate-chatbot
Configure /xstate-chatbot API’s to be a whitelisted open endpoint in zuul. There are 3 API’s /message, /status and /reminder. The postman collection is present in this document
Add indexer-config to the egov-indexer to index all the telemetry messages
Environment Variable | Description |
---|---|
| The provider through which WhatsApp messages are sent & received. An adapter for ValueFirst is written. If there is any new provider a separate adapter will have to be implemented. A default |
| The database used to store the chat state. Currently, an adapter for PostgreSQL is provided. An |
| If it’s value is configured to be eGov, it will call the backend rainmaker services. If the value is configured as Dummy, dummy data would be used rather than fetching data from APIs. Dummy option is provided for initial dialog development, and is only to be used locally. |
| A list of comma separated locales supported by the chatbot. |
Other configuration details are mentioned as part of the XState-Chatbot Integration Document.
Overall Philosophy of Chatbot
This chatbot solves the basic form filling aspect of a chat flow. By collecting the information from the user, an API call can be made to the rainmaker backend services to fulfill what the user wants to do. It uses the concept of StateCharts (similar to State Machines) to maintain the state of the user in a chat flow and store the information provided by the user. XState is a JavaScript implementation of StateCharts. All chat flows are coded inside the XState framework. This chatbot does not have any Natural Language Processing component. In the future, we can extend the chatbot to add such features.
Basic Introduction to XState
...
The chat states would only include dialog-specific code. Any code related to backend service should be written as a part of a separate …-service.js file.
Any code that doesn’t include any asynchronous API call can be written as a part of the onEntry function or an action.
If the function needs to make an API call, that would have to be written with the invoke-onDone pattern. The asynchronous function should be written as a part of the service file. The consolidated data returned by it can be processed in the state of the dialog file.
Helper functions are written in
dialog.js
file. It is advised to use those functions as much as possible rather than writing any custom logic in dialog files.
...