This is an example Django app that shows how to create a simple chat bot web app using Django and ChatterBot.
Clone this repository:
git clone <repo>
cd <repo>Ramp up virtual environment (very much recommended)
python3 -m virtualenv venv
source venv/bin/activateIntall requirements
pip3 install -r requirements.txtGenerate a new Django SECRET_KEY, e.g. via https://miniwebtool.com/django-secret-key-generator Then:
export DJANGO_SECRET_KEY='<secret_key>'
echo SECRET_KEY='<secret_key>' > .envDjango first-time initialization
python manage.py migrate --run-syncdb
python manage.py migrate trainStart the Django app by running
python manage.py runserver 0.0.0.0:8000Further documentation on getting set up with Django and ChatterBot can be found in the ChatterBot documentation
python manage.py migrateOR
python manage.py migrate django_chatterbotpython manage.py trainChatterbot is a very flexible and dynamic chatbot that you easily can create your own training data and structure.
The chatterbot corpus path can be found here, well documented.
You could found Bot settings here
CHATTERBOT = {
'name': 'Heroku ChatterBot Example',
'logic_adapters' : [
"chatterbot.logic.BestMatch"
],
'trainer': 'chatterbot.trainers.ChatterBotCorpusTrainer',
'training_data': [
'chatterbot.corpus'
]
}Include your address at the ALLOWED_HOSTS directives in settings.py - Just the domain, make sure that you will take the protocol and slashes from the string
for example
ALLOWED_HOSTS = ['127.0.0.1', 'chatterbot-demo.herokuapp.com']heroku create Creating intense-falls-9163... done, stack is cedar http://intense-falls-9163.herokuapp.com/ | git@heroku.com:intense-falls-9163.git Git remote heroku added
Before deploying Heroku you should install Heroku CLI on your machine, documentation found here https://devcenter.heroku.com/articles/heroku-cli
Login:
heroku loginEnter your Heroku credentials. ...
git add .
git commit -m "<comment>"
git push heroku master
heroku run python manage.py migrate
heroku run python manage.py trainheroku pg:reset DATABASE
heroku run python manage.py migrate
heroku run python manage.py createsuperuser
heroku run python manage.py shell
>>> from chatterbot import ChatBot
>>> from chatterbot.ext.django_chatterbot import settings
>>> chatbot = ChatBot(**settings.CHATTERBOT)
>>> chatbot.storage.drop()
heroku run python manage.py trainA more detailed information can be found here https://devcenter.heroku.com/articles/deploying-python
ChatterBot Django Live Example is licensed under BSD 3-clause
- Simple chatbot in Python using NLTK and scikit-learn: https://github.com/LuciaLlavero/ryuzaki_bot
- Django + ChatterBot: https://github.com/vkosuri/chatterbot-live-example