March 3, 2020 By Kazuki Nobutani 3 min read

Part 3 of a four-part series. In this post, we are going to create a process flow in Node-RED and integrate with watsonx Assistant Q&A.

Step 1. Launch Node-RED

  1. Open your Node-RED app on the IBM Cloud dashboard and click Visit URL.
  2. Initially, it will show setup screens. Set up your user name and password, if necessary.
  3. Click Go to your Node-RED flow editor.

Step 2. Connect to watsonx Assistant

Let’s try connecting to your watsonx Assistant (see Part 2 of this series: “Configure watsonx Assistant to process simple Q&A.”)

  1. Expand the top right menu and click Import.
  2. Copy and paste the contents of the following text file and click Importnode_red_watson_test.txt 
  3. Let’s get the credentials of watsonx Assistant. Open the service and the assistant you created.
  4. From the top right menu, click on Settings.
  5. Open API Details and get your Assistant ID and Api Key.
  6. Enter the ID and key in the assistant V2 node and click Deploy. You can leave Username and Password blank.

Let’s see if it can connect. Click inject, which sends an empty string. If it goes successfully, a response from your assistant will be shown in the right debug tab. 

Step 3. Understand the flow

Now, we are going to create an http endpoint in Node-RED so that external applications can connect to the watsonx Assistant. When you import the json below using the same steps, you will have the following flows. Make sure you enter Assistant ID and Api Key again: node_red_watson_bot.txt

/talk flow:

  1. /talk is called and it accepts user input.
  2. See if the session already started or not.
  3. Pass the user input to Watson.
  4. Set session ID to continue the conversation with Watson.
  5. Respond.

/clear flow: 

  1. /clear is called by an user.
  2. Clears the session ID stored.

What’s next?

In the final part of this blog series, we are going to integrate with Slack. However, please note that you can connect to the endpoint we created in this part from any app or service. On top of that, you can customize the flow however you want. 

Here are partial examples of how you can expand:

  • Modify input from a user using function node
  • Modify responses from watsonx Assistant using function node before passing it back to users 
  • Import other nodes to integrate with other services
  • Integrate with other Watson services 
  • Integrate with OpenWhisk

In fact, Node-RED is essentially a NodeJS application, so you can create a similar or better feature using it. 

Disclaimer

IBM is not liable for any damages arising in contract, tort or otherwise from the use of or inability to use this post or any material contained within. All sample code is provided as-is and IBM does not support customization. Do not use the code in production. 

Was this article helpful?
YesNo

More from Cloud

New 4th Gen Intel Xeon profiles and dynamic network bandwidth shake up the IBM Cloud Bare Metal Servers for VPC portfolio

3 min read - We’re pleased to announce that 4th Gen Intel® Xeon® processors on IBM Cloud Bare Metal Servers for VPC are available on IBM Cloud. Our customers can now provision Intel’s newest microarchitecture inside their own virtual private cloud and gain access to a host of performance enhancements, including more core-to-memory ratios (21 new server profiles/) and dynamic network bandwidth exclusive to IBM Cloud VPC. For anyone keeping track, that’s 3x as many provisioning options than our current 2nd Gen Intel Xeon…

IBM and AWS: Driving the next-gen SAP transformation  

5 min read - SAP is the epicenter of business operations for companies around the world. In fact, 77% of the world’s transactional revenue touches an SAP system, and 92% of the Forbes Global 2000 companies use SAP, according to Frost & Sullivan.   Global challenges related to profitability, supply chains and sustainability are creating economic uncertainty for many companies. Modernizing SAP systems and embracing cloud environments like AWS can provide these companies with a real-time view of their business operations, fueling growth and increasing…

Experience unmatched data resilience with IBM Storage Defender and IBM Storage FlashSystem

3 min read - IBM Storage Defender is a purpose-built end-to-end data resilience solution designed to help businesses rapidly restart essential operations in the event of a cyberattack or other unforeseen events. It simplifies and orchestrates business recovery processes by providing a comprehensive view of data resilience and recoverability across primary and  auxiliary storage in a single interface. IBM Storage Defender deploys AI-powered sensors to quickly detect threats and anomalies. Signals from all available sensors are aggregated by IBM Storage Defender, whether they come…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters