-
Notifications
You must be signed in to change notification settings - Fork 2
/
flow_Node-Red.txt
1 lines (1 loc) · 12.8 KB
/
flow_Node-Red.txt
1
[{"id":"b1bb8432.bc7c48","type":"http in","z":"24e72b46.2ac4b4","name":"Conversation - Assistente de Segurança","url":"/botsec2018","method":"get","upload":false,"swaggerDoc":"","x":200,"y":240,"wires":[["b7c3ecee.7da1"]]},{"id":"b7c3ecee.7da1","type":"template","z":"24e72b46.2ac4b4","name":"Conversation BOT Template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <title>\n\t Agente Virtual de Security - BSides SP15 2018\n\t</title>\n\t<link rel=\"stylesheet\"\n type=\"text/css\"\n href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" />\n </head>\n <body>\n\n <div class=\"container-fluid\">\n <div id=\"no-script\"class=\"bg-info\">\n This application needs JavaScript enabled in your browser!\n </div>\n <div id=\"id_contextdump\"></div>\n\n <h1>Agente Virtual de Security - BSides SP15 2018</h1>\n\t <div class=\"alert alert-success\" role=\"alert\" id=id_botchathistory></div>\n\t \n\t <div>\n\t <form>\n\t <div class=\"form-group\">\n \n <label for=\"id_chattext\" class=\"col-sm-2 col-form-label\">Você: </label>\n <div class=\"col-sm-10\">\n <input type=\"text\" name=\"chattext\" id=\"id_chattext\">\n </div>\n \n <br/><br/>\n\t \n\t </div>\n\n\t </form>\n\t <button type=\"button\" class=\"btn btn-primary\" onclick=\"javascript:onChatClick()\">Enviar</button>\n\t </div>\n </div>\n <script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-2.1.4.min.js\"></script>\n <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js\"></script>\n\n <script type=\"text/javascript\">\n \n $(document).ready(function() {\n javascriptCheck();\n \t$('#id_contextdump').hide();\n });\n\n // if javascript is enabled on the browser then can\n // remove the warning message\n function javascriptCheck() {\n $('#no-script').remove();\n }\n \n function createNewDiv(who, message) {\n console.log('002-001'); \n var txt = who + ' : ' + message;\n return $('<div></div>').text(txt);\n }\n\n function chat(person, txt) {\n $('#id_botchathistory').append(createNewDiv(person, txt));\n } \n \n function processOK(response) {\n console.log('003-001');\n console.log(response);\n console.log(response.botresponse.messageout);\n console.log(response.botresponse.messageout.output.text);\n console.log(response.botresponse.messageout.context);\n chat('Agente Virtual', response.botresponse.messageout.output.text); \n $('#id_contextdump').data('convContext', response.botresponse.messageout.context);\n }\n \n function processNotOK() {\n chat('Error', 'Error whilst attempting to talk to Bot');\n }\n \n function invokeAjax(message) {\n var contextdata = $('#id_contextdump').data('convContext');\n console.log('checking stashed context data');\n console.log(contextdata);\n \n \n //var ajaxData = \"msgdata=\" + message;\n var ajaxData = {};\n ajaxData.msgdata = message;\n if (contextdata) {\n ajaxData.context = contextdata; \n }\n\n $.ajax({\n type: 'POST',\n url: 'chatbotsec2018',\n data: ajaxData,\n success: processOK,\n error: processNotOK\n });\n }\n \n // User has entered some text.\n function onChatClick() {\n console.log('001-001');\n var txt = $('#id_chattext').val();\n chat('Você', txt); \n invokeAjax(txt);\n console.log('001-002');\n }\n \n \n </script>\n </body>\n</html>\n","x":560,"y":240,"wires":[["aed8b150.f784"]]},{"id":"aed8b150.f784","type":"http response","z":"24e72b46.2ac4b4","name":"","x":950,"y":240,"wires":[]},{"id":"203ada1a.9121d6","type":"http in","z":"24e72b46.2ac4b4","name":"Conversaton PT-BR REST API","url":"/chatbotsec2018","method":"post","upload":false,"swaggerDoc":"","x":175,"y":289.5234661102295,"wires":[["e4b8cef8.29e94"]]},{"id":"8057add7.66c09","type":"http response","z":"24e72b46.2ac4b4","name":"","x":950,"y":300,"wires":[]},{"id":"e4b8cef8.29e94","type":"function","z":"24e72b46.2ac4b4","name":"Pre Service Processing","func":"flow.set(\"RespostaAssistente\",\"Ok, variavel utilizada\");\n\n// stash away incoming data\nmsg.mydata = {};\nmsg.mydata.messagein = msg.req.body.msgdata;\nmsg.payload = msg.mydata.messagein;\n\nmsg.params = { \"context\": msg.req.body.context};\n\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":300,"wires":[["7b4a9a49.881ce4"]]},{"id":"197a4265.34990e","type":"function","z":"24e72b46.2ac4b4","name":"Post Service Processing","func":"//Resposta = \"Ok, executado\";\n//Resposta = flow.get(\"RespostaAssistente\");\n\nmsg.mydata.messageout = msg.payload;\n\n//msg.mydata.messageout.output.text = Resposta;\n\nmsg.payload = {};\nmsg.payload.botresponse = msg.mydata;\n\nreturn msg;","outputs":1,"noerr":0,"x":730,"y":300,"wires":[["8057add7.66c09"]]},{"id":"7b4a9a49.881ce4","type":"watson-conversation-v1","z":"24e72b46.2ac4b4","name":"Conversation","workspaceid":"seuID","multiuser":false,"context":false,"empty-payload":false,"default-endpoint":false,"service-endpoint":"","timeout":"","optout-learning":false,"x":435.0000305175781,"y":416.52344608306885,"wires":[["197a4265.34990e","1304ca8d.5e2945"]]},{"id":"c187373a.20c8a8","type":"ui_form","z":"24e72b46.2ac4b4","name":"","label":"Interação","group":"7810fa77.3b10b4","order":2,"width":"8","height":"4","options":[{"label":"Fale que te escuto","value":"pergunta","type":"text","required":false}],"formValue":{"pergunta":""},"payload":"","topic":"pergunta","x":74,"y":387.3334484100342,"wires":[["379dd617.daa05a"]]},{"id":"379dd617.daa05a","type":"function","z":"24e72b46.2ac4b4","name":"Trata campos do formulário","func":"msg.user = msg.payload.usuario;\nmsg.payload = msg.payload.pergunta;\nreturn msg;","outputs":1,"noerr":0,"x":181.50001525878906,"y":463.3333911895752,"wires":[["7b4a9a49.881ce4"]]},{"id":"6e00043a.9f2a8c","type":"function","z":"24e72b46.2ac4b4","name":"InformaAlerta do App","func":" msg.payload = [];\n msg.topic = \"\";\n\nif (msg.verifica == \"RiscoAlto\"){\n msg.payload = 8;\n msg.topic = \"Alto\";\n}\n\nif (msg.verifica == \"AlertadeIncidente\"){\n msg.payload = 2;\n msg.topic = \"Baixo\";\n}\n\n\n\nif (msg.verifica == \"ZeraDashboard\"){\n msg.payload = [];\n msg.topic = \"\";\n}\n\n\n\nreturn msg;","outputs":1,"noerr":0,"x":880,"y":560,"wires":[["55e35242.09270c","43ce72c2.b0b3cc"]]},{"id":"b13dc85c.fb18d8","type":"function","z":"24e72b46.2ac4b4","name":"Exibe Imagem","func":"//var foto = msg.configuracao.foto;\nvar foto;\nmsg.payload = \"http://sp15.securitybsides.com.br/images/logo_bsidessp.jpg\";\n\nif(msg.zerardashboard == 1){\n msg.payload = \"http://sp15.securitybsides.com.br/images/logo_bsidessp.jpg\";\n}\n\nif (msg.verifica == \"RiscoAlto\"){\n msg.payload = \"https://i.ytimg.com/vi/fl5sLzxeql4/maxresdefault.jpg\";\n}\n\nif (msg.verifica == \"AlertadeIncidente\"){\n msg.payload = \"https://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Face-glasses.svg/2000px-Face-glasses.svg.png\";\n}\n\nif (msg.verifica == \"ZeraDashboard\"){\n msg.payload = \"http://sp15.securitybsides.com.br/images/logo_bsidessp.jpg\";\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":680,"wires":[["4fb3a2cd.dacb8c"]]},{"id":"f7d7a74e.7582d8","type":"function","z":"24e72b46.2ac4b4","name":"InformaTexto","func":"/*\nvar texto = \"Ok, o time de segurança foi avisado de seu alerta.\";\n\nif (msg.verifica == \"RiscoAlto\"){\n msg.payload = texto = \"É, chama o Batman, Super Homem e o Capitão Nascimento.\";\n}else{\n msg.payload = texto = \"Ok, o time de segurança foi avisado de seu alerta.\";\n}\nif (msg.verifica == \"ZeraDashboard\"){\n msg.payload = \"\";\n}\n*/\n\nmsg.payload = msg.respostadobot;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":620,"wires":[["b439810b.56f0a","5a55e052.97c21"]]},{"id":"1304ca8d.5e2945","type":"function","z":"24e72b46.2ac4b4","name":"Avalia o incidente","func":"msg.payload = msg.payload;\n//msg.verifica = \"\";\n//msg.maturidade = \"\";\n\nvar intencao;\nvar entidades;\nvar respostadobot;\n\n\n\nif ( msg.payload.intents != 0 && msg.payload.intents.length >0 ){\n var intents = msg.payload.intents;\n \n \n for(var intent of intents){\n if(intent.intent == \"AlertadeIncidente\" || intent.intent == \"AlertaIncidenteCritico\"){\n //msg.verifica = \"AlertadeIncidente\";\n intencao = \"AlertadeIncidente\";\n \n }\n\n if(intent.intent == \"ZeraDashboard\"){\n //msg.verifica = \"ZeraDashboard\";\n intencao = \"ZeraDashboard\";\n }\n\n }\n \n}\n\nif ( msg.payload.entities != 0 && msg.payload.entities.length >0 ){\n var entities = msg.payload.entities;\n \n \n for(var entity of entities ){\n \n if(entity.entity == \"AlertaIncidenteProblema\"){\n //msg.verifica = \"AlertadeIncidente\";\n entidades = \"AlertadeIncidente\";\n }\n \n if(entity.entity == \"ZeraDashboard\"){\n //msg.verifica = \"ZeraDashboard\";\n entidades = \"ZeraDashboard\";\n }\n \n if(entity.entity == \"cartaocredito\"){\n //msg.verifica = \"RiscoAlto\";\n entidades = \"RiscoAlto\";\n }\n \n if(entity.entity == \"informacoesSensiveis\"){\n //msg.verifica = \"RiscoAlto\";\n entidades = \"RiscoAlto\";\n }\n \n }\n}\n\n// Define o que o Bot irá falar em texto e audio.\nmsg.respostadobot = msg.payload.output.text[0];\n\nif(entidades == \"ZeraDashboard\" || intencao == \"ZeraDashboard\"){\n //Define que o Dashboard será limpado\n msg.verifica = \"ZeraDashboard\";\n}else{\n if(intencao == \"AlertadeIncidente\"){\n if(entidades == \"RiscoAlto\"){\n //Define que o Dashboard irá mostrar um Risco Alto\n msg.verifica = \"RiscoAlto\";\n }else{\n //Define que o Dashboard irá mostrar um Risco Baixo\n msg.verifica = \"AlertadeIncidente\"; \n }\n \n }\n}\n \n\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":620,"wires":[["6e00043a.9f2a8c","f7d7a74e.7582d8","b13dc85c.fb18d8","9ea2c12.10dcb4"]]},{"id":"b439810b.56f0a","type":"ui_text","z":"24e72b46.2ac4b4","group":"7810fa77.3b10b4","order":5,"width":"4","height":"3","name":"Mensagem","label":"","format":"{{msg.payload}}","layout":"row-left","x":1246.000015258789,"y":630.0000381469727,"wires":[]},{"id":"5a55e052.97c21","type":"ui_audio","z":"24e72b46.2ac4b4","name":"BSidesSP15","group":"7810fa77.3b10b4","voice":"17","always":false,"x":1243.9999885559082,"y":691.0000972747803,"wires":[]},{"id":"4fb3a2cd.dacb8c","type":"ui_template","z":"24e72b46.2ac4b4","group":"7810fa77.3b10b4","name":"BSidesSP15","order":6,"width":"12","height":"12","format":" <div ng-show=\"!setMedia[$index]\" class=\"col-xs-36 col-sm-36 col-md-15\">\n <img ng-src=\"{{msg.payload}}\" width=\"300px\">\n </div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1250,"y":760,"wires":[[]]},{"id":"55e35242.09270c","type":"ui_chart","z":"24e72b46.2ac4b4","name":"","group":"7810fa77.3b10b4","order":4,"width":"6","height":"6","label":"Nível do Incidente","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":true,"ymin":"0","ymax":"10","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"1","cutout":0,"useOneColor":false,"colors":["#ffff00","#ff8000","#ff0000","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"x":1252.0002517700195,"y":546.0001878738403,"wires":[[],[]],"inputLabels":["Entrada 1"]},{"id":"9ea2c12.10dcb4","type":"debug","z":"24e72b46.2ac4b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":440,"wires":[]},{"id":"43ce72c2.b0b3cc","type":"ui_gauge","z":"24e72b46.2ac4b4","name":"","group":"7810fa77.3b10b4","order":3,"width":"6","height":"6","gtype":"gage","title":"Indicador","label":"criticidade","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1250,"y":480,"wires":[]},{"id":"7810fa77.3b10b4","type":"ui_group","z":"","name":"Incidente de Segurança","tab":"d6a7e5ec.627428","disp":true,"width":"12","collapse":false},{"id":"d6a7e5ec.627428","type":"ui_tab","z":0,"name":"Incidente de Segurança","icon":"Home","order":3}]