Skip to main content

Complete On-Premise and Fully Customisable Chat Bot - Part 3 - Communicating to the Agent that has been built

Welcome back Folks !!

In our part 2 we created the Bot Kit server/ Agent that will respond to the hello message with a fallback.

Here we will be looking on how to communicate to the bot on the port 3000 using the web socket client.

Communcation With Bot On 3000 in Websocket.

To test the communication with the bot, temporarily we will use the web socket client plugin that comes as a extension in the Chrome / Firefox  plugin.

Follow the procedure as follows ,

1. Install the Chrome / Firefox from the below links


2. After installing the chrome or Firefox. Google for "Simple Websocket Client for Chrome / Firefox".

3. Open the first link and click on add to chrome.
4. Once if the extension has been added you can see it on the chrome like below

5. click on the simple web socket icon and the client opens as follows.

6. Now in the URL enter as "ws://localhost:3000" and click on the Open button. On Success the button will turn to close or it will alert the error. Ensure that the bot server that we created in the Part 2  is running.

7. In the request Section. paste the following message format and include your message in that.
{
      "type": "message",
      "text": "<user message >",
      "user": "<User name>",
      "channel": "Web",
      "timestamp": "<Date time>"
    }

Example
{
      "type": "message",
      "text": "Hello",
      "user": "Pranav",
      "channel": "Web",
      "timestamp": "Thursday, March 8, 2018 8:06:47 AM"
    }

Click on send button and you should get the reply from the bot as follows.



Hurrah !!! Our Bot in action. Modify the index.js to hear for more messages and play around with it.

In the next tutorial lets use the Natural Language Processing server to handle the message and classify the messages to the intents(Meaning full Category ) and lets create a beautiful conversation between the user and the bot. 

Stay Tuned ... !!  

Comments

  1. Appreciate your support and efforts.

    ReplyDelete
  2. Thank you for the nice article. Can you please provide links to next article to use NLP for message handling ?

    ReplyDelete
    Replies
    1. Thank you so much !! Updated the link to the next

      Delete

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(R.id.main_recycler_view); 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