How do I use a Watson Conversation service in Frankfurt using Node-RED or the node-sdk for Watson?

独自空忆成欢 提交于 2019-12-12 19:16:00

问题


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.



来源:https://stackoverflow.com/questions/44249910/how-do-i-use-a-watson-conversation-service-in-frankfurt-using-node-red-or-the-no

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!