Login With Github

Quick Start Guide For ChatterBot

The first thing you'll need to do to get started is install ChatterBot.

pip install chatterbot

See Installation for options for alternative installation methods.

Create a new chat bot

Note:If you are using Python 2.7, be sure that the unicode header is the first line of your Python file: # -*- coding: utf-8 -*-

from chatterbot import ChatBot
chatbot = ChatBot("Ron Obvious")

Note:The only required parameter for the ChatBot is a name. This can be anything you want.

Training your ChatBot

After creating a new ChatterBot instance it is also possible to train the bot. Training is a good way to ensure that the bot starts off with knowledge about specific responses. The current training method takes a list of statements that represent a conversation. Additional notes on training can be found in the Training documentation.

Training is not required but it is recommended.

from chatterbot.trainers import ListTrainer

conversation = [
    "Hello",
    "Hi there!",
    "How are you doing?",
    "I'm doing great.",
    "That is good to hear",
    "Thank you.",
    "You're welcome."
]

chatbot.set_trainer(ListTrainer)
chatbot.train(conversation)

Get a response

response = chatbot.get_response("Good morning!")
print(response)

2 Comments

temp

Thank for this great work.

I found an error for this line : 

chatbot.set_trainer(ListTrainer)

Sytem info:

Windows 10, Anaconda distribution fo Python

Chatterbot version: 1.0.5

Error Message:

[nltk_data]     C:\Users\justi\AppData\Roaming\nltk_data...
[nltk_data]   Package averaged_perceptron_tagger is already up-to-
[nltk_data]       date!
Traceback (most recent call last):

 File "C:\Users\justi\.spyder-py3\temp.py", line 23, in <module>
   chatbot.set_trainer(ListTrainer)

AttributeError: 'ChatBot' object has no attribute 'set_trainer'

I have trained my basic chatbot on the full english corpus. From my INFO log

My input statements are all confidently matched with similar text by processing_search, but in every case I get:-

No responses found. Generating alternate response list.

No known response to the input was found.

followed by obviously a  rubbish response.

Any idea why?