Friday, 30 September 2016

Create a chatbot in python using AIML

In this post, we are going to create an AI-powered chatbot in python using AIML. AIML is Artificial intelligence markup language. A chatbot is that software/ script to which you can talk. It's just like talking to a normal human over the internet. Through ages, chatbot has been evolved in terms of their accuracy. In this, we will use the brain of ALICE, developed by Dr. Wallace.
  1. Install AIML
  2. Download Alice Brain
  3. Group into a single directory
  4. Create a pythonic code to run

Create a chatbot in python

Prior to this step, I'm assuming that you have already worked on python and you know what pip is. Now Installing AIML
sudo pip install aiml
Type the above line inside the console(Terminal/CMD). Download the latest Alice - AIML by clicking here. After downloading extract this zip in a directory (eg: Alice). This is basically the brain of the chatbot. Use the bellow Code snippet to do the rest
import aiml
import os
 
# Create the kernel and learn AIML files
kernel = aiml.Kernel()
kernel.learn('alice/*.aiml')
# Press CTRL-C to break this loop
os.system('clear')
while True:
    x=raw_input('>>')
    y=x.split()
    if 'bye' in y:
        print 'Alice: Tata..'
        break
    else:
        x=kernel.respond(x)
        print 'Alice:',x
Save the above code in the same directory which contains Alice Folder. Very well, now you have created your own chatbot in python using AIML. This is basically an offline chatbot. Liked this post then why don't you share this with your friends.

4 comments:

  1. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Chatbot for beginners

    ReplyDelete
  2. Chatbot for business Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome!

    ReplyDelete
  3. hello!! Very interesting discussion glad that I came across such informative post. Keep up the good work friend. Glad to be part of your net community. business benefits

    ReplyDelete
  4. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. demand gen marketing

    ReplyDelete