Quick Start Guide¶
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¶
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")
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)