This repository contains a simple Flask chatbot that uses AIML and Neo4j for natural language processing and database operations respectively. The chatbot is designed to provide responses to user queries, perform database operations like user authentication and social network creation, and also has web scraping capabilities.
To run the chatbot, follow these steps:
- Clone the repository:
git clone <repository_url>- Install the required dependencies:
pip install -r requirements.txt- Download the NLTK packages:
import nltk
nltk.download("punkt")
nltk.download("averaged_perceptron_tagger")
nltk.download("maxent_ne_chunker")
nltk.download("words")-
Set up a Neo4j database:
- Install Neo4j locally.
- Start the Neo4j server.
- Create a database with the name "chatbot" and set the username and password as "neo4j".
-
Set up the OpenAI API:
- Create an account on OpenAI (https://openai.com).
- Obtain an API key.
- Replace
openai.api_keywith your API key in theget_completionfunction.
-
Run the Flask application:
python bot.py
- Access the chatbot at
http://localhost:8888in your web browser.
The repository contains the following files:
bot.py: The main Flask application file that handles the chatbot functionality.relationships.pl: Prolog file used for storing relationships between users.AIML_FILES/*.aiml: AIML files used for defining chatbot responses and actions.templates/: Directory containing HTML templates for the web interface.
The Flask chatbot provides the following features:
- User authentication: Users can sign up and log in to the chatbot.
- User session management: The chatbot tracks user sessions using Flask's
sessionobject. - Natural language processing: The chatbot uses NLTK for natural language processing, including named entity recognition and part-of-speech tagging.
- AIML-based responses: The chatbot uses AIML (Artificial Intelligence Markup Language) for generating responses to user queries.
- Neo4j database operations: The chatbot performs database operations using the Neo4j Python driver, including user authentication and social network creation.
- Web scraping: The chatbot can perform web searches using the Google Search API and open web pages using the
webbrowsermodule.
- To interact with the chatbot, open your web browser and access
http://localhost:8888. - Sign up for an account or log in if you already have one.
- Enter your queries in the chatbot interface and see the responses.
- The chatbot can provide information, perform calculations, search the web, and more.
- The chatbot uses the Neo4j database to store user information and relationships. Make sure you have Neo4j installed and running locally before using the chatbot.
- The AIML files in the
AIML_FILESdirectory define the chatbot's responses. You can modify these files to customize the chatbot's behavior. - The OpenAI API key is required to use the
get_completionfunction. Replaceopenai.api_keywith your API key to enable the completion functionality. - The NLTK packages are used for natural language processing tasks. Make sure to download the required packages using
nltk.downloadas mentioned in the installation steps.
Feel free to explore and modify the code to meet your requirements!