[Technical Teaching] Create a chatbot for investment management that is yours

Contents   
1. Overview2    
. Preliminary    
work3. Creating Chatbot operation process3.1    
. Logging in to IBM Cloud platform3.2    
. Creating Watson Conversation service3.3    
. Creating Cloudant service3.4    
. Creating Investment Portfolio     service3.5
. Creating Simulated Instrument Analytics     service3.6
. Local development and debugging chatbot application    
3.7. Deploy chatbot application to IBM Cloud platform    

1 Overview

Chatbots are fast gaining acceptance as the standard for all kinds of customer interactions. In this developer learning journey, you will create a Watson Conversation-based chatbot that enables you to query portfolios and related properties using the Investment Portfolio service. You will use the Simulated Instrument Analytics service to perform computational analysis of securities in a given scenario, and learn how to switch between the standard web interface and the Twilio interface.

After completing this learning journey, you will know how to:

 Create chatbot conversations using Watson Conversation
 Set up multiple interfaces to interact with the Watson Conversation bot: Web and Twilio
 Access the Investment Portfolio service, pick seed data and send them to the service
 Send the data and a scenario to Simulated Instrument Analytics Services to retrieve analysis results


2. Preliminary preparations

Create a bluemix account ( click to register )
Familiar with Cloud Foundry and Node JS
Familiar with creating applications on Bluemix and connecting services for applications


 Install NodeJS natively

Windows:https://nodejs.org/dist/v8.9.0/node-v8.9.0-x64.msi

MacOS: https://nodejs.org/dist/v8.9.0/node-v8.9.0.pkg

Linux: https://nodejs.org/dist/v8.9.0/node-v8.9.0-linux-x64.tar.xz


 Install the Bluemix cli command-line tool
on your computer. Download address of Bluemix cli:

Windows:https://plugins.ng.bluemix.net/download/bluemix-cli/0.6.0/win64

Linux:https://plugins.ng.bluemix.net/download/bluemix-cli/0.6.0/linux64

MacOS: https://plugins.ng.bluemix.net/download/bluemix-cli/0.6.0/osx

 Native installation of curl tool
Windows: http://curl.haxx.se/download/curl-7.33.0-win64-ssl-sspi.zip

Linux & MacOS system comes with


Download the practice code and the latest js file

https://pan.baidu.com/s/1jIIfT1k

https://github.com/zhangyanfa/personal-wealth-portfolio-mgt-bot/blob/master/lib/controller.js


3. Create Chatbot operation process

3.1. Log in to the IBM Cloud platform


   1. Log in to the IBM Cloud platform, https://console.bluemix.net/

3.2. Create the Wastson Conversation service


   2. Click "Catalog" in the upper right corner, click "Watson" in the left menu, and click "Conversation"

   3. Enter the service name and click Create


   4. After the creation is successful, enter the Conversation management interface

Click "Service Credentials" on the left, and write down the username and password of the Conversation service credential Note: Local development and debugging code will be used


   5. Click "Manage" on the left, click "Launch tool" on the right, and then open a new page to display the Wastson Conversation platform

   6. Click the arrow icon above, click "Choose File" in the pop-up window, find workspace.json in the resource directory in the local NodeJS project directory and add it, click the "Import" button
Note: Download the NodeJS project provided in the chapter address

   7. In this way, a dialogue scene that has been trained in advance is imported into Conversation


   8. Click the "Waston Conversation" link above, then click the icon, click "View Details" in the pop-up menu, and click the icon again to copy the "Workspace ID" to the clipboard
Note: Save the "Workspace ID" , this ID will be used in local development and debugging

   9. To learn the design of Conversation's dialogue scene in detail, please refer to the online documentation and Demo, and go back to
the management page of the Conversation service to find the corresponding link.

3.3. Create Cloudant service


   10. Go back to the IBM Cloud platform, click "Catalogs" and then click "Data and Analytics" in the left menu, then click "Cloudant NoSQL DB"


   11. Enter the service name and click Create


   12. On the Cloudant service management page, click "Service Credentials" and write down the url in the credential Note: The url will be used in local development and debugging


3.4. Create Investment Portfolio Service


   13. Go back to the IBM Cloud platform, click on "Catalog", then scroll to the bottom of the page, and click
on the "Bluemix Experimental Services" link

 

   14. Click "Finance" in the left menu, click "Investment Portfolio", then enter the service name, and then click "Create"


   15. On the Investment Portfolio service management page, click "Service Credentials" to save the credential information
Note: This credential information will be used in local development and debugging


3.5. Create the Simulated Instrument Analytics service


   16. Go back to the IBM Cloud platform, click on "Catalog", then scroll to the bottom of the page, then click on the "Bluemix Experimental Services" link


   17. Click "Finance" in the left menu, click "Simulated Instrument Analytics", then enter the service name, and then click "Create".


   18. On the Simulated Instrument Analytics service management page, click "Service Credentials" on the left to save the credential information
Note: This credential information will be used in local development and debugging


3.6. Local development and debugging of chatbot applications

Note: NodeJS needs to be installed on this machine, and download the code of this tutorial
   19. Command to enter the project root directory, download the dependency package in the node js project, and enter the command: npm install

   20. Open manifest.yml and replace the attribute services with the service name you defined when you created the service on the IBM Cloud platform; the attribute name is defined as the name of the application you published. In order to ensure uniqueness, it is best to use your login id as the application name. Suffix, such as: portfolio-chat-{loing id}

 

   21. Open the .env file and edit the following variables, the corresponding values ​​are the values ​​saved in steps 12, 15, and 18

 

CRED_PORTFOLIO_USERID is replaced with the reader.userid of the Investment Portfolio service voucher
CRED_PORTFOLIO_PWD is replaced with the reader.password of the Investment Portfolio service voucher CWRT_PORTFOLIO_USERID
is replaced with the writer.userid of the Investment Portfolio service voucher CWRT_PORTFOLIO_PWD is replaced with the
writer.password of the Investment Portfolio service voucher


   22. Initialize Investment Portfolio data Execute the following 2 lines of commands in the system command line tool,
replace {service-user-id} with the writer.userid of the Investment Portfolio service credential
{service-user_password} with the writer.password of the Investment Portfolio service credential Note: Use the curl tool required to be installed in the second chapter
curl -X POST -u "{service-user-id}":"{service-user_password}" --header 'Content-Type: application/json' - -header 'Accept: application/json' -d '{ "name":"P1", "timestamp": "2017-02-24T19:53:56.830Z", "closed": false, "data": { " manager": "Edward Lam" }}' 'https://investment-portfolio.mybluemix.net/api/v1/portfolios'

curl -X POST -u "{service-user-id}":"{service-user_password}" --header 'Content- Type: application/json' --header 'Accept:application/json' -d '{ "timestamp": "2017-05-05T19:53:56.830Z", "holdings": [ { "asset": "IBM", "quantity": 1500, "instrumentId": "CX_US4592001014_NYQ"}, { "asset": "GE", "quantity": 5000, "instrumentId": "CX_US3696041033_NYQ" }, { "asset": "F", "quantity": 5000, "instrumentId": "CX_US3453708600_NYQ" }, { "asset": "BAC", "quantity": 1800, "instrumentId": "CX_US0605051046_NYS" } ] }' 'https://investment- portfolio.mybluemix.net/api/v1/portfolios/P1/holdings'

   23. Execute the command in the project root directory to start the node js service, and the port to start the web service is 3000

 

   24. Open the browser and enter: http://localhost:3000/ in the address bar to test according to the prompts

 

3.7. Deploy chatbot application to IBM Cloud platform


   25. Log in to the IBM Cloud platform from the command line to connect to IBM Cloud, enter the command line:
bx api https://api.ng.bluemix.net
Log in to IBM Cloud, enter the command line:
bx login -u <bluemix login email> -o < org id> -s <space name>
deployment, command line input:
bx app push


The following information appears on the command line, the state is the started state, indicating that the application has been deployed and started successfully


   26. Run the test on the IBM Cloud platform
Go back to the IBM Cloud platform, click the menu button in the upper left corner, click "Dashboard", then click the link address of the application in the application list, and then display the dialog information in the newly opened page


 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325475846&siteId=291194637