Sponser Link

Create a chatbot in python from scratch by using NLP nltk

What is Chatbot

Chatbot is a software or computer program which can conversation with user on chat and able to answer of user queries by using artificial intelligence algorithm.

Chatbot Source code - Step by Step

In this article you will learn that how you can build a simple chatbot using nltk in python. After execute this code in python console, you will give input that “my name is ayaz”. This will give answer according to our pair description.

from nltk.chat.util import Chat, reflections

pairs = [


        r"my name is (.*)",

        ["Hello %1, How are you today ?",]



def MyChatbot_test():

    print("Hi, I am your chatbot.")

    chatbot=Chat(pairs, reflections)


    if __name__ == '__main__':