Implementing the rule-based chatbot
In this section, we will understand the implementation of the chatbot. This implementation is divided into two parts. You can find this code by visiting: https://github.com/jalajthanaki/Chatbot_Rule_Based:
Implementing the conversation flow
Implementing RESTful APIs using flask
Implementing the conversation flow
In order to implement the conversation logic, we are writing a separate Python script, so that whenever we need to add or delete some logic it will be easy for us. Here, we create one Python package in which we put this conversation logic. The name of the file is conversationengine.py and it uses JSON, BSON, and re as Python dependencies.
In this file, we have implemented each conversation in the form of a function. When the user opens the chatbot for the first time, a welcome message should pop up. You can refer to the code given in the following screenshot:
Now the users need to type in Hi in order to...