How do I use a Watson Conversation service in Fran

2019-07-09 23:25发布

问题:

I'm able to use the node-red-node-watson library to call an instance of Watson Conversation hosted in the US-South region of IBM Cloud. If I try it in the Germany region, it does not work.

In github I spotted the following line

ConversationV1.URL = 'https://gateway.watsonplatform.net/conversation/api';

which is the URL for Conversation in US-South. The URL shown in Bluemix VCAP_SERVICES for the Frankfurt instance is different:

 "https://gateway-fra.watsonplatform.net/conversation/api"

I'm not sure if the hard-coded URL is just a default and I just missed the code reading the actual URL from VCAP_SERVICES or if this is actually a bug.

Has somebody successfully used the Node-RED node for Watson Conversation within a region other than US-South?

回答1:

When you initialize the Conversation object it should be possible to set the correct base URL. This is for Node SDK, not Node-RED:

// Create the service wrapper
var conversation = new Conversation({
   username: '<username>',
   password: '<password>',
   url: 'https://gateway-fra.watsonplatform.net/conversation/api',
  version_date: Conversation.VERSION_DATE_2017_04_21
});

I more familiar with the Python SDK and there the same (only in Python :) is working successfully for me.

For Node-RED there are two scenarios. When the Conversation service is bound to the Node-RED app, then the credentials including URL are taken from the VCAP environment. This works for me and should for you. If the service is not bound then there is a "feature gap" based on the Conversation Node source code.