Sunday, August 25, 2019

ChatBot First

I was working on this blog for some weeks now. This is the most interesting topic or happening hot cake in programming on the event horizon. 

Necessity for today’s business to use chatbots

Due to successful chatbot experience of last few years, small business owners are now using AI technologies to improve their daily operations, interact with customers and increase income.
Lets not bagged down by these technology jargon just start with simple smile and open for learning a few things.   Integration and union of apps from different areas with the help of bots allow companies to introduce their software to a new level. Prosperous experience of Slack, Telegram, Messenger, etc. shows us that AI-based bots will remain in demand even further. Nevertheless, not everything is so smooth, and certain aspects of their use still slow introduction of chatbots into today’s business.
Current Forecasts

In relation to AI future in general and chatbots perspectives in particular, the results of the studies diverge. For instance, according to the Oracle research, 80 percent of surveyed said they are going to implement chatbots for customers support during the next years. At the same time, Forrester published completely different results for AI adoption among interviewed companies: only about 20 percent of them are ready to use AI in general, not just chatbots, for business needs in the coming years. Peak of blind popularity and inflated expectations seems to be left behind, as well as existing obstacles and shortcomings have already arisen in front of developers. And now it’s good time for rise of enlightenment, constructive solutions and productive work.

Advantages and Prospects

The reasons for the increased interest to chatbots are quite obvious. Customer expectations are increasing every day, and along with appearance of new technologies they expect more up-to-date customer service which includes fast and reliable payment operations, rapid processing of orders, easy shopping experience, personal approach to each client and much more. And chatbots can provide this. Here’re only some of their capabilities:

    Chatbots allow to resolve problems more quickly. Working 24/7, they not only let the company save money on round the clock support, but also are always ready to answer customer questions or perform another necessary task. With these many integrations, customers don’t need to wait in line, chatbots are always available to them from anywhere and anytime. According to the Business Insider Intelligence research, use of chatbots for customer service can reduce up to 30% of the company’s costs for communication with customers. In the project management process chatbots can be used to reduce the number of distracting conversations, answers to endless questions, discussions with colleagues, while allowing all members of the team to always keep abreast of developments.
    Chatbots provide personal approach to every customer. The fact is that many employees are not attentive enough to each individual client due to the general load and tiredness, lack of important information and knowledge, or irresponsibility. Chatbots have no such problems. Moreover, they allow to attract clients in a more personalized way. Artificial intelligence and machine learning can be used to generate a complete portrait of the customer, explore his habits and needs, gather purchasing history, form personalized experiences to improve the quality of customer service. If customers have a positive interaction with a company, they are more likely to return. No matter how cool your goods or services are, clients primarily care about how well you treat them. What about project management, chatbots can use collected information about users to automate a lot of tasks related to estimating and tracking time spent on tasks, provide interested project data according to the developer’s current activity and so on.
    Chatbots are also very convenient to use. Due to global integration, they can be always available in any desired application. Chatbots let customers save time and get required help without distracting from their smartphones. For example, if we say about project management tool like Riter, developers can use Slack or Telegram chatbots to create and assign tasks just during their discussion with team members without need to open the Riter application itself.
    Chatbots are easy to create and run. As a rule, you can use provided API to create your own chatbots on a necessary platform or just find somebody who can do this for you. For example, Riter has GraphQL API for integration with existing services. This year we are going to release a platform for writing bots and create the first set of bots for integration with the most popular third-party resources. Riter bot system will be able to provide not less opportunities than Jira plugins do, furthermore, our bots may be written in any language and placed on either our servers or on the client side. Later we plan to open a store of bots, where everyone will be able to add their own bots and get interest from their work. In addition, Riter users will get an ability to create private bots for their personal usage.

The chatbot landscape is changing fast, and all business owners need to keep upwiht it.  Facebook’s recent move to bring augmented reality to chatbots is just the latest adaptation, as this young technology tries to keep up with the blistering pace of communications. Having already tried communicating with emoji and by sharing images, what next for chatbots and what should yours focus on?

Ferris Bueller’s final line, “Life moves pretty fast. If you don’t stop and look around once in a while, you could miss it.” is very apt for technology. The trouble is, companies are so focused on adding new features to keep the headlines rolling, the road map on track and to generate interest that they rarely stop to ask, is this in the end-user or consumer interest?

Addition of Augmented Reality gives a great additional push.  So, we have the latest news from Facebook, from its F8 conference With the embattled company trying to push further into our lives with dating services and other efforts. Trying to bolt another tech poster-child, augmented reality (AR) into Facebook Messenger Chatbots is an exciting, if pushy move.

As ever, a few brands get to play guinea pig with the technology, but soon any brand could be pushing visual augmented messaging. That would be interesting for location-based work (“we’re here” with flashing arrows, or replacing complicated instructions with visual cues!) But, for most chatbots it doesn’t feel like something to get excited about.

In the not too distant future, AR will be relevant in many applications, especially as we move away from smartphones into glasses, micro-headsets, or whatever comes next to help us interact with technology and services. That’s when things may get interesting.

Instead, we’ll probably get mixes of AR’s traditional uses, such as funny faces, overlaying of logos on your world and so on to make a chat more lively. That will appeal to brands with big logos to splash around, perhaps even simple games to play.

Kia as one of the early adopters plans to let its Kian chatbot show users around the new Stinger 2018 model. But that’s something car brand apps have been doing for some time, so its not really new or innovative, just moving a feature from one platform to another.

Still, there’s plenty of news involving AR, almost enough to match chatbots when it comes to vendor and ecosystem excitement. At least some of those features should make bots more interesting to interact with. But the Messenger service already has some eight billion chats across it each month, is there really time to be stopping and staring at AR imagery?

In the few short years of their existence, chatbots have already moved from plain text to buttons, then added image recognition and further interactions, but none of them have threatened to replace text as the key feature.

For most bots, certainly for the next year, there is little need to go overboard on adding AR imagery to a chat. Instead most bot providers like SnatchBot offer what is still exciting and media-friendly services, with photos, video and other elements easy to integrate into any conversation for the best experiences.
When it comes to existing chatbots, what we may see happen is features like AR used to speed up a process that takes time if done by text, so images might augment a series of instructions. For retail brands, the visual impact of a product popping up in a chat might help drive some impulse purchases. Imagine walking past a burger bar and getting a location-based chat pop-up offering you their latest meal and cool drink on a hot day.

These and other ideas will all slowly trickle down into chatbots, and in a few years we may wonder why we ever bothered with text. But for now it remains the dominant force in bots and is all most companies will need to keep their customers engaged.

“Let’s build a Chatbot!” , I am trying to put in a programmers language lets see how successful I am. Chatbots are cool. They are driving the industry like hardly any other topic these days and are considered to be real game changers.

Therefore it’s pretty easy to convince customers to implement a digital assistant. But, it becomes tricky when we’re talking about costs. To give serious numbers, customers have to do their homework first.

Lets collect some data to get started,  first of all, we should investigate all your contact channels looking for the real pain points. Topics to consider are…

    Where are most of the requests coming in?
    Which requests are coming again and again?
    Which of those can be answered using standardized replies?
    And especially, which requests need most resources in your contact center?

In nine out of ten cases our advise is to start with a FAQ bot. The focus is on pain points and cost drivers identified within your contact channels.

So that’s the first milestone: Build a FAQ Chatbot

You shouldn’t necessarily compare a FAQ bot with those often pretty boring Frequently Asked Questions sections on websites. More than that, a FAQ Chatbot could…

    lead customers in a smart dialog to the desired information
    directly link customers to a contact form or similar on your website
    or ask for all the parameters needed according to the users intent and create and assign tickets in your system

How to integrate with Backend Systems?

The next milestone is usually to integrate your Chatbot with your Backend Systems. Technically, that’s usually not a big deal.

Questions to ask are…

  •     what are the most common Use Cases?
  •     which value can be added by standardized replies?
  •     does your Back-end System expose an open interface?

After identifying your Use Cases, you should (especially in Europe) consider GDPR topics. In addition, you usually need some kind of authentication method if your chatbot is dealing with customer related data. It’s always a good idea to include your legal department in this questions.
What should the technical implementation look like?

Now things are getting pretty easy ;). If you can answer all the things above, we can make a reliable recommendation according the technical implementation.

This recommendation will cover…

  •     Input and Output methods used
  •     The Design of the User Interface
  •     The desired User Experience
  •     Training and Testing of your Chatbot
  •     Development technologies and the Toolstack used

Now lets wait for my next blog for actual Chat Bot programming tutorial. Feel free to reach me at ravindrapande@gmail.com for any queries & suggestions.

Building the Bot

Pre-requisites

Hands-On knowledge of scikit library and NLTK is assumed. However, if you are new to NLP, you can still read the article and then refer back to resources.
NLP

The field of study that focuses on the interactions between human language and computers is called Natural Language Processing, or NLP for short. It sits at the intersection of computer science, artificial intelligence, and computational linguistics[Wikipedia].NLP is a way for computers to analyze, understand, and derive meaning from human language in a smart and useful way. By utilizing NLP, developers can organize and structure knowledge to perform tasks such as automatic summarization, translation, named entity recognition, relationship extraction, sentiment analysis, speech recognition, and topic segmentation.
NLTK: A Brief Intro

NLTK(Natural Language Toolkit) is a leading platform for building Python programs to work with human language data. It provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, wrappers for industrial-strength NLP libraries.

NLTK has been called “a wonderful tool for teaching and working in, computational linguistics using Python,” and “an amazing library to play with natural language.”

Natural Language Processing with Python provides a practical introduction to programming for language processing. I highly recommend this book to people beginning in NLP with Python.

Downloading and installing NLTK

    Install NLTK: run pip install nltk
    Test installation: run python then type import nltk

For platform-specific instructions, read here.
Installing NLTK Packages

import NLTK and run nltk.download().This will open the NLTK downloader from where you can choose the corpora and models to download. You can also download all packages at once.
Text Pre- Processing with NLTK

The main issue with text data is that it is all in text format (strings). However, Machine learning algorithms need some sort of numerical feature vector in order to perform the task. So before we start with any NLP project we need to pre-process it to make it ideal for work. Basic text pre-processing includes:

    Converting the entire text into uppercase or lowercase, so that the algorithm does not treat the same words in different cases as different
    Tokenization: Tokenization is just the term used to describe the process of converting the normal text strings into a list of tokens i.e words that we actually want. Sentence tokenizer can be used to find the list of sentences and Word tokenizer can be used to find the list of words in strings.

The NLTK data package includes a pre-trained Punkt tokenizer for English.

    Removing Noise i.e everything that isn’t in a standard number or letter.
    Removing Stop words. Sometimes, some extremely common words which would appear to be of little value in helping select documents matching a user need are excluded from the vocabulary entirely. These words are called stop words
    Stemming: Stemming is the process of reducing inflected (or sometimes derived) words to their stem, base or root form — generally a written word form. Example if we were to stem the following words: “Stems”, “Stemming”, “Stemmed”, “and Stemtization”, the result would be a single word “stem”.
    Lemmatization: A slight variant of stemming is lemmatization. The major difference between these is, that, stemming can often create non-existent words, whereas lemmas are actual words. So, your root stem, meaning the word you end up with, is not something you can just look up in a dictionary, but you can look up a lemma. Examples of Lemmatization are that “run” is a base form for words like “running” or “ran” or that the word “better” and “good” are in the same lemma so they are considered the same.

Bag of Words

After the initial preprocessing phase, we need to transform the text into a meaningful vector (or array) of numbers. The bag-of-words is a representation of text that describes the occurrence of words within a document. It involves two things:
 •A vocabulary of known words.
•A measure of the presence of known words.

Why is it is called a “bag” of words? That is because any information about the order or structure of words in the document is discarded and the model is only concerned with whether the known words occur in the document, not where they occur in the document.

The intuition behind the Bag of Words is that documents are similar if they have similar content. Also, we can learn something about the meaning of the document from its content alone.

For example, if our dictionary contains the words {Learning, is, the, not, great}, and we want to vectorize the text “Learning is great”, we would have the following vector: (1, 1, 0, 0, 1).

And that’s the point, where we can seriously talk about numbers, now lets take a breath and revisit what have we learned till this point.

Now lets wait for my next belog for actual ChatBot programming tutorial. Feel free to reach me at ravindrapande@gmail.com for any queries & suggestions.