0

node-red と Watson の Conversation サービスで Slack Bot を作りたいです。これは私のコードです:

    [
   {
      "id":"92984fcb.13597",
      "type":"http in",
      "z":"f83b7887.f92208",
      "name":"watson slack",
      "url":"/watson-rg-1",
      "method":"post",
      "swaggerDoc":"",
      "x":96,
      "y":116.35000610351562,
      "wires":[
         [
            "119d86bd.3ce22d"
         ]
      ]
   },
   {
      "id":"19d684b0.ceb487",
      "type":"http request",
      "z":"f83b7887.f92208",
      "name":"slack response",
      "method":"POST",
      "ret":"txt",
      "url":"https://hooks.slack.com/services/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",
      "tls":"",
      "x":782,
      "y":126.58999633789062,
      "wires":[
         [

         ]
      ]
   },
   {
      "id":"119d86bd.3ce22d",
      "type":"switch",
      "z":"f83b7887.f92208",
      "name":"Command parser",
      "property":"payload.text",
      "propertyType":"msg",
      "rules":[
         {
            "t":"regex",
            "v":"^!coin",
            "vt":"str",
            "case":false
         },
         {
            "t":"else"
         }
      ],
      "checkall":"true",
      "outputs":2,
      "x":148,
      "y":203.27999877929687,
      "wires":[
         [
            "c1ef9e78.1efb1"
         ],
         [
            "9d1c215b.7e936",
            "1fd76cf2.10950f"
         ]
      ]
   },
   {
      "id":"c1ef9e78.1efb1",
      "type":"function",
      "z":"f83b7887.f92208",
      "name":"real payload filter",
      "func":"return {\n    payload: Math.random() >= 0.5 ? \"heads\" : \"Tails\"\n};",
      "outputs":1,
      "noerr":0,
      "x":416,
      "y":282.2799987792969,
      "wires":[
         [
            "7b8c968d.58d104"
         ]
      ]
   },
   {
      "id":"7b8c968d.58d104",
      "type":"function",
      "z":"f83b7887.f92208",
      "name":"watson slack message",
      "func":"var text = {\n    text: msg.payload,\n    username : \"watson\"\n};\nreturn {\n    payload : JSON.stringify(text)\n};\n",
      "outputs":1,
      "noerr":0,
      "x":644,
      "y":198.27999877929687,
      "wires":[
         [
            "19d684b0.ceb487"
         ]
      ]
   },
   {
      "id":"9d1c215b.7e936",
      "type":"function",
      "z":"f83b7887.f92208",
      "name":"Get user context",
      "func":"msg.payload = msg.payload.text;\nmsg.user = \"toto\";\n//msg.params.context = {};\nreturn msg;",
      "outputs":1,
      "noerr":0,
      "x":332,
      "y":448,
      "wires":[
         [
            "f9fc1260.dd5a",
            "446d3ae.e966804"
         ]
      ]
   },
   {
      "id":"f9fc1260.dd5a",
      "type":"watson-conversation-v1",
      "z":"f83b7887.f92208",
      "name":"",
      "workspaceid":"",
      "multiuser":false,
      "context":true,
      "x":512,
      "y":448,
      "wires":[
         [
            "d7f5e507.82bf18",
            "c5685f38.2a269"
         ]
      ]
   },
   {
      "id":"d7f5e507.82bf18",
      "type":"function",
      "z":"f83b7887.f92208",
      "name":"Handle response",
      "func":"var user = msg.user;\nvar convContext = flow.get('convContexts')||{};\n\nconvContext[user] = msg.payload.context;\n\nmsg.payload = msg.payload.output.text.join(\"\\n\");\n\nflow.set('convContexts',convContext);\n\nreturn msg;",
      "outputs":"1",
      "noerr":0,
      "x":712,
      "y":448,
      "wires":[
         [
            "7b8c968d.58d104"
         ]
      ]
   },
   {
      "id":"446d3ae.e966804",
      "type":"debug",
      "z":"f83b7887.f92208",
      "name":"getUserCtx",
      "active":true,
      "console":"false",
      "complete":"payload",
      "x":505,
      "y":356.5299987792969,
      "wires":[

      ]
   },
   {
      "id":"c5685f38.2a269",
      "type":"debug",
      "z":"f83b7887.f92208",
      "name":"AfterConv",
      "active":true,
      "console":"false",
      "complete":"payload",
      "x":677,
      "y":508.52996826171875,
      "wires":[

      ]
   },
   {
      "id":"1fd76cf2.10950f",
      "type":"debug",
      "z":"f83b7887.f92208",
      "name":"slack payload",
      "active":true,
      "console":"false",
      "complete":"payload",
      "x":135,
      "y":388.5299987792969,
      "wires":[

      ]
   }
]

ノードのスクリーンショット

しかし、私がテストするとき。最初のブランチは機能します (slack と node-red の間のリンクが機能するかどうかをテストするためだけに実行しました) が、もう 1 つのブランチ (会話ノードを使用) は機能しません。

2 つのエラーがあります。

  1. ワトソン会話サービスの呼び出しに失敗しました

  2. エラー: 許可されていません

4

1 に答える 1