Python-ChatterBot 1.0.8: ChatterBot is a machine learning, conversational dialog engine for creating chat bots

Latest Release: 1.0.8

This release makes a handful of ChatterBot's dependencies optional as described in #2027

Source code(tar.gz)
Source code(zip)

ChatterBot: Machine learning in Python


ChatterBot is a machine-learning based conversational dialog engine build in Python which makes it possible to generate responses based on collections of known conversations. The language independent design of ChatterBot allows it to be trained to speak any language.

Package Version Python 3.6 Django 2.0 Requirements Status Build Status Documentation Status Coverage Status Code Climate Join the chat at

An example of typical input would be something like this:

user: Good morning! How are you doing?
bot: I am doing very well, thank you for asking.
user: You're welcome.
bot: Do you like hats?

How it works

An untrained instance of ChatterBot starts off with no knowledge of how to communicate. Each time a user enters a statement, the library saves the text that they entered and the text that the statement was in response to. As ChatterBot receives more input the number of responses that it can reply and the accuracy of each response in relation to the input statement increase. The program selects the closest matching response by searching for the closest matching known statement that matches the input, it then returns the most likely response to that statement based on how frequently each response is issued by the people the bot communicates with.


This package can be installed from PyPi by running:

pip install chatterbot

Basic Usage

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus

# Get a response to an input statement
chatbot.get_response("Hello, how are you today?")

Training data

ChatterBot comes with a data utility module that can be used to train chat bots. At the moment there is training data for over a dozen languages in this module. Contributions of additional training data or training data in other languages would be greatly appreciated. Take a look at the data files in the chatterbot-corpus package if you are interested in contributing.

from chatterbot.trainers import ChatterBotCorpusTrainer

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train based on the english corpus

# Train based on english greetings corpus

# Train based on the english conversations corpus

Corpus contributions are welcome! Please make a pull request.


View the documentation for ChatterBot on Read the Docs.

To build the documentation yourself using Sphinx, run:

sphinx-build -b html docs/ build/


For examples, see the examples directory in this project's git repository.

There is also an example Django project using ChatterBot, as well as an example Flask project using ChatterBot.


See release notes for changes

Development pattern for contributors

  1. Create a fork of the main ChatterBot repository on GitHub.
  2. Make your changes in a branch named something different from master, e.g. create a new branch my-pull-request.
  3. Create a pull request.
  4. Please follow the Python style guide for PEP-8.
  5. Use the projects built-in automated testing. to help make sure that your contribution is free from errors.


ChatterBot is licensed under the BSD 3-clause license.


  • added support for python up to 3.10
    added support for python up to 3.10

    Dec 20, 2021

    in, python up to 3.8 was supported and I turned it to 3.10 tested it and it installed successfully

  • AttributeError: module 'time has no attribute 'clock'
    AttributeError: module 'time has no attribute 'clock'

    Dec 21, 2021

    I installed and imported the proper packages. When I used the ChatBot function, I get an error that I put in the title. How do I fix that?

  • How to fine tune on massive dataset (10k + dialog lines)
    How to fine tune on massive dataset (10k + dialog lines)

    Dec 30, 2021

    So i have a few 100k+ datasets, and i made some 10k line ones trying to finetune several models but so far this is the only high level programming project where I have seen full documentation. Is it possible to fine tune my bot to, for example, reply on topics about politics with 10k+ lines of politics conversations, just for fun of course, I don't expect it to come up with anything substantial xD

    I have an RTX 2060 and CUDA 11.3, pythorch, transformers, cudnn 8, etc

  • Few questions
    Few questions

    Dec 30, 2021


    We are a legal tech company planning to develop a legal assistant chatbot. I’d like to know more about the suitability of your framework with our needs. So, please answer the following questions:

    1. Is Mongolian supported?
    2. Is your framework capable of building a chatbot that answers all types of legal questions. Is there a similar use case? (maybe in different industries?)
    3. If your framework is capable of developing a legal assistance chatbot, approximately how many Q&As (intent & response) do we need to train so that our chatbot provides 10,000 different responses? We’re planning to collect 10,000 answers to 100,000 legal questions (10 questions for each response). Is this enough data to train this type of chatbot?
    4. What AI methods are used or what types of algorithms are used?

    Best, Zolo

  • fix bug in with spacy en model
    fix bug in with spacy en model

    Jan 8, 2022

    This PR fixes a bug in the chatterbot/ file


    • A description of the bug and solution can be found in this stack overflow thread
      • Basically one of the lines in is updated to cater for when chatterbot tries to load a model titled en. It ensures that the correct naming of the English model is used, i.e. en_core_web_sm
  • Can't run the Django example.
    Can't run the Django example.

    Jan 9, 2022

    This is my environment by pip list:

    Package                       Version
    ----------------------------- ----------
    alabaster                     0.7.12
    asgiref                       3.4.1
    Babel                         2.9.1
    bleach                        4.1.0
    blis                          0.2.4
    certifi                       2021.10.8
    charset-normalizer            2.0.10
    ChatterBot                    1.0.8
    chatterbot-corpus             1.2.0
    click                         8.0.3
    colorama                      0.4.4
    coverage                      6.2
    coveralls                     3.3.1
    cymem                         2.0.6
    de-core-news-sm               2.1.0
    Django                        2.2.26
    django-bootstrap3             21.2
    docopt                        0.6.2
    docutils                      0.17.1
    en-core-web-sm                2.1.0
    flake8                        4.0.1
    idna                          3.3
    imagesize                     1.3.0
    importlib-metadata            4.2.0
    Jinja2                        3.0.3
    joblib                        1.1.0
    keyring                       23.5.0
    MarkupSafe                    2.0.1
    mathparse                     0.1.2
    mccabe                        0.6.1
    murmurhash                    1.0.6
    nltk                          3.6.7
    nose                          1.3.7
    numpy                         1.21.5
    oauthlib                      3.1.1
    packaging                     21.3
    Pint                          0.18
    pip                           21.3.1
    pkginfo                       1.8.2
    plac                          0.9.6
    preshed                       2.0.1
    pycodestyle                   2.8.0
    pyflakes                      2.4.0
    Pygments                      2.11.2
    pymongo                       3.12.3
    pyparsing                     3.0.6
    python-dateutil               2.8.2
    pytz                          2021.3
    pywin32-ctypes                0.2.0
    PyYAML                        5.3.1
    readme-renderer               32.0
    regex                         2021.11.10
    requests                      2.27.1
    requests-oauthlib             1.3.0
    requests-toolbelt             0.9.1
    rfc3986                       1.5.0
    setuptools                    60.2.0
    six                           1.16.0
    snowballstemmer               2.2.0
    spacy                         2.1.9
    Sphinx                        3.0.4
    sphinx-rtd-theme              1.0.0
    sphinxcontrib-applehelp       1.0.2
    sphinxcontrib-devhelp         1.0.2
    sphinxcontrib-htmlhelp        2.0.0
    sphinxcontrib-jsmath          1.0.1
    sphinxcontrib-qthelp          1.0.3
    sphinxcontrib-serializinghtml 1.1.5
    SQLAlchemy                    1.3.24
    sqlparse                      0.4.2
    srsly                         1.0.5
    thinc                         7.0.8
    tqdm                          4.62.3
    twine                         3.7.1
    twython                       3.9.1
    typing_extensions             4.0.1
    urllib3                       1.26.7
    wasabi                        0.9.0
    webencodings                  0.5.1
    wheel                         0.37.1
    zipp                          3.7.0

    I encountered several problems while attempting to run the Django example. The first one is <frozen importlib._bootstrap>, which I somehow fixed with installing django-bootstrap3 (but pip warns potential uncompetible).

    Also, what the README.rst suggests, running python runserver won't succeed. I only loaded a page with the localhost IP address. Then Django gave errors concerning MIDDLEWARE, which is a key not even exist in (but MIDDLEWARE_CLASSES).

    I followed Django's suggestion and finally successfully loaded the interface. However, the bot won't respond to my input. The terminal outputs: django.db.utils.OperationalError: no such table: django_chatterbot_statement.

    I have given up. There must be many undiscovered problems behind all of these! Help!

  • the question comes in Response and answer comes in statement in next row
    the question comes in Response and answer comes in statement in next row

    Aug 7, 2017


  • Postgres storage adapter
    Postgres storage adapter

    Jan 10, 2019


    Has anyone come up with a storage adapter for Postgres.

    I would like to have postgres storage adapter rather than SQL and Mongodb. But, I am really struggling to create one. Can someone please help me with this.

    If all good, I will prepare the documentation for this.

    Many thanks in advance.

    storage adapter 
  • Not able to import chatterbot after successful installation
    Not able to import chatterbot after successful installation

    Jul 6, 2017

    code :

    from chatterbot import ChatBot
    chatbot = ChatBot(
        'Ron Obvious',
    chatbot.get_response("Hello, how are you today?")

    error :

    Traceback (most recent call last):
      File "", line 1, in <module>
        from chatterbot import ChatBot
    ImportError: No module named chatterbot
  • Chatterbot data to 2M is very slow to reflect why?
    Chatterbot data to 2M is very slow to reflect why?

    Apr 5, 2017

    4G memory usage is not particularly large, but after the training data reflects a very slow data only 2M did not use mongodb to answer

  • Transfer database from JSON to MongoDB
    Transfer database from JSON to MongoDB

    Dec 8, 2015

    I have a JSON database with 1000+ responses, and even after installing python-cjson it's still pretty slow. From what I understand, MongoDB is much faster. Is this correct, and is there an easy way to switch between the two

  • 'ChatBot' object has no attribute 'find'
    'ChatBot' object has no attribute 'find'

    Sep 26, 2018

    File "/usr/local/lib/python3.6/dist-packages/chatterbot/", line 48, in get_or_create statement = AttributeError: 'ChatBot' object has no attribute 'find'