DEV Community

Cover image for Facebook Unofficial API + Chatterbot Bot Part 4: Bot see Bot do
Takunda Madechangu
Takunda Madechangu

Posted on


Facebook Unofficial API + Chatterbot Bot Part 4: Bot see Bot do

Unless you teach your bot new tricks its going to remain dum.

Hello everyone. In this tutorial we are going to teach our bot some new tricks

Training your chatbot

As i browsed the web i only found two way to train your chatbot:

  • Using Listrainer class
  • Using chatterbot corpus

Using ListTrainer class

Import libraries
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
Enter fullscreen mode Exit fullscreen mode
Create bot and start training
chatbot = ChatBot('Training Example')

trainer = ListTrainer(chatbot)

    "Hi there!",

Enter fullscreen mode Exit fullscreen mode

Its that simple

Using Chatterbot Corpus

According to the documentation:

Chatterbot corpus is a corpus of dialog data that is included in the chatterbot module.

Corpus data is user contributed, but it is also not difficult to create one if you are familiar with the language. This is because each corpus is just a sample of various input statements and their responses for the bot to train itself with.

Installing chatterbot-corpus module

pip install chatterbot-corpus

In most cases chatterbot-corpus is not installed by default so you have to install it.

Using the corpus

Forgive me i am thinking of the corpus callosum right now. I must be mad right?

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

This is an example showing how to create an export file from
an existing chat bot that can then be used to train other bots.

chatbot = ChatBot('Export Example Bot')

# First, lets train our bot with some data
trainer = ChatterBotCorpusTrainer(chatbot)

Enter fullscreen mode Exit fullscreen mode

All this stuff can be done from a separate file as long as you specify the correct bot name.


After some experimentation i discovered that the corpus is not that smart, you can get easily detected by someone who knows how you chat. We could use ListTrainer right?

Heart hell no

You cant anticipate every conversation, it would take you days if not months or years to include every possible use case. So what should do we do? Curse fbchat and chatterbot authors?........Nope

What if we make chatbot take notes silently as we chart. We do the chitty chat chat and chatbot simply learns from the boss. One day when we are confident enough.......We unleash the beast

Until next time. See you next tutorial

Bye bye

Top comments (0)

The AI Brief

AI generated git commit messages

Minimize the struggle of remembering what you just coded. AI-generated commits make it easier to manage projects and keep track of changes. The Nutlope/aicommits project demonstrates how AI can improve commit messages.

I open sourced an AI that creates any UI in seconds

Make AI-generated user interfaces a breeze. This open-source project harnesses the power of generative AI technologies like chatGPT to create versatile, quick, and intuitive UI components.

Use AI to commit like a PRO in 1 second

Upgrade your commit message game with AI. Boost your productivity by using ChatGPT to generate commit messages and avoid context switching. OpenCommit is an open-source library that helps you achieve this easily.

Build your own ChatGPT starter kit

Train AI models on custom data for improved domain-specific knowledge. Combine the power of WebView technologies and this starter kit to train your ChatGPT model on specific websites, allowing for better-optimized outcomes.