Mood Bot | Small Talk Bot |
---|---|
I have made a simple chat application which sends user message to RASA server, and sends response back to user - both text and image. There are 2 main parts:
- RASA Model
- Chat App
RASA is an Open-Source machine learning framework for building contextual AI assistants and chatbots. It Consists of 2 components –
- Natural Language Understanding (NLU)
- Dialogue Management aka Core
NLU: Ear of assistant. Help assistant to understand what is being said. It Takes user input in an unstructured human language and extract structured data in form of intents and entities.
Dialogue Management (Core): - Brain of Assistant. Makes decision of how an assistant should respond based on specific state of conversation as well as context. - Core learns by observing patterns from conversational data between user and Assistant (aka stories).
-
open/create virtual-env and activate it
-
pip install rasa
-
cd to project dir
-
rasa init - It will setup initial rasa project named Mood bot
-
For training model- rasa train
-
For running model- rasa shell
-
open virtual-env and cd to project dir
-
rasa train
-
rasa run -m models --enable-api --endpoints endpoints.yml - note the port no of local host
-
open ngrok and type- ngrok http PORT-NO (eg- ngrok http 5005)
-
copy https link - base url for making request from android app
-
Open postman
-
Make POST request to - NGROK-HTTPS-URL/webhooks/rest/webhook. (eg- https://5ea1-2405-201-4029-66-6812-2e4d-93-e9e1.ngrok.io/webhooks/rest/webhook)
-
Select Body, choose raw and input data in JSON format.
eg- { "sender": "shashank", "message":"how are you" })
- click send and observer response.
I used retrofit inside my chat app to make POST request to RASA server and display response to user. I have used MVVM architecture to better organize my project and handle configuration changes. There are 3 types of views used in recycler view of chat conversation:
- user message
- bot message
- bot loading message
- Retrofit
- Gson
- Glide
- ViewModel
- Material Design
- Executor Services
Visit here, for pre-built rasa models.