Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Prerequisites

  • NodeJS

  • XState

  • 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

  1. Deploy the latest version of xstate-chatbot

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

  3. Add indexer-config to the egov-indexer to index all the telemetry messages

Environment Variable

Description

WHATSAPP_PROVIDER

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 console adapter is provided for developers to test the chatbot locally.

REPO_PROVIDER

The database used to store the chat state. Currently, an adapter for PostgreSQL is provided.

An InMemory adapter is provided to test the chatbot locally

SERVICE_PROVIDER

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.

SUPPORTED_LOCALES

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

...

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

  2. Any code that doesn’t include any asynchronous API call can be written as a part of the onEntry function or an action.

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

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

...