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

From complexity to clarity: Future pathways for VMware clients

5 min read - Today, VMware clients might be facing transformational decisions amidst an evolving landscape following Broadcom's acquisition of VMware and in search of the best pathways to serve their business needs. However, this process can be complex and challenging, with the potential impacts of choosing the right offerings, adapting to licensing modifications and navigating the partnership impacts. IBM Consulting® can support VMware clients in their transformational journey based on its vast experience of supporting clients through their hybrid cloud estate. IBM Consulting…

Accelerating responsible AI adoption with a new Amazon Web Services (AWS) Generative AI Competency

3 min read - We’re at a watershed moment with generative AI. According to findings from the IBM Institute for Business Value, investment in generative AI is expected to grow nearly four times over the next two to three years. For enterprises that make the right investments in the technology it could deliver a strategic advantage that pays massive dividends. At IBM® we are committed to helping clients navigate this new reality and realize meaningful value from generative AI over the long term. For our…

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 Newsletters

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