Skip to main content

Complete On-Premise and Fully Customisable Chat Bot - Part 4 - Integrating the Natural Language Processor NLP

Welcome back Folks !!

In our part 3 we have seen how to communicate to the bot that we have built. Each and every people would talk the same thing in the different format and on his style. For each response if we start writing the code, Imagine how hard its gonna be.

What can we do for that ?

Natural Language Processor makes it easy to do. NLP is a component that identifies the user conversation and identifies the meaningful context from that.

What NLP is available ?

There are few NLP services like,
1. Dialog flow
2. Luie
3. IBM Voice etc.

But all these are the cloud services and we need to go internet for this. As we speaking about the on premise chat bot we will go for the RASA solution.

What is RASA ?

RASA is a Chatbot server and RASA NLU is the NLP server that comes handy and is built on the python tech stack. Its is a open source and backed by a strong community.

Lets get started with RASA ...

1. Installing the python environment : 

Since we know that the RASA is built on the python tech stack, we need to install the python. To install the python follow the below instructions,

Step 1: Open the respective page for the Operating system of your interest and follow the instruction and install the anaconda with python 3.x (contains most of the packages needed for the RASA)

  • Windows -
  • MacOs -
  • Linux -
Step 2 : Test you Anaconda installation by using "conda list" in the command window.
Step 3 : Test your python using "python -V" command.
Step 4 : let's start installing the RASA NLU server. Open the command prompt and key in the following command 
Step 5 :  RASA NLU used the SpaCy, MITE , SkLearn combinations to server the natural language processing. Most of the cases the combination of the SpaCy and Sklearn will work out. So to install the spacy.

Step 6 : Create a folder called "NLU" inside your bot project. < Revisit this post to see the directory structure >

Step 7: Our NLP processor is a model that learns the experiences from the past data and improves on the accuracy. So we need to provide the data that the user might have spoken for a particular intent of interest. So create the folder inside the NLU folder as data.

Step 8 : Following are the contents of the data folder, rasa_data.json file. The main components of the data file are as follows
Below one is the entire file created for a chinese restaurant use case
If you feel this process of editing the intents and entities are difficult. There is a handy tool at

  • online version :
  • offline tool :
Just upload the file to the online / Offline version and add the intents and entities as shown in the picture below

Step 9: Now your are in the data directory of the RASA project. Come back a step (means to the root directory). Create the .json file and place the below contents.
Step 10:  Now it time to train the model with the data we created. Open the command window in the current directory and run this command "python -m rasa_nlu.train -c config_spacy.json"

Step 11: Once if the command completes successfully, you can see the projects folder getting created. At this point, invoke another command to run the HTTP server "python -m rasa_nlu.server -c config_spacy.json --server_model_dirs=<newly Created folder path>"

Tadaaaa !! the server is up and running. Using the postman hit the below url and see the magic.
http://localhost:3000/parse?q="Hello this is the user response".

The Nlu server should understand this and give you back the JSON object that have the predicted Intent Name. Use this in the chatbot to respond back to the user.


  1. This is really awesome. An excellent step by step guide. I am also looking to use the BotKit for integrating it with Microsoft Teams. Do you have something (blog/github sample) that i can follow?

    1. Thanks Anuj ! Right now I don't have blog for integrating the bot with Microsoft Teams ! I can take this as a topic to help on others. Integrating with Microsoft Teams is a good idea.

  2. Hi Pranav
    That's a very nice piece of article for beginners like us, thanks for that.

    I was able to setup both Bot and NLU server, but the article I think did not cover the integration path between them. Please help us few steps how to integrate


    1. Thank you ! Just noted the missing of linking between the two. I will update this with RASA and BOTKIT linking

  3. You have written that amazingly. One thing i want to know is how to embed code in blog posts like you have done here?

    1. Hi SpaCy with the help of git gist, we can embed the snippet in blogger


Post a Comment

Popular posts from this blog

How to access the each view of item by position in Recycler View in android ?

How to access the each view of item by position in Recycler View in android ? There are some methods to access the view of each item view to change or update the view during the run time. To access the view of the item view , consider the Recycler view as below, RecyclerView mainRecyclerView = (RecyclerView)view.findViewById(; RecyclerAdapter adapter = new RecyclerAdapter(mContext); mainRecyclerView.setAdapter(adapter); main.setLayoutManager(new LinearLayoutManager(mContext));  To access the itemView of each position the following functions can be used,  1. View itemView = mainRecyclerView.getChildAt(positionOfItem);  2. View itemView = mainRecyclerView.findViewHolderForAdapterPosition(Position).itemView;  3. View itemView = mainRecyclerView.findViewHolderForPosition(Position).itemView;  4. Long itemId = mainRecyclerView.getAdapter().getItemId(position);       View itemView = mainRecyclerView.findViewHolderForItemId(itemId);  5. View

A.P.I call or async await not working in Array forEach ?

H ello Readers, Welcome back. You would have wondered why does forEach function on the array does not wait for any asynchronous function even if we provide the async await in the node js. If you are the person, wondered about this ever, this post is right for you. Non working example : Lets consider the below snippet, this will not wait for the asynchronous process to wait. I am making a setTimeout to mock the API call async process. This will result the count as, Output : count = 0 OMG !! Why it doesn't work ? Answer probably might be lying inside the Array prototype from JavaScript. Lets take a look inside the "Array.prototype.forEach" function. From the snippet its clear that, the for loop in which they call the callback function does not wait for the asynchronous process to run in the callback. So this forEach is not build for asynchronous process itself. So can't I use forEach any more for running a asynchronous function ? Answer g