Creating a REST Api to connect NLU using custom model from WKS
In this flow I create a REST Api to connect to Watson Natural Language Understand, using a custom model from Watson Knowledge Studio.
Details on: https://youtu.be/Nqyd5rJ0KJU (in Portuguese)
[{"id":"3838f8e2.15c778","type":"inject","z":"54297220.345bdc","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Por favor, quero ir de Chapecó direto para Nova York, tem?","payloadType":"str","x":90,"y":60,"wires":[["11ef3acb.4d0c55"]]},{"id":"11ef3acb.4d0c55","type":"function","z":"54297220.345bdc","name":"","func":"msg.nlu_options = \n{\"entity_model\":\"8289a28d-8f5e-4370-9133-00fa884b5467\",\n \"relations_model\":\"8289a28d-8f5e-4370-9133-00fa884b5467\" \n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":60,"wires":[["b2f90ff7.c4d19"]]},{"id":"3e4052f6.5bb30e","type":"debug","z":"54297220.345bdc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":280,"wires":[]},{"id":"b2f90ff7.c4d19","type":"natural-language-understanding","z":"54297220.345bdc","name":"","categories":true,"limitcategories":"3","concepts":false,"maxconcepts":"8","doc-emotion":false,"doc-emotion-target":"","doc-sentiment":true,"doc-sentiment-target":"","entity":true,"entity-emotion":false,"entity-sentiment":false,"maxentities":"50","keyword":false,"keyword-emotion":false,"keyword-sentiment":false,"maxkeywords":"50","metadata":false,"relation":true,"semantic":false,"semantic-entities":false,"semantic-keywords":false,"maxsemantics":"50","limittextcharacters":"0","syntax":false,"syntax-sentences":false,"syntax-tokens-lemma":false,"syntax-tokens-pos":false,"service-endpoint":"","x":480,"y":60,"wires":[["a890f235.ebf3f"]]},{"id":"a890f235.ebf3f","type":"function","z":"54297220.345bdc","name":"","func":"msg.payload = msg.features;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":60,"wires":[["3e4052f6.5bb30e","de5e2331.26782"]]},{"id":"6a51698c.1dfce8","type":"http in","z":"54297220.345bdc","name":"","url":"/nlu","method":"get","upload":false,"swaggerDoc":"","x":130,"y":200,"wires":[["f6a1767a.1a0628"]]},{"id":"de5e2331.26782","type":"http response","z":"54297220.345bdc","name":"","statusCode":"","headers":{},"x":600,"y":280,"wires":[]},{"id":"f6a1767a.1a0628","type":"change","z":"54297220.345bdc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"req.query.texto","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":120,"wires":[["11ef3acb.4d0c55"]]}]