Skip to content

sgino209/ChatterBot_app

ChatterBot Django Live Example

This is an example Django app that shows how to create a simple chat bot web app using Django and ChatterBot.

Quick Start

Clone this repository:

git clone <repo>
cd <repo>

Ramp up virtual environment (very much recommended)

python3 -m virtualenv venv
source venv/bin/activate

Intall requirements

pip3 install -r requirements.txt

Generate 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>' > .env

Django first-time initialization

python manage.py migrate --run-syncdb
python manage.py migrate train

Start the Django app by running

python manage.py runserver 0.0.0.0:8000

Further documentation on getting set up with Django and ChatterBot can be found in the ChatterBot documentation

Make migrations

python manage.py migrate

OR

python manage.py migrate django_chatterbot

Train your bot

python manage.py train

Training Corpus Path

Chatterbot 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.

Bot Django Settings

You could found Bot settings here

CHATTERBOT = {
    'name': 'Heroku ChatterBot Example',
    'logic_adapters' : [
        "chatterbot.logic.BestMatch"
    ],
    'trainer': 'chatterbot.trainers.ChatterBotCorpusTrainer',
    'training_data': [
        'chatterbot.corpus'
    ]
}

Allowed Hosts

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']

Deploying on Heroku

Creating a new Heroku app

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

Heroku CLI

Before deploying Heroku you should install Heroku CLI on your machine, documentation found here https://devcenter.heroku.com/articles/heroku-cli

Login:

heroku login

Enter your Heroku credentials. ...

Deploying

git add .

git commit -m "<comment>"

git push heroku master

heroku run python manage.py migrate
heroku run python manage.py train

Reset

heroku 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 train

A more detailed information can be found here https://devcenter.heroku.com/articles/deploying-python

LICENSE

ChatterBot Django Live Example is licensed under BSD 3-clause

Similar works:

About

ChatterBot WebApp

Resources

License

Apache-2.0, BSD-3-Clause licenses found

Licenses found

Apache-2.0
LICENSE
BSD-3-Clause
license.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •