Post1

ChatBots (Part 2) – How to make Bots

Posted by

It is said that to explain is to explain away. This maxim is nowhere so well fulfilled as in the area of computer programming, especially in what is called heuristic programming and artificial intelligence…Once a particular program is unmasked, once its inner workings are explained in language sufficiently plain to induce understanding, its magic crumbles away; it stands revealed as a mere collection of procedures, each quite comprehensible. The observer says to himselfI could have written that.”

— Joseph Weizenbaum, ELIZA (1966)

What we should keep in mind before we write a conversational bot?

Domain knowledge should be the first thing to be kept in mind. True artificial intelligence (AI) doesn’t exit. Even the best that can intimate humans, is restricted to subset of topics or conversational gambits. IBM Watson (best AI supercomputer) known for winning Jeopardy knew facts and could construct realistic natural language responses, but it couldn’t schedule your meeting or deliver your groceries. Same is with other renowned chat bots, they only serve to a specific domain; to which they are trained.

Personality, tone or vocabulary bot will employ. Bots have historically been personified as something less than fully human to excuse their rote responses and frustrating lack of comprehension. Often the dual axes of domain and personality align: in the program ELIZA, the domain was a therapy session, and the bot’s personality was that of a Rogerian therapist. Domain and personality don’t necessarily need to be tightly coupled, though—an ecommerce bot needs to know about products, sizing, and order status, but that domain doesn’t imply any particular kind of personality. A shopping bot could have the persona of a helpful person, a cheerful kitten, or have no personality at all.

 

How bots work

Conversational agents or Dialog system, that simulates Intelligent conversation using text or speech, mostly consists of 3 modules.

  1. Data exchange module.
  2. Natural Language Assistance.
  3. Chat bot engine.

2.1

  1. Data exchange Module – Enables interaction between messaging client and bot engine. It could be 2 way hooks or full duplex real time communication channel like WebRTM, websockets or any other. Most of the times, web hooks are used as a medium of data exchange between messaging client and bot.

Transferring the message from messaging client to Chat bot and vice versa are responsibility of Data exchange modules. It’s an inlet and outlet for chat bot application interaction.

Roshan says “hello” to Bot -> Skype (check message is for bot engine ) -> send message to Bot engine listing at webhook (http:/so/so) or RTM (wss:/so/so) [this where data exchange module comes into picture]

Bot Engine processes the request and returns response

Botengine sends message to Roshan -> Skype (message is from Bot to Roshan) -> sends message to Roshan (Bot says “hi”)

 

  1. Natural Language Assistance – this is where the magic lays. It’s a mixture of Natural language processing, Natural language Understanding and Artificial Intelligence.

This is the core of conversational bots. We can build this in 3 major ways.

  1. Build AI of our own – A large amount of human hour and enormous data is needed for Machine Learning. NLP and NLU is another big thing to be taken care of.
  2. 3rd party NLP and NLU powered by AI like Wit.ai, luis and many others.
  3. Hybrid – Wherein we utilize 3rd party api for NLU and NLP and rule engine is built by us.

Rule engine doesn’t mean the use of if and else statement.

A rule engine is all about providing an alternative computational model. Instead of the usual imperative model, commands in sequence with conditionals and loops, it provides a list of production rules. Each rule has a condition and an action – simplistically, you can think of it as a bunch of if-then statements.

– Martin Fowler

 

Simple NLA example –
            # Sentences we’ll respond with if the user greeted us

GREETING_KEYWORDS = (“hello”, “hi”, “greetings”, “hey”, “what’s up”)

 

# Predefined set of responses for specific topic greetings.

GREETING_RESPONSES = [“‘What’s up bro”, “hey”, “hi”]

 

def check_for_greeting(sentence):

“””If any of the words in the user’s input was a greeting, return a greeting response”””

for word in sentence.words:

if word.lower() in GREETING_KEYWORDS:

return random.choice(GREETING_RESPONSES)

 

Its simple implementation where it looks for certain keywords in user utterance and returns, form several predefined responses. In a more complex system, deep neural networks like RNN are used. Even in a generative model, RNN with LSTM has soon great results but not so reliable, this is why we don’t see bots build out of true generative model.

 

  1. Chat bot engine – It converts results form Natural Language Assistance to actions and responses.

NLA provides us with the probability of  intent, entities and different user defined contexts. But the business logic resides in bot engine. That uses those probabilities to determine appropriate response or action.

 

A better understanding can be derived from our next upcoming blog – How we implement Chat bot for IoT Ecosystem.

 

 

 

Related Posts

  • Implementing bot in IoT ecosystemImplementing bot in IoT ecosystem

    What we did... With the help of Hallwaze beat’s RTM api and a bot engine that uses popular Wit.ai for NLU and NLP. We cooked some very interesting bots. We…

  • Implementing Chatbot in IoT Ecosystem (Use-case)Implementing Chatbot in IoT Ecosystem (Use-case)

    In continuation with the Chatbot series, we are back with our next blog on implementing chatbot in IoT ecosystem. Let’s get started. What Did We Do? With the help of…

  • Introduction to Chat bots (Part 1)Introduction to Chat bots (Part 1)

    Chat bots Chat bots are Conversational agents or a Dialog system that simulates Intelligent conversation using text or speech. Why chat bots? In recent times, a sudden rise in interest towards…

  • AI in Banking(2) – ChatbotsAI in Banking(2) – Chatbots

    Hello readers, as promised, we are here with our 2nd blog in the series of blogs on “AI in Banking and Financial Services”, focusing on Chatbots. As discussed in the…

  • A Know-how of Timesheet Management via ChatbotA Know-how of Timesheet Management via Chatbot

    SAP Timesheet Management using Chatbot is an application, which helps users in managing their time entries quickly and efficiently in real-time through mobile phones. Chatbot is an AI-powered computer program…

  • Manager’s Dilema: SAS vs R vs Python

    There are countless articles on this topic already, and I must begin by accepting that I am quite late to this superstar battle. However, every time these champions of analytics…

4 comments

  1. This design is spectacular! You obviously know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!

  2. I just like the valuable info you supply to your articles. I will bookmark your blog and check again here regularly. I’m quite certain I will be told many new stuff proper here! Good luck for the following!

  3. Hello there I am so happy I found your site, I really found you by error, while I was looking on Google for something else, Nonetheless I am here now and would just like to say kudos for a remarkable post and a all round entertaining blog (I also love the theme/design), I don’t have time to go through it all at the minute but I have book-marked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the superb jo.|

Leave a Reply

Your email address will not be published. Required fields are marked *