DB Integration to Chatbot

A database is an organized collection of data, generally stored and accessed electronically from a computer system. Where databases are more complex they are often developed using formal design and modeling techniques. In this session, Watson assistant is integrated with Cloudant DB and DB2 to get data from the databases.

IBM Watson IOT ChatBot

627 Views, 13 Nov 2018 02:10 pm

Description


The restaurant chatbot gives a static response from the dialog node.

Now let’s integrate the chatbot to Database and get bot response from Database

Step -1– Go to Dashboard and Open existing Cloudant Db service




Step -2– Click on “LAUNCH” to launch the dashboard of Cloudant NoSQL DB



 

Step -3– This is the typical Dashboard of IBM Cloudant NoSQL DB




Step -4– Click on 2nd option “Databases” to launch your databases list




Step -5– Click on “Create Database”, give a name to your Database and click on Create




Step -6– Click on “All Documents ” to get the data stored on Database




Step -7– Click on Create document to create a sample data about offers




Step -8– Give the “_id” as offers




Step -9 – Enter a sample Data about offers as shown below  and click on “Create document”




Step -10 – Sample data about offers is created




Step -11 – Go to Assistant tool, go to dialog and open Enquiry node edit window




Step -12 – As we have given a static response in offers condition, now let’s get the response from the Cloudant DB.




Step -13 – So, change the static response to “offers” as shown below because our cloudant data id is “offers” data id is “offers”




Step -14 – Go to NodeRed service




Step -15 – Drag cloudant node from the storage section  




Step -16 – Double-click on cloudant node, give the database name, let the remaining on cloudant node, give the database name, let the remaining node, give the database name, let the remaining properties are the default and click on done.




Step -17 – Search for switch node and drag the switch node from the function section  




Step -18 – Double-click on the Switch node




Step -19 –   Enter the first condition as shown below and click on “+add” to add the second condition




Step -20 – Select the second condition as “otherwise” and click on Done






Step -21 – Connect the output of “Parsing” function node to the input of “switch” node, first condition switch node output to cloudant node, cloudant node output to debug node and second condition switch node output to the input of ”Bot” text node.




Step -22 –Click on deploy to save the flow




Step -23 – Go to the Restaurant website and ask for offers and observe the bot response




Step -24 – Go to node red editor and observe the data retrieved from the cloudant DB in debug tab.




Now we have to parse the JSON data retrieved from the cloudant DB and replace the existing bot response for offers condition with data from Cloudant DB


Step -25 – Drag function node on to the flow and double-click on it.




Step -26  Give a name to function node, Write the JSON parsing code as shown below based on the data from Cloudant DB and Click on Done.  




Step -27 – Connect the output of Cloudant DB node to Input of function node and output of function node to the input of “Bot” text node as shown below and click on Deploy. 




Step -28   Go to the Restaurant website and ask about offers to Chatbot and observe the bot response which is retrieved from Cloudant DB based on the user question.  



                                                                                

In the next lab, we will integrate Watson Assistant Restaurant Chatbot to DB2         


Step -1 – Login to IBM Cloud and go to the catalog     




Step -2 – Go to “Databases” and open “DB2” service  




Step -3 – Give a service name and click on Create  




Step -4 – Click on “Open Console” to launch “Db2”.  




Step -5 – Open Navigation pane on a top left corner   




Step -6 – Open Explore to create a Tabel   




Step -7 –   Select the default Schema




Step -8 – Click on “New Table ” to create a new table  




Step -9 – Give a name to the table, enter the schema as shown below  and click on Create




Step -10 –Table is created as shown below




Step -11  Go to navigation pane and open “RUN SQL” 




Step -12 – Enter the SQL Query as shown below 




Step -13 – Go running and Select “Run all” 




Step -14 – Once you run the query, the following statement will be printed    



Step -15 – Go to explore and click on View Data 



Step -16 – Data will be added as shown below 




Step -17 – Drag dashDB node from the storage section on to the flow and double click on it 




Step -18  – Click on the edit option to add the dashDB Configuration     




Step -19  – We have to add the credentials of Db2 service here



Step -20 –  Go to service credentials of DB2 service       




Step -21 – Click on “View credentials” and copy the service credentials in the Db2 node




Step -22 – After coping all the information click on Add 




Step - 23  – In query add the following statement (select * from <Enter your Table Name> where COL1='offers') and click on Done 




Step -24 – Drag a function node, double-click on it and enter the JSON parsing code as shown below and click on done 




Step -25 –  Connect the output of first condition switch node to the input of dashDB node and output of dashDB node to input of DB parsing function node and output of function node to “Bot” text node input 




Step - 26   Go to the Restaurant website and ask about offers to Chatbot and observe the bot response which is retrieved from DB2 based on the user question. 




 






Latest IOT Projects
IoT Bootcamp From Sept 2
IoT Analytics Bootcamp From Aug 5
MQTT and CoAP Training From Aug 29
ThingWorx Training From Aug 24
Communication Protocols Training Coming Soon
IOT Development Kits
IoT Bootcamp From Sept 2
IoT Analytics Bootcamp From Aug 5
MQTT and CoAP Training From Aug 29
ThingWorx Training From Aug 24
Communication Protocols Training Coming Soon
Adds Here Adds Here Adds Here

TESTIMONIALS

Sowmya Kambampati
KONY India Pvt Ltd, as a Associate Software Engineer
Ratings :
Review:

I am very thank full to you all for giving such a great training and opportunity to explore my ideas in the stream of IoT, started with a 2 week workshop, very well Hands-on session ever had before...

Poorna prudhvi
Associate Software Engineer in mroads Pvt Ltd
Ratings :
Review:

I interned at smart bridge it's on a mission to become the power House of IOT.The work here is innovative and colleagues are very friendly.i would definitely recommend smart bridge to be a part of you..

P. Sai Teja
System engineer in IBM
Ratings :
Review:

I have done my project and Iot training at Smart Bridge Technologies based on which I got placed in IBM as a system engineer. I am very thankful that i have found my way to build my career further. Th..

Revathi Dhage.
Intern
Ratings :
Review:

The Project was developed in time, and it was appreciated .Many small details were covered well, and proved to be distinguishing points to the project.The concerned mentor, Sandeep Doodigani, has been..