-
Notifications
You must be signed in to change notification settings - Fork 363
Expand file tree
/
Copy pathvirtual_agent_lab.json
More file actions
1 lines (1 loc) · 5.35 KB
/
virtual_agent_lab.json
File metadata and controls
1 lines (1 loc) · 5.35 KB
1
[{"id":"97a0b3f5.e61d","type":"http in","z":"7f99b9ba.e10df8","name":"","url":"/wva","method":"get","swaggerDoc":"","x":75,"y":37,"wires":[["1777526a.de2cbe"]]},{"id":"aa003d59.bf84e","type":"http response","z":"7f99b9ba.e10df8","name":"","x":661,"y":37,"wires":[]},{"id":"63844499.a5687c","type":"template","z":"7f99b9ba.e10df8","name":"Chat Widget Template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n <head>\n <title>IBM Watson Virtual Agent Chat Widget Sample</title>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" \n content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0\" />\n <style>\n html, body, iframe { width: 100%; height:100%; padding:0; margin:0; }\n #ibm_chat_root { position:fixed; bottom:0; right: 20px; height: 80%; min-height:400px; width:300px; background:#000; }\n </style>\n </head>\n <body>\n <div id=\"ibm_chat_root\"></div>\n <iframe style=\"width:100%; height:100%\" src=\"{{wva.homepage}}\"></iframe>\n <!--\n https://unpkg.com/@watson-virtual-agent/chat-widget@X.X.X/dist/chat.min.js for a specific version, where X.X.X is the semantic version of the chat widget.\n In your production environment, we recommend locking down your widget version.\n -->\n <script src='https://unpkg.com/@watson-virtual-agent/chat-widget/dist/chat.min.js'></script>\n <script>\n var botid = '{{wva.botid}}';\n var config = {\n el: 'ibm_chat_root',\n botID: botid, \n baseURL: '/wvaProxy',\n styles: {\n background: 'rgba(255, 255, 255, 0.8)', //use rgba\n text: 'rgba(0, 0, 0, 1)',\n accentBackground: '#31eaf1', //or a hex code\n accentText: '#ffffff',\n secondaryBackground: '#f7f7f7',\n secondaryText: '#464646',\n link: '#ffffff'\n }\n };\n \n IBMChat.subscribe('action:updateAddress', function(data){\n console.log('Action - update Address');\n console.log(data);\n //make an ajax call to update a user address using \"data\"\n IBMChat.sendSilently('success');\n // or IBMChat.sendSilently('failure'); or IBMChat.sendSilently('cancel');\n });\n \n window.IBMChat.init(config);\n </script>\n </body>\n</html>","x":465,"y":38,"wires":[["aa003d59.bf84e"]]},{"id":"d9c95c44.933c5","type":"http response","z":"7f99b9ba.e10df8","name":"","x":648,"y":148,"wires":[]},{"id":"3df5731a.6ffc1c","type":"http in","z":"7f99b9ba.e10df8","name":"","url":"/wvaProxy/bots/:botid/dialogs","method":"post","swaggerDoc":"","x":156,"y":102,"wires":[["455670c.d30649"]]},{"id":"455670c.d30649","type":"function","z":"7f99b9ba.e10df8","name":"Add Secret","func":"var botid = '';\n\nif (msg.req && msg.req.params && msg.req.params.botid)\n{\n botid = msg.req.params.botid; \n}\n\nmsg.url = 'https://api.ibm.com/virtualagent/run/api/v1/bots/' + botid + '/dialogs';\nmsg.method = 'POST';\n\nmsg.headers={ 'X-IBM-Client-Id': 'Your Client ID',\n 'X-IBM-Client-Secret': 'Your Secret'\n };\n \n\nreturn msg;\n","outputs":1,"noerr":0,"x":405,"y":99,"wires":[["d19deccd.0feaf"]]},{"id":"84949622.524ce8","type":"http request","z":"7f99b9ba.e10df8","name":"","method":"use","ret":"obj","url":"","tls":"","x":476,"y":148,"wires":[["d9c95c44.933c5"]]},{"id":"86047653.771ff8","type":"http in","z":"7f99b9ba.e10df8","name":"","url":"/wvaProxy/bots/:botid/dialogs/:convid/messages","method":"post","swaggerDoc":"","x":216,"y":200,"wires":[["3afc2af0.2a5cc6"]]},{"id":"3afc2af0.2a5cc6","type":"function","z":"7f99b9ba.e10df8","name":"Add Secret 2","func":"var botid = '';\nvar convid = '';\nvar message = '';\n\nif (msg.req && msg.req.params && msg.req.params.botid)\n{\n botid = msg.req.params.botid; \n}\n\nif (msg.req && msg.req.params && msg.req.params.convid)\n{\n convid = msg.req.params.convid; \n}\n\nif (msg.payload && msg.payload.message) {\n message = msg.payload.message;\n}\n\n\nmsg.url = 'https://api.ibm.com/virtualagent/run/api/v1/bots/' + \n botid + '/dialogs/' + convid +\n '/messages' + '?message=' + message;\n\nmsg.method = 'POST';\n\nmsg.headers={ 'X-IBM-Client-Id': 'Your Client ID',\n 'X-IBM-Client-Secret': 'Your Secret'\n };\n \n\nreturn msg;\n","outputs":1,"noerr":0,"x":532.5,"y":202,"wires":[["b9c5ebb3.9e2268"]]},{"id":"c31d8ec5.1e1a6","type":"link in","z":"7f99b9ba.e10df8","name":"VA HTTP Request","links":["d19deccd.0feaf","b9c5ebb3.9e2268"],"x":350,"y":148,"wires":[["84949622.524ce8"]]},{"id":"d19deccd.0feaf","type":"link out","z":"7f99b9ba.e10df8","name":"VA BOTID","links":["c31d8ec5.1e1a6"],"x":524,"y":98,"wires":[]},{"id":"b9c5ebb3.9e2268","type":"link out","z":"7f99b9ba.e10df8","name":"VA ConvID","links":["c31d8ec5.1e1a6"],"x":661,"y":203,"wires":[]},{"id":"1777526a.de2cbe","type":"function","z":"7f99b9ba.e10df8","name":"Set Agent BotID","func":"msg.wva = {};\nmsg.wva.botid = 'Your BOT ID';\nmsg.wva.homepage = 'https://www.ibm.com/watson/developer/';\nreturn msg;","outputs":1,"noerr":0,"x":246.5,"y":37,"wires":[["63844499.a5687c"]]}]