【问题标题】:IBM Watson Conversation - Unable to connect node.js to watson conversationIBM Watson Conversation - 无法将 node.js 连接到 watson 对话
【发布时间】:2017-06-01 13:12:01
【问题描述】:

我在使用 IBM Watson 对话应用程序时遇到问题。

我设置了我的应用程序并尝试将其连接到我的 node.js 应用程序。我在这里学习本教程: https://github.com/watson-developer-cloud/node-sdk#conversation 我正在使用 ibm 提供的官方 node.js api。

不幸的是,它不起作用,我收到以下错误。

{ Error: Not Authorized
    at Request._callback (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/lib/requestwrapper.js:87:15)
    at Request.self.callback (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Volumes/hd2/Projekte/vi-com-bot-service/node_modules/watson-developer-cloud/node_modules/request/request.js:1091:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)
  code: 401,
  error: 'Not Authorized',
  description: '2017-06-01T08:57:57-04:00, Error ERCDPLTFRM-DNLKUPERR occurred when accessing https://gateway.watsonplatform.net/conversation/api/v1/workspaces/dc8097e8-fea7-47a3-80ed-57c43321377e/message?version=2017-04-21, Tran-Id: gateway-dp01-2475007148 - Invalid UserId and/or Password. Please confirm that your credentials match the end-point you are trying to access. A common error is trying to use credentials from an experimental or beta release against a GA release or vice versa' }

我提供的凭据是正确的。

你有什么想法,为什么我不工作? 最好的,本

【问题讨论】:

标签: node.js ibm-watson watson-conversation


【解决方案1】:

Bluemix 有许多可以托管服务的区域。每个区域都有不同的网关。默认为https://gateway.watsonplatform.net

对于德国 + 法国地区,您可以在代码中设置以下 URL 变量:

url: 'https://gateway-fra.watsonplatform.net/conversation/api/'

像这样:

var conversation = new ConversationV1({
  username: '<username>',
  password: '<password>',
  url: 'https://gateway-fra.watsonplatform.net/conversation/api/',
  version_date: ConversationV1.VERSION_DATE_2017_05_26
});

对于其他地区,您可以进入 Watson 对话服务凭证以查看 URL。或者对话工作区“部署”然后是“凭据”部分。

这是针对 Watson Assistant 的修订版 IBM Cloud API 的链接,包括 node.js 的代码示例和 URL 列表(请参阅“服务端点”)。

【讨论】:

    【解决方案2】:
    var ConversationV1= require('watson-developer-cloud/conversation/v1');
        var conversation = new ConversationV1({
            username:'<username>',
            password: '<Password>',
        version_date: 'Date'
    });
    conversation.message({
      workspace_id:'<Workspace Id>',
                context: userContext,
                input: {
                "text": "<text>"
                    }
    },function(err,resp){
    
    });
    

    【讨论】:

    • 感谢您提供此代码 sn-p,它可能会提供一些有限的即时帮助。 proper explanation 将通过展示为什么这是解决问题的好方法,并使其对有其他类似问题的未来读者更有用,从而大大提高其长期价值。请edit您的回答添加一些解释,包括您所做的假设。
    猜你喜欢
    • 2017-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多