Skip to content

RajSinha77/Covid-19-Tracker-ChatBot

Repository files navigation

Covid-19-Tracker-ChatBot

COVID-19 Tracker ChatBot in which it tries to understand multiple intents, extract the Named Entity Recognition (NER) values, implementing a custom COVID-19 visual response, and has Slack integration.A chatbot which gives updated details about covid19 spread all over India. This chatbot is made using RASA.It can answer your basic questions like "How are you?" and corona based questions like "Can you give me details of corona in Jharkhand?"

Installation

pip install rasa
rasa init

Important concepts:

Intent: Intent means purpose/aim/target of chatbot of the user input example, if user typed "I want to order a book?" here intent would be "ordering..."

Entity: useful information that can be extracted from user like, "I want to order a book?" from this we extract "book" as an entity.

Action : It is just a response from the chatbot so it can be a code reply or api response

Stories: These are a sample interaction between the user and bot, defined in terms of intents captured and actions performed.

Domain: Domain knowledge is required to reply for any user query.

We can define this all concepts in code as follows: Intent and Entity ==> nlu.md Story (Dialogue Management) ==> Stories.md Actual output (Hard code)[all intent , action, response] ==> domain.yml Custom reply ==> action.py

For covid19 chat bot we are using external opensource api https://api.covid19india.org/data.json following are the steps to build basic chatbot

Steps: Edit nlu.md file and write intent

intent:corona_status

corona status path

  • corona_status
    • action_corona_status

Edit domain.yml and add action actions:

  • action_corona_status

  • action_hello_world

  • action_search_restaurant Edit action.py class ActionCoronaTracker(Action):

    def name(self) -> Text: return "action_corona_status"

    def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    response = requests.get('https://api.covid19india.org/data.json').json()
    
    entities = tracker.latest_message['entities']
    state=None
    message = "Active cases are {0}\n, confirmed cases are {1}\n, Total deaths are {2}\n, Total patient recovered are {3}\n"
    for e in entities:
        if e['entity'] == 'state':
            state=e['value']
        for data in response["statewise"]:
            if data['state']==state.title():
                
                message = message.format(data['active'], data['confirmed'],data['deaths'],data['recovered'])
    
            else:
                message = "Sorry data not available for input: {}".format(state)
        
    dispatcher.utter_message(text=message)
    
    return []
    

Commands
rasa train (for training model).

rass shell (comand interface provider between user and bot).

rasa shell --debug.

rasa x (UI interface).

rasa train nlu(training nlu.md file).

To run server
sudo rasa run actions To run shell
sudo rasa shell