How using msg.topic, payload and transcription in compare data in switch node

i am doing my project that are using voice to open the door... so, i need to comapre the voice from microphone and comapre the voice data in database....if same the the it will upload the name data from user table to history table and it have output sound "welcome" , if not same the just output sound sound "access denied" only

so, nowi have problem from the about the message...i very confuse...i don't know i have using correct msg. in compare both data in compare data node (switch node)...

And below is the code in

read voice data node

msg.topic = "SELECT VOICE FROM USER";
return msg; 

upload name data node (have error)

msg.voice = msg.payload;
msg.name = msg.transcription;
//msg.transcription = "SELECT NAME FROM USER WHERE VOICE = msg.name;” 
msg.topic= "INSERT INTO HISTORY (NAME) VALUES( "+ msg.voice+ ");"
return msg;

Below is the complete flow

[{"id":"ee60c3e3.69e03","type":"mysql","z":"98f4cc17.965b","mydb":"7c738c44.e9a364","name":"DB_MYSQL","x":470,"y":100,"wires":[["df7c1555.276f08"]]},{"id":"5d766314.29f91c","type":"function","z":"98f4cc17.965b","name":"read voice data","func":"//data voice from database\nmsg.topic = \"SELECT VOICE FROM USER\";\nreturn msg; \n\n/*var transcription =msg.transcription;//data from microphone (input data)\n\n\nif(topic==transcription){\n    \n    //upload name to history database from user database\n    msg.topic = INSERT INTO HISTORY (NAME) VALUES ('SELECT NAME FROM USER WHERE VOICE = transcription;');\n    \n    //audio sound\n    msg.payload=\"Welcome\";\n    \n    \n}\n\nif(topic!=transcription){\n    \n    //audio sound\n    msg.payload=\"Access Denied\";\n    \n}*/","outputs":1,"noerr":0,"x":400,"y":360,"wires":[["ee60c3e3.69e03","d97fda3c.851438"]]},{"id":"2b9d8dd1.390142","type":"watson-speech-to-text","z":"98f4cc17.965b","name":"","alternatives":1,"speakerlabels":true,"smartformatting":false,"lang":"en-US","langhidden":"en-US","langcustom":"NoCustomisationSetting","langcustomhidden":"","custom-weight":"0.5","band":"NarrowbandModel","bandhidden":"NarrowbandModel","keywords":"","keywords-threshold":"0.5","word-confidence":false,"password":"","apikey":"aEfplzvlM_B8MA01nsDy3fj6b3CnG6dOQEGISr2gHxxk","payload-response":true,"streaming-mode":false,"streaming-mute":false,"auto-connect":false,"discard-listening":false,"disable-precheck":false,"service-endpoint":"https://api.us-south.speech-to-text.watson.cloud.ibm.com/instances/4ec7115d-1cbf-4ac7-b141-9c9a675fbdac","x":160,"y":340,"wires":[["338d77fb.3e9f88","4428ed4a.f322b4"]]},{"id":"9c343afa.80e438","type":"microphone","z":"98f4cc17.965b","name":"","x":110,"y":240,"wires":[["2b9d8dd1.390142"]]},{"id":"338d77fb.3e9f88","type":"debug","z":"98f4cc17.965b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"transcription","targetType":"msg","x":370,"y":280,"wires":[]},{"id":"31544043.a9475","type":"change","z":"98f4cc17.965b","name":"change to welcome","rules":[{"t":"change","p":"payload","pt":"msg","from":"topic","fromt":"msg","to":"Welcome","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":280,"wires":[["96331e85.67521"]]},{"id":"d97fda3c.851438","type":"switch","z":"98f4cc17.965b","name":"compare data","property":"transcription","propertyType":"msg","rules":[{"t":"eq","v":"topic","vt":"msg"},{"t":"neq","v":"toipc","vt":"msg"}],"checkall":"true","repair":false,"outputs":2,"x":640,"y":340,"wires":[["31544043.a9475","e2ee878e.301618"],["fb2abb1b.bb72f8"]]},{"id":"96331e85.67521","type":"ui_audio","z":"98f4cc17.965b","name":"Output sound","group":"826baa0d.4398d8","voice":"en-GB","always":"","x":920,"y":340,"wires":[]},{"id":"fb2abb1b.bb72f8","type":"change","z":"98f4cc17.965b","name":"change to Access Denied","rules":[{"t":"change","p":"payload","pt":"msg","from":"topic","fromt":"msg","to":"Access Denied","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":400,"wires":[["96331e85.67521"]]},{"id":"e2ee878e.301618","type":"function","z":"98f4cc17.965b","name":"upload name data","func":"msg.voice = msg.payload;\nmsg.name = msg.transcription;\n//msg.transcription = \"SELECT NAME FROM USER WHERE VOICE = msg.name;” \nmsg.topic= \"INSERT INTO HISTORY (NAME) VALUES( \"+ msg.voice+ \");\"\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":180,"wires":[["ee60c3e3.69e03"]]},{"id":"df7c1555.276f08","type":"json","z":"98f4cc17.965b","name":"","property":"payload","action":"","pretty":false,"x":650,"y":100,"wires":[["b7baa5b9.4f62a8"]]},{"id":"b7baa5b9.4f62a8","type":"debug","z":"98f4cc17.965b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":100,"wires":[]},{"id":"4428ed4a.f322b4","type":"change","z":"98f4cc17.965b","name":"Transcription","rules":[{"t":"set","p":"payload","pt":"msg","to":"transcription","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":440,"wires":[["5d766314.29f91c"]]},{"id":"7c738c44.e9a364","type":"MySQLdatabase","z":"","host":"165.22.51.44","port":"3306","db":"hireelec_vaes","tz":""},{"id":"826baa0d.4398d8","type":"ui_group","z":"","name":"Default","tab":"1142dd80.c3eec3","disp":true,"width":"6","collapse":false},{"id":"1142dd80.c3eec3","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Can anyone help me

I haven't looked at your flow, but I did notice that you spelled 'topic' wrong in the switch node screenshot. (toipc)

1 Like

You might want to change the 'checking all rules' option to 'stop after first match'

At which node?

the switch node

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.