watson-developer-cloud / node-red-node-watson

A collection of nodes for the IBM Watson services
Apache License 2.0
82 stars 86 forks source link

Conversation Workspace Manager node updateDialogNode function not working #357

Closed tim-minter closed 6 years ago

tim-minter commented 6 years ago

Hi, I can't get the Conversation Workspace Manager node to work in updateDialogNode mode. I have resorted to using the updateWorkspace function, which works fine in the same flow. Setting a dialog node ID in the node properties or via the flow results in an error "Missing required parameters: dialog_node".

This is the flow I'm using [{"id":"1e56e778.8e7341","type":"ibmiot in","z":"b8987172.3f1f58","authentication":"boundService","apiKey":"","inputType":"evt","deviceId":"MossSensor","applicationId":"","deviceType":"+","eventType":"+","commandType":"","format":"text","name":"IBM IoT","service":"registered","allDevices":"","allApplications":"","allDeviceTypes":true,"allEvents":true,"allCommands":"","allFormats":true,"qos":0,"x":150,"y":380,"wires":[["204dd6df.b25ca2"]]},{"id":"6c48c558.0b9ddc","type":"function","z":"b8987172.3f1f58","name":"Moisture","func":"if(msg.payload.moisture){\n var moisture = msg.payload.moisture;\n msg.topic = \"Moisture\";\n msg.payload = moisture;\n global.set(\"moisture\",moisture);\n return msg;\n}\n","outputs":1,"noerr":0,"x":500,"y":380,"wires":[["7351e473.a9eaa4","549be952.4a32c"]]},{"id":"95b94747.239b68","type":"function","z":"b8987172.3f1f58","name":"Temperature","func":"if(msg.payload.temperature){\n var temperature = msg.payload.temperature;\n msg.topic = \"Temperature\";\n msg.payload = temperature;\n global.set(\"temperature\",temperature);\n return msg;\n}\n","outputs":1,"noerr":0,"x":510,"y":420,"wires":[["7351e473.a9eaa4"]]},{"id":"f680825b.4942a8","type":"function","z":"b8987172.3f1f58","name":"Humidity","func":"if(msg.payload.humidity){\n var humidity = msg.payload.humidity;\n msg.topic = \"Humidity\";\n msg.payload = humidity;\n global.set(\"humidity\",humidity);\n return msg;\n}\n","outputs":1,"noerr":0,"x":500,"y":460,"wires":[["7351e473.a9eaa4"]]},{"id":"722cec5f.40011c","type":"debug","z":"b8987172.3f1f58","name":"","active":true,"console":"false","complete":"true","x":1350,"y":740,"wires":[]},{"id":"2c6bb8d6.231eb8","type":"function","z":"b8987172.3f1f58","name":"Set Dialog ID and Humidity dialog","func":"//msg.dialog_node=\"node_3_1514055634494\";\n//msg.payload.dialog_node=\"node_3_1514055634494\";\n//msg.params.dialog_node=\"node_3_1514055634494\";\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":640,"wires":[["2c97d656.a340d2","db43c522.61f008"]]},{"id":"549be952.4a32c","type":"template","z":"b8987172.3f1f58","name":"format json payload with data","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"output\": {\n \"text\": {\n \"values\": [\"the humidity here is {{payload}}\"],\n \"selection_policy\": \"sequential\"\n },\n \"humidityQuery\": true\n }\n}\n","output":"json","x":530,"y":640,"wires":[["5f7a80f7.bd671","2c6bb8d6.231eb8"]]},{"id":"a2874c05.f005f","type":"inject","z":"b8987172.3f1f58","name":"Test Trigger","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":250,"y":640,"wires":[["549be952.4a32c"]]},{"id":"7351e473.a9eaa4","type":"debug","z":"b8987172.3f1f58","name":"","active":false,"console":"false","complete":"false","x":870,"y":420,"wires":[]},{"id":"5f7a80f7.bd671","type":"debug","z":"b8987172.3f1f58","name":"","active":true,"console":"false","complete":"payload","x":710,"y":820,"wires":[]},{"id":"204dd6df.b25ca2","type":"delay","z":"b8987172.3f1f58","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"15","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":320,"y":380,"wires":[["6c48c558.0b9ddc","95b94747.239b68","f680825b.4942a8"]]},{"id":"2c97d656.a340d2","type":"debug","z":"b8987172.3f1f58","name":"","active":true,"console":"false","complete":"false","x":1090,"y":820,"wires":[]},{"id":"db43c522.61f008","type":"watson-conversation-v1-workspace-manager","z":"b8987172.3f1f58","name":"Mossy","cwm-custom-mode":"updateDialogNode","cwm-workspace-id":"3ba5476b-90a4-4795-9af8-3bf5d1cf930a","cwm-intent":"","cwm-example":"","cwm-entity":"","cwm-entity-value":"","cwm-dialog-node":"node_3_1514055634494","cwm-export-content":false,"cwm-default-endpoint":true,"cwm-service-endpoint":"https://gateway.watsonplatform.net/conversation/api …","x":1170,"y":640,"wires":[["722cec5f.40011c"]]},{"id":"cffc1878.996f68","type":"inject","z":"b8987172.3f1f58","name":"Simplest Test Trigger","topic":"","payload":"{\"output\":{\"text\":{\"values\":[\"the temperature here is 21C\",\"near my pot it is 21C\",\"around me it is 21C\",\"in this bit of the room it is 21C\"],\"selection_policy\":\"random\"},\"temeratureQuery\":true}}","payloadType":"json","repeat":"","crontab":"","once":false,"x":270,"y":840,"wires":[["db43c522.61f008"]]}]

chughts commented 6 years ago

I have just tried this using my test set of nodes, and the update dialog mode is working. This is a subset of the test:

[{"id":"15f61557.d43ceb","type":"inject","z":"797450ac.3abb4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":129,"y":181,"wires":[["744b6bb1.e55874"]]},{"id":"744b6bb1.e55874","type":"watson-conversation-v1-workspace-manager","z":"797450ac.3abb4","name":"List Dialog Nodes","cwm-custom-mode":"listDialogNodes","cwm-workspace-id":"eb866cb6-9885-4c7b-91d7-938b4e4de1ae","cwm-intent":"","cwm-example":"","cwm-entity":"","cwm-entity-value":"","cwm-export-content":false,"cwm-default-endpoint":true,"cwm-service-endpoint":"https://gateway.watsonplatform.net/conversation/api","x":305,"y":178,"wires":[["6c678f5e.eec6d"]]},{"id":"6c678f5e.eec6d","type":"link out","z":"797450ac.3abb4","name":"","links":["659fc7ce.615878"],"x":457,"y":176,"wires":[]},{"id":"659fc7ce.615878","type":"link in","z":"797450ac.3abb4","name":"Conv Workspace Debugger","links":["cb52a33c.5b676","4ced947b.077d2c","dd260d31.c45ea","8bac13f7.76863","63f95762.684008","fcbc589.0bfd5a8","61e0e75f.aea5a8","d745dc1a.cd334","6ed36817.5acd68","4e19d962.e3d928","26cc9aa7.5fc786","19b7a069.2885","3be2fec1.bc46e2","9318369f.3d1f28","a11e351.364adc8","ee2dccfb.d99da","f1c311e4.e8485","8530a5bc.b80248","7c778b92.0e3d64","1cb9702b.755b5","944a035.4037d","25e83ebb.519c12","fdf2dbef.55b128","56420a78.bd17f4","b4a9a257.58db7","943b9acf.786448","fd4ed659.9b5138","b0f2761.f09ec88","3845fc46.631444","6c678f5e.eec6d","18c2cc4e.03b014","dc12a412.d14098","d5d9918f.230f3","f756104.9cabbf","817c31d8.1b6d"],"x":222,"y":354,"wires":[["43860a65.c327d4"]]},{"id":"43860a65.c327d4","type":"debug","z":"797450ac.3abb4","name":"","active":true,"console":"false","complete":"true","x":339,"y":354,"wires":[]},{"id":"3cf4063f.29e3ea","type":"inject","z":"797450ac.3abb4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":127,"y":218,"wires":[["7be55efb.3bcec"]]},{"id":"7be55efb.3bcec","type":"watson-conversation-v1-workspace-manager","z":"797450ac.3abb4","name":"Get Dialog Node","cwm-custom-mode":"getDialogNode","cwm-workspace-id":"eb866cb6-9885-4c7b-91d7-938b4e4de1ae","cwm-intent":"","cwm-example":"","cwm-entity":"","cwm-entity-value":"","cwm-dialog-node":"node_10_1472224381261","cwm-export-content":false,"cwm-default-endpoint":true,"cwm-service-endpoint":"https://gateway.watsonplatform.net/conversation/api","x":304,"y":221,"wires":[["18c2cc4e.03b014"]]},{"id":"18c2cc4e.03b014","type":"link out","z":"797450ac.3abb4","name":"","links":["659fc7ce.615878"],"x":454,"y":219,"wires":[]},{"id":"49c82166.c7d0f","type":"fileinject","z":"797450ac.3abb4","name":"","x":123,"y":255,"wires":[["4f7cc8c3.29ca38"]]},{"id":"4f7cc8c3.29ca38","type":"watson-conversation-v1-workspace-manager","z":"797450ac.3abb4","name":"Update Dialog Node","cwm-custom-mode":"updateDialogNode","cwm-workspace-id":"eb866cb6-9885-4c7b-91d7-938b4e4de1ae","cwm-intent":"","cwm-example":"","cwm-entity":"","cwm-entity-value":"","cwm-dialog-node":"node_10_1472224381261","cwm-export-content":false,"cwm-default-endpoint":true,"cwm-service-endpoint":"https://gateway.watsonplatform.net/conversation/api","x":312,"y":259,"wires":[["dc12a412.d14098"]]},{"id":"dc12a412.d14098","type":"link out","z":"797450ac.3abb4","name":"","links":["659fc7ce.615878"],"x":455,"y":260,"wires":[]}]

and the json update:

{ "title": "PaymentCheck", "output": {"text": "What is payment method?"}, "parent": "node_5_1472215701009", "context": null, "next_step": null, "conditions": "@contact:address", "dialog_node": "node_10_1472224381261", "previous_sibling": null }

chughts commented 6 years ago

OK, I think I got this. Two dialog node IDs are required for an update, the old existing one, and the new post update one. They can be the same value. So two dialog_nodes values need to be provided. The existing one, is the one that is provided on the node properties. The new one is the one that is provided in the .json.

Neat flow BTW.