NODE.JS FRAMEWORK FOR CHATBOT DEVELOPMENT-SAP INTEGRATION
This is the third blog in the series. You can read the first two blogs here. HOW TO ADDRESS YOUR CUSTOMER’S PAIN POINTS INSTANTLY WITH SAP INTEGRATED CHATBOT? and HOW TO ADDRESS YOUR SAP CUSTOMERS PAIN POINTS WITH NLP CHATBOT TOOL? In this blog, we’ll discuss how to use Node.js framework for Chatbot Development – SAP Integration.
It is very evident that Node.js is one the most commonly used framework for developing chatbots. As I am going to integrate SAP with the chatbot, I will be dealing with SAP BAPI’s in this blog. Therefore, we will be seeing how to call a BAPI in node.js which can further act as an API. In the next blog, we will see how this API can be used in the form of a webhook in dialogflow to get relevant data as an automatic response based on user query.
Follow the below steps carefully:
1) First of all, make sure that node.js is installed in your system. Otherwise, you can go to https://nodejs.org/en and download it. We will be using a module called “Node-rfc” to connect the SAP system to the node server. Refer to this link https://www.npmjs.com/package/node-rfc for any details regarding that module.
2) Create a folder with the desired name (saprfc) and copy the code from below link into a .js file with the desired file name(saprfc.js). Refer to the below code.
3) Go to Node.js command prompt, navigate to the created folder and give the command “npm install–save”.
4) After the completion of installation, give the below command.
node saprfc.js (this is my file name, you can give yours).
Refer to the below screenshot for any assistance.Follow the above steps perfectly to get the below output.
Yeah!!! We have successfully connected the SAP system by calling a BAPI in the node code. Wait it’s not yet over, Did we create an intent in dialogflow which would fit with the current scenario. Nooo!!!… So let’s create an intent first. Based on the current scenario, we need to get the name of the plant entered by the user, pass it as an input parameter to the BAPI and return the response to the chatbot.
Ohhh. Wait…before even creating an intent relevant to the current scenario, Let me tell you about a tool named “NGROK” which is required to connect the local node server to the dialogflow.
Ngrok is a fascinating tool which provides a public URL to expose the local server to the internet. It is very helpful in testing chatbots. So just install NGROK and open it. We are running our node server on port 3001.
So just type the below command in the NGROK console.
ngrok.exe http 3001.
It will provide you with an https:// URL which will be used as a webhook in dialogflow.
CREATE AN INTENT:
- Now let’s create an intent in dialogflow with the name purchase_order. Add a training phrase as mentioned below and assign the plant name to an entity @sys.any and give it a name (plant).
- Don’t forget to enable the webhook in the fulfilment section below.
- Now that you are ready with both node code and dialogflow intent, let us include the webhook URL to connect them. Include the NGROK URL in the fulfilment section.
Do you think that this is going to work as expected?? Yeah…..It would work but we have to ensure that by testing the bot. Ok, Let’s take a break and chill!!! We will see how to do this in the next blog. The destination of this blog series is to integrate the bot with a social platform like a messenger. So, I would be covering the messenger integration in the next blog which is going to be the final part of this series.