-
Notifications
You must be signed in to change notification settings - Fork 1
/
node-red_telegram_viber_bot.json
1 lines (1 loc) · 266 KB
/
node-red_telegram_viber_bot.json
1
[{"id":"36bce78a.5b1d38","type":"tab","label":"Sneaker Bot","disabled":false,"info":""},{"id":"4ac6a692.a123d8","type":"subflow","name":"1 Set Webhook Viber","info":"","category":"","in":[{"x":140,"y":240,"wires":[{"id":"1166bd77.9f2d93"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"f7ce5827.49bb28","type":"subflow","name":"1 Set Webhook Telegram","info":"","category":"","in":[{"x":80,"y":100,"wires":[{"id":"dca110ba.16b7c"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"842721de.0a90c","type":"subflow","name":"Message Output","info":"","category":"","in":[],"out":[{"x":560,"y":180,"wires":[{"id":"919b5d3b.b1088","port":0}]},{"x":560,"y":400,"wires":[{"id":"498b2406.9aefdc","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"bcbb1b33.d50ad8","type":"subflow","name":"Add Phone to DB","info":"","category":"","in":[{"x":220,"y":280,"wires":[{"id":"4ab1d71f.dc0818"},{"id":"64dedf7b.c8c77"},{"id":"b8486bff.2c4f68"},{"id":"7f843c77.2aa474"},{"id":"47cb831f.d1c37c"}]}],"out":[{"x":740,"y":380,"wires":[{"id":"7e52df9.e8b9e2","port":0},{"id":"56b75564.dfd89c","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"5096e274.b6714c","type":"subflow","name":"VIBER MAIN CONV","info":"","category":"","in":[{"x":240,"y":380,"wires":[{"id":"15ee2714.aeaf39"},{"id":"4d5ef65.72bb208"},{"id":"6a7121ea.f1453"}]}],"out":[{"x":720,"y":380,"wires":[{"id":"15ee2714.aeaf39","port":0},{"id":"4d5ef65.72bb208","port":0},{"id":"6a7121ea.f1453","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"da6310b4.82f05","type":"subflow","name":"Delete from DB","info":"","category":"","in":[{"x":280,"y":300,"wires":[{"id":"5e0696f1.25c378"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"c6081279.fe8b6","type":"subflow","name":"Add User to DB ","info":"","category":"","in":[{"x":280,"y":180,"wires":[{"id":"a190d3f4.d0bad"},{"id":"d1d4095c.c072b8"}]}],"out":[{"x":740,"y":280,"wires":[{"id":"d1d4095c.c072b8","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"5b4d7701.30a938","type":"subflow","name":"Buttons Main Menu","info":"","category":"","in":[{"x":180,"y":240,"wires":[{"id":"53a2f629.4eee98"}]}],"out":[{"x":760,"y":240,"wires":[{"id":"c10784d5.c31208","port":0},{"id":"538aa2e2.03fd3c","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"c71fceb2.e323f","type":"subflow","name":"Category Check","info":"","category":"","in":[{"x":80,"y":420,"wires":[{"id":"669a9e91.b55bc"}]}],"out":[{"x":680,"y":440,"wires":[{"id":"bcd866c7.8328a8","port":0},{"id":"bc4a8448.593868","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"e1e0c44d.006b38","type":"subflow","name":"Get Back MainM","info":"","category":"","in":[{"x":300,"y":360,"wires":[{"id":"b0e5ae4f.59677"}]}],"out":[{"x":700,"y":360,"wires":[{"id":"b0e5ae4f.59677","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"c61231f7.8068a","type":"subflow","name":"Basket","info":"","category":"","in":[{"x":80,"y":320,"wires":[{"id":"9bad6405.918278"}]}],"out":[{"x":820,"y":320,"wires":[{"id":"532ce8ab.8f8058","port":0},{"id":"b331974e.d59368","port":0},{"id":"961007df.de7508","port":0},{"id":"ee67ed9b.a2266","port":0},{"id":"cdf24d70.4dd51","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"fea15d6c.58e16","type":"subflow","name":"Manually phone logic","info":"","category":"","in":[{"x":40,"y":660,"wires":[{"id":"6b7c0576.a6aa4c"}]}],"out":[{"x":2680,"y":560,"wires":[{"id":"dc488c11.23ebe","port":0},{"id":"7721776e.622d58","port":0},{"id":"bf49140d.8ebff8","port":0}]},{"x":880,"y":640,"wires":[{"id":"286f53c3.79c26c","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"c34e9bdb.bbc688","type":"subflow","name":"Added to Basket","info":"","category":"","in":[{"x":60,"y":200,"wires":[{"id":"91372c4.8a95bd"}]}],"out":[{"x":1300,"y":460,"wires":[{"id":"59bf84d1.15fe0c","port":0},{"id":"7c5d083.41448f8","port":0},{"id":"3310728c.048bfe","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"4e27080.a1b7ff8","type":"subflow","name":"Clear Basket","info":"","category":"","in":[{"x":200,"y":220,"wires":[{"id":"e2667ff5.6782f"}]}],"out":[{"x":1080,"y":220,"wires":[{"id":"22b7733f.2629fc","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"a281f193.619d7","type":"subflow","name":"Check Basket","info":"","category":"","in":[{"x":40,"y":120,"wires":[{"id":"2b98c41f.608e6c"}]}],"out":[{"x":1140,"y":320,"wires":[{"id":"a4b979b1.864698","port":0},{"id":"249ac803.206fa8","port":0},{"id":"f243d558.ff9778","port":0},{"id":"fd88f753.170bb8","port":0},{"id":"4b556889.f14548","port":0},{"id":"dbfb2560.0b77b8","port":0},{"id":"a0af9ba9.4566c8","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"6e15ed1c.05f3d4","type":"subflow","name":"Manually Phone","info":"","category":"","in":[{"x":340,"y":220,"wires":[{"id":"715ec7de.e50518"}]}],"out":[{"x":1120,"y":200,"wires":[{"id":"d415d3df.37a87","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"c761d7f6.2970e8","type":"subflow","name":"Learn More","info":"","category":"","in":[{"x":180,"y":240,"wires":[{"id":"dc5e4e5e.9be1d"}]}],"out":[{"x":1020,"y":240,"wires":[{"id":"d3c3afe9.c6181","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"ddbac507.dbd058","type":"subflow","name":"Carousel","info":"","category":"","in":[{"x":100,"y":400,"wires":[{"id":"cc55448f.d56b98"}]}],"out":[{"x":1120,"y":400,"wires":[{"id":"a91743b4.a21f2","port":0},{"id":"34e244b1.1b501c","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"dec3397.f5f9fc8","type":"subflow","name":"Delete from Basket","info":"","category":"","in":[{"x":60,"y":240,"wires":[{"id":"8d70241c.e945b8"}]}],"out":[{"x":1860,"y":260,"wires":[{"id":"5160bddf.844714","port":0},{"id":"d6fc816a.10806","port":0},{"id":"35367e5.bcc5182","port":0},{"id":"f9116633.0dc068","port":0},{"id":"32ebcf11.851b8","port":0},{"id":"bfd6eae8.987588","port":0},{"id":"7b2389ec.c2b1b8","port":0},{"id":"1d70298.c99cad7","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"61e699d3.bad628","type":"subflow","name":"TELEGRAM CONV START","info":"","category":"","in":[{"x":40,"y":200,"wires":[{"id":"b35b68f7.f37a88"}]}],"out":[{"x":660,"y":340,"wires":[{"id":"a9d3b3e9.6c967","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"aa4e0ad4.553da8","type":"subflow","name":"Alread.Regist.Message","info":"","category":"","in":[{"x":400,"y":400,"wires":[{"id":"74d5565c.56bab8"},{"id":"1be69193.1d947e"}]}],"out":[{"x":840,"y":440,"wires":[{"id":"1be69193.1d947e","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"8a7eef08.275f6","type":"subflow","name":"I Am Already Registered","info":"","category":"","in":[{"x":40,"y":120,"wires":[{"id":"58d8d3c6.04fb4c"}]}],"out":[{"x":2180,"y":240,"wires":[{"id":"98b45b43.a51038","port":0},{"id":"60085880.3392c8","port":0},{"id":"484e8210.713f1c","port":0}]},{"x":380,"y":400,"wires":[{"id":"a4c35c6e.4852c","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"60725fdb.ab566","type":"subflow","name":" VIBER CONV START","info":"","category":"","in":[{"x":280,"y":280,"wires":[{"id":"2146a657.b15d7a"}]}],"out":[{"x":1500,"y":640,"wires":[{"id":"7c195350.ce442c","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"8e043e59.f15c5","type":"subflow","name":"I Am Not Registered","info":"","category":"","in":[{"x":200,"y":220,"wires":[{"id":"e61e9718.3c1d38"},{"id":"5893f9e5.e7fb38"}]}],"out":[{"x":740,"y":240,"wires":[{"id":"5893f9e5.e7fb38","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"9aeb7186.69057","type":"subflow","name":"TG Hello","info":"","category":"","in":[{"x":220,"y":280,"wires":[{"id":"d9f7f366.9ed56"},{"id":"64a1b2e4.24ad2c"}]}],"out":[{"x":700,"y":340,"wires":[{"id":"64a1b2e4.24ad2c","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"e9dffb2e.039e58","type":"subflow","name":"TG Ukraine number validation","info":"","category":"","in":[{"x":180,"y":380,"wires":[{"id":"bd719245.5a7c9"}]}],"out":[{"x":2420,"y":400,"wires":[{"id":"420cae19.2832d","port":0},{"id":"ac101d2d.32dab","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"8c1865f9.3f7bc8","type":"subflow","name":"TG Already in DB or not","info":"","category":"","in":[{"x":40,"y":140,"wires":[{"id":"3dfd3d00.b1d894"}]}],"out":[{"x":1400,"y":80,"wires":[{"id":"8cb63e9c.53015","port":0},{"id":"7417371.0ca6fc8","port":0},{"id":"8b6b1942.566d28","port":0}]},{"x":460,"y":540,"wires":[{"id":"4a2d9fa3.1ba6f","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"8265f79d.547d38","type":"subflow","name":"TELEGRAM MAIN CONV","info":"","category":"","in":[{"x":140,"y":320,"wires":[{"id":"746860d7.aacad"},{"id":"ee34235.a6e0ae"},{"id":"606477f9.186af8"}]}],"out":[{"x":600,"y":320,"wires":[{"id":"746860d7.aacad","port":0},{"id":"ee34235.a6e0ae","port":0},{"id":"606477f9.186af8","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"d8982748.1d99e8","type":"subflow","name":"TG /start","info":"","category":"","in":[{"x":100,"y":320,"wires":[{"id":"b48c1de8.52816"}]}],"out":[{"x":1080,"y":280,"wires":[{"id":"b4a683c4.58bad","port":0},{"id":"41efc035.2366e","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"1b39f8a3.d7f8b7","type":"subflow","name":"TG Work with phone AUTO","info":"","category":"","in":[{"x":120,"y":340,"wires":[{"id":"df888581.ae8068"},{"id":"d351f812.683128"},{"id":"9ce62f1f.6149c"},{"id":"ec35418d.c4dc4"}]}],"out":[{"x":1040,"y":340,"wires":[{"id":"1adad457.21267c","port":0},{"id":"1e19a638.f1a7fa","port":0},{"id":"c85822dc.2f142","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"69a66f9a.09815","type":"subflow","name":"TG Buttons Main Menu","info":"","category":"","in":[{"x":20,"y":200,"wires":[{"id":"87e384aa.1a8ee8"}]}],"out":[{"x":1240,"y":200,"wires":[{"id":"f0ef2adf.aa3118","port":0},{"id":"e412bb66.6290d8","port":0},{"id":"5f69bce8.3bc984","port":0},{"id":"fd2d468e.15d0d8","port":0},{"id":"cb22e386.5eb","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"9ceb0f78.78d99","type":"subflow","name":"TG Category Check","info":"","category":"","in":[{"x":60,"y":360,"wires":[{"id":"6eadca5e.a2f6d4"}]}],"out":[{"x":1680,"y":440,"wires":[{"id":"62e1ea01.31f764","port":0},{"id":"235cdd32.7c4552","port":0},{"id":"f0d7a916.452a18","port":0},{"id":"3c1700eb.4f384","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"2bfd919c.f0f68e","type":"subflow","name":"TG Choose NEXT","info":"","category":"","in":[{"x":80,"y":80,"wires":[{"id":"f38ef235.bf30e"}]}],"out":[{"x":1860,"y":380,"wires":[{"id":"9fff7e63.9bc3d","port":0},{"id":"321cb293.bdc54e","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"f033b019.ef1b3","type":"subflow","name":"TG Choose BACK","info":"","category":"","in":[{"x":60,"y":100,"wires":[{"id":"2e68af60.e57ff"}]}],"out":[{"x":1920,"y":360,"wires":[{"id":"e8b8b05f.6cfad","port":0},{"id":"692d3025.aabec","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"efab7df5.d9e61","type":"subflow","name":"TG Basket","info":"","category":"","in":[{"x":100,"y":300,"wires":[{"id":"ddea6472.75d1d8"}]}],"out":[{"x":1100,"y":300,"wires":[{"id":"640b702d.40bab","port":0},{"id":"a276ee63.ef4a5","port":0},{"id":"f41c98c7.e053e8","port":0},{"id":"6727d53f.3eec7c","port":0},{"id":"b94d6c68.a2aff","port":0},{"id":"b1efc01c.3c1aa","port":0},{"id":"ac3b018a.2fbe1","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"56b45400.f580cc","type":"subflow","name":"TG AddToBasket","info":"","category":"","in":[{"x":80,"y":60,"wires":[{"id":"63e0b83d.b60288"}]}],"out":[{"x":1180,"y":360,"wires":[{"id":"8fc26c2a.afd7e","port":0},{"id":"c9f2027b.009f6","port":0},{"id":"f12d55d4.98d608","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"9ecd215f.b77f7","type":"subflow","name":"TG Clear Basket","info":"","category":"","in":[{"x":100,"y":300,"wires":[{"id":"4e26eec0.f752c"}]}],"out":[{"x":820,"y":420,"wires":[{"id":"fb40eae0.ee5b28","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"68c38691.5e9888","type":"subflow","name":"TG Check_Basket","info":"","category":"","in":[{"x":60,"y":140,"wires":[{"id":"6dfe2568.09818c"}]}],"out":[{"x":720,"y":460,"wires":[{"id":"6bb12862.29d618","port":0},{"id":"a3639c3d.58e7d","port":0},{"id":"c976e8aa.b763e8","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"8de7f599.4e50a8","type":"subflow","name":"TG Check_NEXT_Basket","info":"","category":"","in":[{"x":80,"y":120,"wires":[{"id":"4e0755b8.39f49c"}]}],"out":[{"x":1740,"y":400,"wires":[{"id":"d5387e29.423bd","port":0},{"id":"f8ee8478.b0df18","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"69aec46f.aba83c","type":"subflow","name":"TG Check_PREVIOUS_Basket","info":"","category":"","in":[{"x":40,"y":100,"wires":[{"id":"80b33af2.be2f18"}]}],"out":[{"x":1540,"y":420,"wires":[{"id":"ede242b3.748c","port":0},{"id":"10cfc825.47b418","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"4782995d.094808","type":"subflow","name":"TG Delete_From_Basket","info":"","category":"","in":[{"x":0,"y":80,"wires":[{"id":"e9ca218.90c38e"}]}],"out":[{"x":1140,"y":80,"wires":[{"id":"f19baf44.83fef","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"d60ec569.fa2668","type":"subflow","name":"TG Work with phone MANUAL","info":"","category":"","in":[{"x":60,"y":280,"wires":[{"id":"97cc6740.4b79a8"}]}],"out":[{"x":2080,"y":300,"wires":[{"id":"942b0cbb.1e418","port":0},{"id":"f2139edf.32c7e","port":0},{"id":"ecbbe3e9.3595e","port":0},{"id":"9d6f7682.5e4e58","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"c97fc2aa.c8221","type":"subflow","name":"TG Bot command","info":"","category":"","in":[{"x":80,"y":180,"wires":[{"id":"fb5326ee.e096b8"}]}],"out":[{"x":700,"y":180,"wires":[{"id":"55b839c7.1e3348","port":0},{"id":"82c51c58.d9e3","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"fc9c05b0.be2c58","type":"subflow","name":"TG FULL PHONE LOGIC","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"44ee2af7.1c7834"}]}],"out":[{"x":1620,"y":260,"wires":[{"id":"79795cd8.b47784","port":0},{"id":"6951fd03.b028d4","port":0},{"id":"e9d8e6ea.047038","port":0},{"id":"956f64aa.f426a8","port":0}]},{"x":420,"y":520,"wires":[{"id":"40bc62b.48cc59c","port":1}]}],"env":[],"color":"#DDAA99"},{"id":"e683806a.488ab","type":"subflow","name":"TG Callback","info":"","category":"","in":[{"x":160,"y":180,"wires":[{"id":"87b9902c.e3cc8"}]}],"out":[],"env":[],"color":"#DDAA99"},{"id":"a8eb2ba2.888468","type":"subflow","name":"TG Buy Basket","info":"","category":"","in":[{"x":20,"y":180,"wires":[{"id":"a001b760.f1ac38"},{"id":"784f60ba.cfacf"}]}],"out":[{"x":860,"y":260,"wires":[{"id":"a001b760.f1ac38","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"b5ae98db.c5b1c8","type":"subflow","name":"Buy Basket","info":"","category":"","in":[{"x":80,"y":260,"wires":[{"id":"8ca5caf5.af3b58"},{"id":"b7b584f.1b5cc78"}]}],"out":[{"x":940,"y":220,"wires":[{"id":"8ca5caf5.af3b58","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"5296cb16.024d34","type":"telegram bot","botname":"","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"a79d585f.fdd3a8","type":"vtjbot-config","d":true,"botGender":"male","name":"TJBot","hasServo":false,"hasLED":false,"hasSpeaker":false,"hasMicrophone":false,"hasCamera":false,"aUrl":"https://gateway.watsonplatform.net/assistant/api","taUrl":"https://gateway.watsonplatform.net/tone-analyzer/api","ltUrl":"https://gateway.watsonplatform.net/language-translator/api","sttUrl":"https://stream.watsonplatform.net/speech-to-text/api","ttsUrl":"https://stream.watsonplatform.net/text-to-speech/api","vrUrl":"https://gateway.watsonplatform.net/visual-recognition/api"},{"id":"87726f00.c270b","type":"sqlitedb","db":"C:\\Users\\User\\Desktop/UserInfoDB.db","mode":"RWC"},{"id":"edd2eb30.19d298","type":"chatbot-viber-node","z":"60725fdb.ab566","botname":"","usernames":"","webHook":"","store":"","log":"","debug":false},{"id":"52c1e3b.0670b1c","type":"inject","z":"36bce78a.5b1d38","name":"webhook","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":120,"wires":[["20413745.99b468","d1e74e05.ba1bc"]]},{"id":"20413745.99b468","type":"subflow:4ac6a692.a123d8","z":"36bce78a.5b1d38","name":"","env":[],"x":320,"y":80,"wires":[]},{"id":"1166bd77.9f2d93","type":"function","z":"4ac6a692.a123d8","name":"","func":"var token_viber = env.get(\"TOKEN_VIBER\")\nvar ngrok_viber = env.get(\"NGROK_VIBER\")\nvar set_webhook = env.get(\"VIBER_SET_WEBHOOK\")\nmsg.method = \"POST\"\nmsg.url = set_webhook\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"url\": ngrok_viber,\n \"event_types\": [\n \"delivered\",\n \"seen\",\n \"failed\",\n \"subscribed\",\n \"unsubscribed\",\n \"conversation_started\",\n \"get_user_details\"\n ],\n \"send_name\": true,\n \"send_photo\": true\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":300,"wires":[["e4bf4830.ad3908"]]},{"id":"e4bf4830.ad3908","type":"http request","z":"4ac6a692.a123d8","name":"set webhook VB","method":"use","ret":"obj","paytoqs":"body","url":"","tls":"","persist":false,"proxy":"","authType":"","x":420,"y":380,"wires":[["c7b8b464.fabf28"]]},{"id":"c7b8b464.fabf28","type":"debug","z":"4ac6a692.a123d8","name":"webhook viber","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":580,"y":460,"wires":[]},{"id":"d1e74e05.ba1bc","type":"subflow:f7ce5827.49bb28","z":"36bce78a.5b1d38","name":"","env":[],"x":330,"y":160,"wires":[]},{"id":"b13d96da.cb0fa8","type":"http request","z":"f7ce5827.49bb28","name":"set webhook TG","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":340,"y":260,"wires":[["fce66662.11d968"]]},{"id":"fce66662.11d968","type":"debug","z":"f7ce5827.49bb28","name":"webhook telegram","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":340,"wires":[]},{"id":"dca110ba.16b7c","type":"function","z":"f7ce5827.49bb28","name":"","func":"var set_webhook = env.get(\"TELEGRAM_SET_WEBHOOK\")\n\nmsg.method=\"POST\"\nmsg.url=set_webhook\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":180,"wires":[["b13d96da.cb0fa8"]]},{"id":"d3d49d51.0e6b6","type":"http response","z":"842721de.0a90c","name":"","statusCode":"200","headers":{},"x":140,"y":180,"wires":[]},{"id":"919b5d3b.b1088","type":"http in","z":"842721de.0a90c","name":"","url":"/viber_bot","method":"post","upload":false,"swaggerDoc":"","x":160,"y":220,"wires":[["d3d49d51.0e6b6"]]},{"id":"498b2406.9aefdc","type":"http in","z":"842721de.0a90c","name":"","url":"/telegram_bot","method":"post","upload":false,"swaggerDoc":"","x":170,"y":420,"wires":[["debe1350.273ca"]]},{"id":"debe1350.273ca","type":"http response","z":"842721de.0a90c","name":"","statusCode":"200","headers":{},"x":140,"y":380,"wires":[]},{"id":"5891f949.2e3b88","type":"subflow:842721de.0a90c","z":"36bce78a.5b1d38","name":"","env":[],"x":160,"y":460,"wires":[["ef720c31.266e3","90da2142.390d6"],["c6ff11a.04de2f","62734447.1d598c","bd7e486a.056ff8"]]},{"id":"ef720c31.266e3","type":"debug","z":"36bce78a.5b1d38","name":"get message viber","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":150,"y":400,"wires":[]},{"id":"c6ff11a.04de2f","type":"debug","z":"36bce78a.5b1d38","name":"get message telegram","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":140,"y":520,"wires":[]},{"id":"9e29c8c5.fa06f8","type":"sqlite","z":"36bce78a.5b1d38","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"Create DB","x":830,"y":140,"wires":[["ce5364c1.141b48"]]},{"id":"22f1d71.4f3b428","type":"inject","z":"36bce78a.5b1d38","name":"User_Data_VB","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CREATE TABLE User_Data_VB (role CHAR, id_viber CHAR, username CHAR,phone CHAR,phone_inputStatus CHAR, already_registered CHAR)","payload":"","payloadType":"date","x":600,"y":80,"wires":[["9e29c8c5.fa06f8"]]},{"id":"ce5364c1.141b48","type":"debug","z":"36bce78a.5b1d38","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":140,"wires":[]},{"id":"4ab1d71f.dc0818","type":"function","z":"bcbb1b33.d50ad8","name":"Update (set phone)","func":"msg.topic = `UPDATE User_Data_VB SET phone = \"${msg.payload.message.contact.phone_number}\" WHERE id_viber = \"${msg.payload.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":100,"wires":[["738bbd0b.8e88a4"]]},{"id":"738bbd0b.8e88a4","type":"sqlite","z":"bcbb1b33.d50ad8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":570,"y":100,"wires":[[]]},{"id":"dc24ff3e.66ed3","type":"subflow:5096e274.b6714c","z":"36bce78a.5b1d38","name":"","env":[],"x":760,"y":380,"wires":[["a3230171.e7eeb"]]},{"id":"10023495.bd62eb","type":"inject","z":"36bce78a.5b1d38","name":"Database","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CREATE TABLE Database (id CHAR,url CHAR,url_image CHAR, size CHAR,brand CHAR, model CHAR, type CHAR, price CHAR)","payload":"","payloadType":"date","x":620,"y":200,"wires":[["9e29c8c5.fa06f8"]]},{"id":"a8f12cd2.f033","type":"sqlite","z":"da6310b4.82f05","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":970,"y":300,"wires":[[]]},{"id":"7c9a070d.c38c08","type":"function","z":"da6310b4.82f05","name":"Delete from User_Data","func":"msg.topic = `DELETE FROM User_Data_VB WHERE id_viber = \"${msg.payload.user_id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":300,"wires":[["a8f12cd2.f033"]]},{"id":"b2f561b2.f263f","type":"sqlite","z":"c6081279.fe8b6","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":830,"y":160,"wires":[[]]},{"id":"a190d3f4.d0bad","type":"function","z":"c6081279.fe8b6","name":"role,id_viber,username","func":"msg.topic = `INSERT INTO User_Data_VB (role,id_viber, username,already_registered) VALUES (\"user\",\"${msg.payload.user.id}\",\"${msg.payload.user.name}\",0)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":160,"wires":[["b2f561b2.f263f"]]},{"id":"d1d4095c.c072b8","type":"function","z":"c6081279.fe8b6","name":"Hello Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.payload.user.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Привет! Я - бот-каталог для магазина SneakerShop. Мне нужно, чтобы ты указал свой номер телефона\",\n \"keyboard\": {\n\t\t\"Buttons\": [{\n\t\t \n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"share-phone\",\n \"ActionBody\": \"phone\",\n\t\t\t\"Text\": \"Отправить номер\",\n\t\t},\n\t\t{\n\t\t \n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"NoAutoPhoneInput\",\n\t\t\t\"Text\": \"Вписать номер вручную\",\n\t\t},\n\t\t{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"IAmAlreadyRegistered\",\n\t\t\t\"Text\": \"Я уже зарегистрирован в другом мессенджере\",\n\t\t}],\n\t\t\"DefaultHeight\" : \"true\",\n\t\t\"InputFieldState\" : \"hidden\",\n\t}\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":280,"wires":[[]]},{"id":"7e52df9.e8b9e2","type":"function","z":"bcbb1b33.d50ad8","name":"Hello Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.payload.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Ты успешно ввёл данные\\nНиже ты можешь увидеть меню, в котором описаны все мои функции\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":380,"wires":[[]]},{"id":"c10784d5.c31208","type":"function","z":"5b4d7701.30a938","name":"Category","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Доступные категории:\",\n \n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgMediaType\": \"picture\",\n\t\t\t\"BgMedia\": \"https://img.ans-media.com/files/sc_staging_images/product/large_img_2576340.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Boots\",\n \"Text\":\"Ботинки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n \n },\n {\n \"BgMediaType\": \"picture\",\n \"BgMedia\": \"https://images.ua.prom.st/1914761302_kedy-kopiya-converse.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-1\",\n \"Text\":\"Кеды\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n {\n \n \n \"BgMedia\": \"https://crossplus.com.ua/content/images/1/muzhskie-krossovki-adidas-iniki-runner-boost-31957844966906_small11.jpeg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-2\",\n \"Text\":\"Кроссовки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://s3.eu-central-1.amazonaws.com/helen-marlen/catalog/product/cache/0/image/400x/040ec09b1e35df139433887a97daa66f/7/f/7ff712f50b28ed63598838924079b1af.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Moccasins\",\n \"Text\":\"Мокасины\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://static.wittchen.com/zdjecia/skorzane-polbuty-meskie-1-91-M-902-1-41/thumb_480x449/5f4792d3982ae.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Shoes\",\n \"Text\":\"Туфли\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgLoop\": true,\n \"BgMedia\": \"https://static.wikia.nocookie.net/shararam-smeshi/images/7/7d/%D0%A1%D1%82%D1%80%D0%B5%D0%BB%D0%BA%D0%B0_%D0%B2%D0%BB%D0%B5%D0%B2%D0%BE.gif/revision/latest?cb=20150401153013&path-prefix=ru\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Back\",\n \"Text\":\"Назад\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n \n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":220,"wires":[[]]},{"id":"538aa2e2.03fd3c","type":"function","z":"5b4d7701.30a938","name":"Basket","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Ниже можешь увидеть функции корзины\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\": \"#6ac490\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"CheckBasket\",\n \"Text\":\"Просмотреть корзину\",\n \"TextSize\":\"large\"\n },\n {\n \"BgColor\": \"#a82349\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"ClearBasket\",\n \"Text\":\"Очистить корзину\",\n \"TextSize\":\"large\"\n },\n {\n \"BgColor\": \"#5294c7\",\n \"Columns\": 6,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"BuyBasket\",\n \"Text\":\"Перейти к оплате\",\n \"TextSize\":\"large\"\n },\n {\n \"BgColor\": \"#95c210\",\n \"Columns\": 6,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Back\",\n \"Text\":\"Назад\",\n \"TextSize\":\"large\"\n },\n \n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":260,"wires":[[]]},{"id":"15ee2714.aeaf39","type":"subflow:5b4d7701.30a938","z":"5096e274.b6714c","name":"","env":[],"x":470,"y":320,"wires":[[]]},{"id":"53a2f629.4eee98","type":"switch","z":"5b4d7701.30a938","name":"Button Check","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"eq","v":"Category","vt":"str"},{"t":"eq","v":"Basket","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":440,"y":240,"wires":[["c10784d5.c31208"],["538aa2e2.03fd3c"]]},{"id":"4d5ef65.72bb208","type":"subflow:c71fceb2.e323f","z":"5096e274.b6714c","name":"","env":[],"x":460,"y":380,"wires":[[]]},{"id":"b0e5ae4f.59677","type":"function","z":"e1e0c44d.006b38","name":"Get Back","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"text\",\n \"text\": \"Главное меню\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\":\"hidden\",\n \"Buttons\":[\n {\n \"BgColor\": \"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\"\n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"large\"\n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":360,"wires":[[]]},{"id":"6a7121ea.f1453","type":"subflow:c61231f7.8068a","z":"5096e274.b6714c","name":"","env":[],"x":430,"y":440,"wires":[[]]},{"id":"9bad6405.918278","type":"switch","z":"c61231f7.8068a","name":"Check Function Basket","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"eq","v":"CheckBasket","vt":"str"},{"t":"eq","v":"ClearBasket","vt":"str"},{"t":"eq","v":"BuyBasket","vt":"str"},{"t":"cont","v":"AddToBasket","vt":"str"},{"t":"cont","v":"DeleteFromBasket","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":290,"y":320,"wires":[["532ce8ab.8f8058"],["b331974e.d59368"],["cdf24d70.4dd51"],["961007df.de7508"],["ee67ed9b.a2266"]]},{"id":"286f53c3.79c26c","type":"switch","z":"fea15d6c.58e16","name":"Check_Input_Status","property":"payload[0].phone_inputStatus","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":640,"y":660,"wires":[["3793c8b3.51d758"],[],[]]},{"id":"f81a2d99.87992","type":"sqlite","z":"fea15d6c.58e16","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":430,"y":660,"wires":[["286f53c3.79c26c"]]},{"id":"6b7c0576.a6aa4c","type":"function","z":"fea15d6c.58e16","name":"Select phone_inputStatus","func":"msg.topic = `SELECT phone_inputStatus FROM User_Data_VB WHERE id_viber = \"${msg.payload.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":660,"wires":[["f81a2d99.87992"]]},{"id":"56fa0a2a.d124c4","type":"function","z":"fea15d6c.58e16","name":"Check_Amount_Of_Numbers","func":"msg.check_amount_of_phone_numbers = msg.req.body.message.text.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1100,"y":400,"wires":[["9737baec.9a0468"]]},{"id":"9737baec.9a0468","type":"switch","z":"fea15d6c.58e16","name":"Check Amount of Numbers","property":"check_amount_of_phone_numbers","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1400,"y":400,"wires":[["f8c291a4.d422b","4a130b7a.d7f0b4","a6491a.e26766e8"],["7721776e.622d58"]]},{"id":"7721776e.622d58","type":"function","z":"fea15d6c.58e16","name":"Input Error","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Неверный формат номера, попробуй ещё раз\",\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1670,"y":560,"wires":[[]]},{"id":"7b3e0acb.57b544","type":"sqlite","z":"fea15d6c.58e16","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1930,"y":320,"wires":[["54e99458.bfb9bc"]]},{"id":"f8c291a4.d422b","type":"function","z":"fea15d6c.58e16","name":"Set Input Status to 0","func":"msg.topic = `UPDATE User_Data_VB SET phone_inputStatus = 0 WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1700,"y":320,"wires":[["7b3e0acb.57b544"]]},{"id":"80216808.3b43e8","type":"sqlite","z":"fea15d6c.58e16","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":2330,"y":320,"wires":[["493424e.8e492dc"]]},{"id":"54e99458.bfb9bc","type":"function","z":"fea15d6c.58e16","name":"Insert Phone to DB","func":"msg.topic = `UPDATE User_Data_VB SET phone = \"${msg.req.body.message.text}\" WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2130,"y":320,"wires":[["80216808.3b43e8"]]},{"id":"dc488c11.23ebe","type":"function","z":"fea15d6c.58e16","name":"Success Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Ты успешно ввёл данные\\nНиже ты можешь увидеть меню, в котором описаны все мои функции\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2630,"y":320,"wires":[[]]},{"id":"64dedf7b.c8c77","type":"function","z":"bcbb1b33.d50ad8","name":"set phoneInputStatus = 0","func":"msg.topic = `UPDATE User_Data_VB SET phone_inputStatus = 0 WHERE id_viber = \"${msg.payload.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":420,"wires":[["1022ed61.c6f403"]]},{"id":"1022ed61.c6f403","type":"sqlite","z":"bcbb1b33.d50ad8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":570,"y":420,"wires":[[]]},{"id":"961007df.de7508","type":"subflow:c34e9bdb.bbc688","z":"c61231f7.8068a","name":"","env":[],"x":560,"y":360,"wires":[[]]},{"id":"d4b47b57.c2f668","type":"function","z":"c34e9bdb.bbc688","name":"Add to Basket","func":"var string = msg.req.body.message.text;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `INSERT INTO \"${msg.payload[0].phone}\" (id) VALUES (\"${number}\")`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1040,"y":240,"wires":[["e53c39b1.ea5848"]]},{"id":"e53c39b1.ea5848","type":"sqlite","z":"c34e9bdb.bbc688","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1210,"y":240,"wires":[["59bf84d1.15fe0c"]]},{"id":"59bf84d1.15fe0c","type":"function","z":"c34e9bdb.bbc688","name":"Success message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Добавлено в корзину!\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1330,"y":280,"wires":[[]]},{"id":"e941caab.9b1168","type":"switch","z":"c34e9bdb.bbc688","name":"null or not","property":"payload[0]","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":160,"y":420,"wires":[["1619fb47.e865b5"],["7c5d083.41448f8"]]},{"id":"78799791.9689b8","type":"function","z":"c34e9bdb.bbc688","name":"split string","func":"msg.phone = msg.payload[0].phone;\n\nvar string = msg.req.body.message.text;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `SELECT id FROM \"${msg.payload[0].phone}\" WHERE id =\"${number}\"`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":280,"wires":[["3e98e160.0350de"]]},{"id":"3e98e160.0350de","type":"sqlite","z":"c34e9bdb.bbc688","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":390,"y":280,"wires":[["e941caab.9b1168"]]},{"id":"7c5d083.41448f8","type":"function","z":"c34e9bdb.bbc688","name":"Already in Basket","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Товар уже в корзине!\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":460,"wires":[[]]},{"id":"cbffb822.885338","type":"function","z":"4e27080.a1b7ff8","name":"Clear Basket","func":"msg.topic =`DELETE FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":280,"wires":[["766ce572.00dc5c"]]},{"id":"766ce572.00dc5c","type":"sqlite","z":"4e27080.a1b7ff8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":690,"y":280,"wires":[["22b7733f.2629fc"]]},{"id":"22b7733f.2629fc","type":"function","z":"4e27080.a1b7ff8","name":"Send Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Корзина очищена\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":360,"wires":[[]]},{"id":"b331974e.d59368","type":"subflow:4e27080.a1b7ff8","z":"c61231f7.8068a","name":"","env":[],"x":550,"y":280,"wires":[[]]},{"id":"8600b067.a0597","type":"function","z":"a281f193.619d7","name":"Get info from DB","func":"msg.topic = `SELECT D.id,url,url_image,brand,model,type,price FROM Database D LEFT JOIN \"${msg.payload[0].phone}\" M WHERE D.id=M.id `\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":200,"wires":[["a3b8efa8.b03d7"]]},{"id":"a3b8efa8.b03d7","type":"sqlite","z":"a281f193.619d7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":200,"wires":[["58b60fbf.d021"]]},{"id":"249ac803.206fa8","type":"function","z":"a281f193.619d7","name":"1 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":360,"wires":[[]]},{"id":"58b60fbf.d021","type":"switch","z":"a281f193.619d7","name":"Empty or not","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":360,"wires":[["a4b979b1.864698"],["6123b37e.7bf90c"]]},{"id":"a4b979b1.864698","type":"function","z":"a281f193.619d7","name":"Basket already clear","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Корзина пуста\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":320,"wires":[[]]},{"id":"532ce8ab.8f8058","type":"subflow:a281f193.619d7","z":"c61231f7.8068a","name":"","env":[],"x":560,"y":240,"wires":[[]]},{"id":"6123b37e.7bf90c","type":"function","z":"a281f193.619d7","name":"array length","func":"msg.amount_of_items = msg.payload.length\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":460,"wires":[["6b81b216.3f9a1c"]]},{"id":"6b81b216.3f9a1c","type":"switch","z":"a281f193.619d7","name":"How much items in basket do we have","property":"amount_of_items","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":6,"x":610,"y":460,"wires":[["249ac803.206fa8"],["f243d558.ff9778"],["fd88f753.170bb8"],["4b556889.f14548"],["dbfb2560.0b77b8"],["a0af9ba9.4566c8"]]},{"id":"f243d558.ff9778","type":"function","z":"a281f193.619d7","name":"2 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":400,"wires":[[]]},{"id":"fd88f753.170bb8","type":"function","z":"a281f193.619d7","name":"3 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":440,"wires":[[]]},{"id":"4b556889.f14548","type":"function","z":"a281f193.619d7","name":"4 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":480,"wires":[[]]},{"id":"dbfb2560.0b77b8","type":"function","z":"a281f193.619d7","name":"5 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[4].brand+\"</b></font><font color=#777777><br>\"+msg.payload[4].model+\"</font><font color=#48c72c> \"+msg.payload[4].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"Image\":msg.payload[4].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[4].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":520,"wires":[[]]},{"id":"a0af9ba9.4566c8","type":"function","z":"a281f193.619d7","name":"6 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[4].brand+\"</b></font><font color=#777777><br>\"+msg.payload[4].model+\"</font><font color=#48c72c> \"+msg.payload[4].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"Image\":msg.payload[4].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[4].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[5].brand+\"</b></font><font color=#777777><br>\"+msg.payload[5].model+\"</font><font color=#48c72c> \"+msg.payload[5].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[5].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[5].url,\n \"Image\":msg.payload[5].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[5].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[5].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":560,"wires":[[]]},{"id":"669a9e91.b55bc","type":"switch","z":"c71fceb2.e323f","name":"Learn More","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"cont","v":"MoreInfo","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":420,"wires":[["bcd866c7.8328a8"],["bc4a8448.593868"]]},{"id":"d415d3df.37a87","type":"function","z":"6e15ed1c.05f3d4","name":"Send Message \"Ручной ввод\"","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Введи номер формата 380ххххххххх\",\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":910,"y":220,"wires":[[]]},{"id":"4a606ae0.4772f4","type":"sqlite","z":"6e15ed1c.05f3d4","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":670,"y":220,"wires":[["d415d3df.37a87"]]},{"id":"715ec7de.e50518","type":"function","z":"6e15ed1c.05f3d4","name":"Set InputStatus 0","func":"msg.topic = `UPDATE User_Data_VB SET phone_inputStatus = 1 WHERE id_viber = \"${msg.payload.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":220,"wires":[["4a606ae0.4772f4"]]},{"id":"dc5e4e5e.9be1d","type":"function","z":"c761d7f6.2970e8","name":"Get info from DB","func":"var string = msg.req.body.message.text;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `SELECT brand,model,size,type,price,url_image FROM Database WHERE id = \"${number}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":240,"wires":[["fb511fed.dc085"]]},{"id":"fb511fed.dc085","type":"sqlite","z":"c761d7f6.2970e8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":590,"y":240,"wires":[["d3c3afe9.c6181"]]},{"id":"d3c3afe9.c6181","type":"function","z":"c761d7f6.2970e8","name":"Send message with Info","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Информация о паре обуви:\\nБренд - \"+msg.payload[0].brand+\"\\nМодель - \"+msg.payload[0].model+\"\\nДоступные размеры: \"+msg.payload[0].size+\"\\nЦена без учёта скидки - \"+msg.payload[0].price+\" грн\",\n \n \n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgMediaType\": \"picture\",\n\t\t\t\"BgMedia\": \"https://img.ans-media.com/files/sc_staging_images/product/large_img_2576340.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Boots\",\n \"Text\":\"Ботинки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n \n },\n {\n \"BgMediaType\": \"picture\",\n \"BgMedia\": \"https://images.ua.prom.st/1914761302_kedy-kopiya-converse.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-1\",\n \"Text\":\"Кеды\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n {\n \n \n \"BgMedia\": \"https://crossplus.com.ua/content/images/1/muzhskie-krossovki-adidas-iniki-runner-boost-31957844966906_small11.jpeg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-2\",\n \"Text\":\"Кроссовки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://s3.eu-central-1.amazonaws.com/helen-marlen/catalog/product/cache/0/image/400x/040ec09b1e35df139433887a97daa66f/7/f/7ff712f50b28ed63598838924079b1af.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Moccasins\",\n \"Text\":\"Мокасины\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://static.wittchen.com/zdjecia/skorzane-polbuty-meskie-1-91-M-902-1-41/thumb_480x449/5f4792d3982ae.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Shoes\",\n \"Text\":\"Туфли\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgLoop\": true,\n \"BgMedia\": \"https://static.wikia.nocookie.net/shararam-smeshi/images/7/7d/%D0%A1%D1%82%D1%80%D0%B5%D0%BB%D0%BA%D0%B0_%D0%B2%D0%BB%D0%B5%D0%B2%D0%BE.gif/revision/latest?cb=20150401153013&path-prefix=ru\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Back\",\n \"Text\":\"Назад\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n \n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":790,"y":240,"wires":[[]]},{"id":"bcd866c7.8328a8","type":"subflow:c761d7f6.2970e8","z":"c71fceb2.e323f","name":"","env":[],"x":450,"y":380,"wires":[[]]},{"id":"5b50e40c.5e202c","type":"function","z":"ddbac507.dbd058","name":"get infro from Database","func":"msg.topic = `SELECT id,url,url_image,brand,model,price FROM Database WHERE type = \"${msg.req.body.message.text}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":400,"wires":[["bf67a5a1.eafde8"]]},{"id":"34e244b1.1b501c","type":"subflow:e1e0c44d.006b38","z":"ddbac507.dbd058","name":"","env":[],"x":580,"y":540,"wires":[[]]},{"id":"bf67a5a1.eafde8","type":"sqlite","z":"ddbac507.dbd058","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":790,"y":400,"wires":[["a91743b4.a21f2"]]},{"id":"cc55448f.d56b98","type":"switch","z":"ddbac507.dbd058","name":"Category Check","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"eq","v":"Boots","vt":"str"},{"t":"eq","v":"Sneakers-1","vt":"str"},{"t":"eq","v":"Sneakers-2","vt":"str"},{"t":"eq","v":"Moccasins","vt":"str"},{"t":"eq","v":"Shoes","vt":"str"},{"t":"eq","v":"Back","vt":"str"}],"checkall":"true","repair":false,"outputs":6,"x":320,"y":400,"wires":[["5b50e40c.5e202c"],["5b50e40c.5e202c"],["5b50e40c.5e202c"],["5b50e40c.5e202c"],["5b50e40c.5e202c"],["34e244b1.1b501c"]]},{"id":"a91743b4.a21f2","type":"function","z":"ddbac507.dbd058","name":"Carousel","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\",\n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\" </b></font><font color=#777777>\"+msg.payload[0].model+\" </font><font color=#6fc133> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\" </b></font><font color=#777777>\"+msg.payload[1].model+\" </font><font color=#6fc133>\"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\": msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\" </b></font><font color=#777777>\"+msg.payload[2].model+\" </font><font color=#6fc133>\"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\": msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\" </b></font><font color=#777777>\"+msg.payload[3].model+\" </font><font color=#6fc133>\"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\": msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[4].brand+\" </b></font><font color=#777777>\"+msg.payload[4].model+\" </font><font color=#6fc133>\"+msg.payload[5].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\": msg.payload[4].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"Image\":msg.payload[4].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[5].brand+\" </b></font><font color=#777777>\"+msg.payload[5].model+\" </font><font color=#6fc133>\"+msg.payload[5].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\": msg.payload[5].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[5].url,\n \"Image\":msg.payload[5].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[5].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>В корзину</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\": \"AddToBasket \"+msg.payload[5].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#62aacc\"\n \n },\n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgMediaType\": \"picture\",\n\t\t\t\"BgMedia\": \"https://img.ans-media.com/files/sc_staging_images/product/large_img_2576340.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Boots\",\n \"Text\":\"Ботинки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n \n },\n {\n \"BgMediaType\": \"picture\",\n \"BgMedia\": \"https://images.ua.prom.st/1914761302_kedy-kopiya-converse.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-1\",\n \"Text\":\"Кеды\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n {\n \n \n \"BgMedia\": \"https://crossplus.com.ua/content/images/1/muzhskie-krossovki-adidas-iniki-runner-boost-31957844966906_small11.jpeg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Sneakers-2\",\n \"Text\":\"Кроссовки\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://s3.eu-central-1.amazonaws.com/helen-marlen/catalog/product/cache/0/image/400x/040ec09b1e35df139433887a97daa66f/7/f/7ff712f50b28ed63598838924079b1af.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Moccasins\",\n \"Text\":\"Мокасины\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgMedia\": \"https://static.wittchen.com/zdjecia/skorzane-polbuty-meskie-1-91-M-902-1-41/thumb_480x449/5f4792d3982ae.jpg\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Shoes\",\n \"Text\":\"Туфли\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"right\",\n },\n {\n \"BgColor\": \"#ccd141\",\n \"BgLoop\": true,\n \"BgMedia\": \"https://static.wikia.nocookie.net/shararam-smeshi/images/7/7d/%D0%A1%D1%82%D1%80%D0%B5%D0%BB%D0%BA%D0%B0_%D0%B2%D0%BB%D0%B5%D0%B2%D0%BE.gif/revision/latest?cb=20150401153013&path-prefix=ru\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Back\",\n \"Text\":\"Назад\",\n \"TextSize\":\"large\",\n \"TextVAlign\": \"top\",\n \"TextHAlign\": \"left\",\n },\n \n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":960,"y":400,"wires":[[]]},{"id":"bc4a8448.593868","type":"subflow:ddbac507.dbd058","z":"c71fceb2.e323f","name":"","env":[],"x":440,"y":460,"wires":[[]]},{"id":"89c33edc.99304","type":"function","z":"dec3397.f5f9fc8","name":"Delete from DB","func":"var string = msg.req.body.message.text;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `DELETE FROM \"${msg.payload[0].phone}\" WHERE id =\"${number}\"`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":260,"wires":[["37c90fe6.4cc6"]]},{"id":"37c90fe6.4cc6","type":"sqlite","z":"dec3397.f5f9fc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":630,"y":260,"wires":[["5160bddf.844714"]]},{"id":"5160bddf.844714","type":"function","z":"dec3397.f5f9fc8","name":"Send Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Товар убран из корзины\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":260,"wires":[[]]},{"id":"4ef9dc51.51c074","type":"function","z":"dec3397.f5f9fc8","name":"Get info from DB","func":"msg.topic = `SELECT D.id,url,url_image,brand,model,type,price FROM Database D LEFT JOIN \"${msg.payload[0].phone}\" M WHERE D.id=M.id `\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":610,"y":560,"wires":[["bfcacf40.e7775"]]},{"id":"bfcacf40.e7775","type":"sqlite","z":"dec3397.f5f9fc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":810,"y":560,"wires":[["16428d56.a0b4e3"]]},{"id":"35367e5.bcc5182","type":"function","z":"dec3397.f5f9fc8","name":"1 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":520,"wires":[[]]},{"id":"16428d56.a0b4e3","type":"switch","z":"dec3397.f5f9fc8","name":"Empty or not","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":970,"y":560,"wires":[["d6fc816a.10806"],["a334896c.a79e18"]]},{"id":"a334896c.a79e18","type":"function","z":"dec3397.f5f9fc8","name":"array length","func":"msg.amount_of_items = msg.payload.length\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1190,"y":620,"wires":[["43a6f7ee.5dab88"]]},{"id":"43a6f7ee.5dab88","type":"switch","z":"dec3397.f5f9fc8","name":"How much items in basket do we have","property":"amount_of_items","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":6,"x":1470,"y":620,"wires":[["35367e5.bcc5182"],["f9116633.0dc068"],["32ebcf11.851b8"],["bfd6eae8.987588"],["7b2389ec.c2b1b8"],["1d70298.c99cad7"]]},{"id":"f9116633.0dc068","type":"function","z":"dec3397.f5f9fc8","name":"2 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":560,"wires":[[]]},{"id":"32ebcf11.851b8","type":"function","z":"dec3397.f5f9fc8","name":"3 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":600,"wires":[[]]},{"id":"bfd6eae8.987588","type":"function","z":"dec3397.f5f9fc8","name":"4 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":640,"wires":[[]]},{"id":"7b2389ec.c2b1b8","type":"function","z":"dec3397.f5f9fc8","name":"5 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[4].brand+\"</b></font><font color=#777777><br>\"+msg.payload[4].model+\"</font><font color=#48c72c> \"+msg.payload[4].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"Image\":msg.payload[4].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[4].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":680,"wires":[[]]},{"id":"1d70298.c99cad7","type":"function","z":"dec3397.f5f9fc8","name":"6 position","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 7,\n \"type\":\"rich_media\",\n \"rich_media\": {\n \"text\":\"Все позиции в корзине:\",\n \"Type\":\"rich_media\",\n \"ButtonsGroupColumns\":6,\n \"ButtonsGroupRows\":7,\n \"BgColor\":\"#5324a3\", \n \n \"Buttons\":[\n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[0].brand+\"</b></font><font color=#777777><br>\"+msg.payload[0].model+\"</font><font color=#48c72c> \"+msg.payload[0].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[0].url,\n \"Image\":msg.payload[0].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[0].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[0].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[1].brand+\"</b></font><font color=#777777><br>\"+msg.payload[1].model+\"</font><font color=#48c72c> \"+msg.payload[1].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[1].url,\n \"Image\":msg.payload[1].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[1].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[1].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[2].brand+\"</b></font><font color=#777777><br>\"+msg.payload[2].model+\"</font><font color=#48c72c> \"+msg.payload[2].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[2].url,\n \"Image\":msg.payload[2].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[2].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[2].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[3].brand+\"</b></font><font color=#777777><br>\"+msg.payload[3].model+\"</font><font color=#48c72c> \"+msg.payload[3].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[3].url,\n \"Image\":msg.payload[3].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[3].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[3].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[4].brand+\"</b></font><font color=#777777><br>\"+msg.payload[4].model+\"</font><font color=#48c72c> \"+msg.payload[4].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[4].url,\n \"Image\":msg.payload[4].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[4].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[4].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n {\n \"Columns\":6,\n \"Rows\":1,\n \"Text\":\"<font color=#323232><b>\"+msg.payload[5].brand+\"</b></font><font color=#777777><br>\"+msg.payload[5].model+\"</font><font color=#48c72c> \"+msg.payload[5].price+\" грн</font>\",\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[5].url,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\"\n \n },\n {\n \"Columns\":6,\n \"Rows\":5,\n \"ActionType\":\"open-url\",\n \"ActionBody\":msg.payload[5].url,\n \"Image\":msg.payload[5].url_image,\n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Узнать больше</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"MoreInfo \"+msg.payload[5].id,\n \"TextSize\":\"medium\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#6ac490\"\n \n },\n {\n \"Columns\":3,\n \"Rows\":1,\n \"Text\":\"<font color=#f70202>Убрать из корзины</font>\",\n \"ActionType\":\"reply\",\n \"ActionBody\":\"DeleteFromBasket \"+msg.payload[5].id,\n \"TextSize\":\"small\",\n \"TextVAlign\":\"top\",\n \"TextHAlign\":\"middle\",\n \"BgColor\" : \"#a30b41\"\n \n },\n \n \n \n ]\n },\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n \n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":720,"wires":[[]]},{"id":"d6fc816a.10806","type":"function","z":"dec3397.f5f9fc8","name":"Basket is empty","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Корзина пуста\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":460,"wires":[[]]},{"id":"ee67ed9b.a2266","type":"subflow:dec3397.f5f9fc8","z":"c61231f7.8068a","name":"","env":[],"x":570,"y":400,"wires":[[]]},{"id":"62734447.1d598c","type":"subflow:61e699d3.bad628","z":"36bce78a.5b1d38","name":"","env":[],"x":460,"y":540,"wires":[["e3799996.ccc898"]]},{"id":"1be69193.1d947e","type":"function","z":"aa4e0ad4.553da8","name":"Send Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\n\nmsg.method = \"POST\";\nmsg.url = send_message;\n\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\n\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Введи номер телефона, на который Вы зарегистрированы в другом мессенджере.\\nФормата 380xxxxxxxxx\",\n \"keyboard\": {\n\t\t\"Buttons\": [{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"IAmNotRegistered\",\n\t\t\t\"Text\": \"Я не зарегистрирован\",\n\t\t}],\n\t\t\"DefaultHeight\" : \"true\",\n\t\t\n\t}\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":440,"wires":[[]]},{"id":"74d5565c.56bab8","type":"function","z":"aa4e0ad4.553da8","name":"Update already_register to 1","func":"msg.topic = `UPDATE User_Data_VB SET already_registered = 1 WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":380,"wires":[["4bbabc49.c6dd44"]]},{"id":"4bbabc49.c6dd44","type":"sqlite","z":"aa4e0ad4.553da8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":870,"y":380,"wires":[[]]},{"id":"a4c35c6e.4852c","type":"switch","z":"8a7eef08.275f6","name":"Already Registered 1 or 0","property":"payload[0].already_registered","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":190,"y":360,"wires":[["609390e.cf8f67"],[]]},{"id":"58d8d3c6.04fb4c","type":"function","z":"8a7eef08.275f6","name":"Get Already Registered","func":"msg.topic = `SELECT already_registered FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":120,"wires":[["a5f9b481.e50928"]]},{"id":"a5f9b481.e50928","type":"sqlite","z":"8a7eef08.275f6","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":120,"wires":[["a4c35c6e.4852c"]]},{"id":"a7db3e6f.676f","type":"switch","z":"8a7eef08.275f6","name":"Check if contains 380","property":"phone_number","propertyType":"msg","rules":[{"t":"eq","v":"380","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":680,"y":260,"wires":[["9e05d81b.519cb8"],["484e8210.713f1c"]]},{"id":"484e8210.713f1c","type":"function","z":"8a7eef08.275f6","name":"Input Error","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Неверный формат номера, попробуй ещё раз\",\n \"keyboard\": {\n\t\t\"Buttons\": [{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"IAmNotRegistered\",\n\t\t\t\"Text\": \"Я не зарегистрирован\",\n\t\t}],\n\t\t\"DefaultHeight\" : \"true\",\n\t\t\n\t}\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1290,"y":240,"wires":[[]]},{"id":"9e05d81b.519cb8","type":"function","z":"8a7eef08.275f6","name":"Check_Amount_Of_Numbers","func":"msg.check_amount_of_phone_numbers = msg.req.body.message.text.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":140,"wires":[["d1dd291f.084658"]]},{"id":"d1dd291f.084658","type":"switch","z":"8a7eef08.275f6","name":"Check Amount of Numbers","property":"check_amount_of_phone_numbers","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1040,"y":140,"wires":[["dfb0a4fb.df80b8"],["484e8210.713f1c"]]},{"id":"dfb0a4fb.df80b8","type":"function","z":"8a7eef08.275f6","name":"Check Number Exists","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE phone = \"${msg.req.body.message.text}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1300,"y":100,"wires":[["16c11a43.6bd6d6"]]},{"id":"16c11a43.6bd6d6","type":"sqlite","z":"8a7eef08.275f6","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1490,"y":100,"wires":[["1f99b064.87be5"]]},{"id":"60085880.3392c8","type":"function","z":"8a7eef08.275f6","name":"There is no Number in DB","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Такого номера нет в базе\",\n \"keyboard\": {\n\t\t\"Buttons\": [{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"IAmNotRegistered\",\n\t\t\t\"Text\": \"Я не зарегистрирован\",\n\t\t}],\n\t\t\"DefaultHeight\" : \"true\",\n\t\t\n\t}\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1990,"y":180,"wires":[[]]},{"id":"1f99b064.87be5","type":"switch","z":"8a7eef08.275f6","name":"Check Number Exists","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"nempty"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":1700,"y":100,"wires":[["98b45b43.a51038","f2dd9259.936aa","e97dc5ce.d355b8"],["60085880.3392c8"]]},{"id":"98b45b43.a51038","type":"function","z":"8a7eef08.275f6","name":"Success Message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Ты успешно ввёл данные\\nНиже ты можешь увидеть меню, в котором описаны все мои функции\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1970,"y":120,"wires":[[]]},{"id":"f2dd9259.936aa","type":"function","z":"8a7eef08.275f6","name":"Already Registered = 0","func":"msg.topic = `UPDATE User_Data_VB SET already_registered = 0,phone = \"${msg.req.body.message.text}\" WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1980,"y":60,"wires":[["dd744f8d.00c85"]]},{"id":"dd744f8d.00c85","type":"sqlite","z":"8a7eef08.275f6","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":2210,"y":60,"wires":[[]]},{"id":"6d1e4d8.49137b4","type":"inject","z":"36bce78a.5b1d38","name":"User_Data_TG","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"CREATE TABLE User_Data_TG (role CHAR,id_telegram CHAR, username CHAR,phone CHAR,phone_inputStatus CHAR, already_registered CHAR,category_status CHAR,last_category CHAR,basket_check CHAR,phone_Manually CHAR)","payload":"","payloadType":"date","x":600,"y":140,"wires":[["9e29c8c5.fa06f8"]]},{"id":"2fa6561e.e4dc8a","type":"sqlite","z":"bcbb1b33.d50ad8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":570,"y":140,"wires":[[]]},{"id":"b8486bff.2c4f68","type":"function","z":"bcbb1b33.d50ad8","name":"Creating Basket","func":"\nmsg.topic = `CREATE TABLE \"${msg.payload.message.contact.phone_number}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":140,"wires":[["2fa6561e.e4dc8a"]]},{"id":"b4d24e9e.dffbd","type":"sqlite","z":"fea15d6c.58e16","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1930,"y":420,"wires":[[]]},{"id":"4a130b7a.d7f0b4","type":"function","z":"fea15d6c.58e16","name":"create user basket","func":"\nmsg.topic = `CREATE TABLE \"${msg.req.body.message.text}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1690,"y":420,"wires":[["b4d24e9e.dffbd"]]},{"id":"61fa63bf.03714c","type":"http request","z":"61e699d3.bad628","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":830,"y":160,"wires":[[]]},{"id":"9da3a7ba.de5618","type":"http in","z":"61e699d3.bad628","name":"","url":"/send_message","method":"post","upload":false,"swaggerDoc":"","x":860,"y":200,"wires":[[]]},{"id":"5e0696f1.25c378","type":"delay","z":"da6310b4.82f05","name":"delay for not to overload flow","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":300,"wires":[["7c9a070d.c38c08"]]},{"id":"b6366859.cd9288","type":"function","z":"c34e9bdb.bbc688","name":"Get phone from db","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":200,"wires":[["cf0e448d.93e768"]]},{"id":"cf0e448d.93e768","type":"sqlite","z":"c34e9bdb.bbc688","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1190,"y":200,"wires":[["d4b47b57.c2f668"]]},{"id":"91372c4.8a95bd","type":"function","z":"c34e9bdb.bbc688","name":"Get phone from DB","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":200,"wires":[["c1d7fbb3.857f28"]]},{"id":"c1d7fbb3.857f28","type":"sqlite","z":"c34e9bdb.bbc688","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":390,"y":200,"wires":[["78799791.9689b8"]]},{"id":"2b98c41f.608e6c","type":"function","z":"a281f193.619d7","name":"Get phone from DB","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":120,"wires":[["a4115a3a.677ff8"]]},{"id":"a4115a3a.677ff8","type":"sqlite","z":"a281f193.619d7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":120,"wires":[["8600b067.a0597"]]},{"id":"e2667ff5.6782f","type":"function","z":"4e27080.a1b7ff8","name":"Get phone from DB","func":"msg.topic =`SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":190,"y":400,"wires":[["3a0dd1c8.ef6e0e"]]},{"id":"3a0dd1c8.ef6e0e","type":"sqlite","z":"4e27080.a1b7ff8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":370,"y":400,"wires":[["cbffb822.885338"]]},{"id":"8d70241c.e945b8","type":"function","z":"dec3397.f5f9fc8","name":"Take DB name","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":140,"y":380,"wires":[["60c8d206.21b54c"]]},{"id":"60c8d206.21b54c","type":"sqlite","z":"dec3397.f5f9fc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":310,"y":380,"wires":[["89c33edc.99304","23e55bf6.3b33d4"]]},{"id":"23e55bf6.3b33d4","type":"delay","z":"dec3397.f5f9fc8","name":"For not to overload flow","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":490,"y":460,"wires":[["4ef9dc51.51c074"]]},{"id":"90da2142.390d6","type":"subflow:60725fdb.ab566","z":"36bce78a.5b1d38","name":"","env":[],"x":440,"y":380,"wires":[["dc24ff3e.66ed3"]]},{"id":"2146a657.b15d7a","type":"switch","z":"60725fdb.ab566","name":"Conv. Start","property":"payload.event","propertyType":"msg","rules":[{"t":"eq","v":"conversation_started","vt":"str"},{"t":"eq","v":"unsubscribed","vt":"str"},{"t":"eq","v":"message","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":430,"y":280,"wires":[["2c9362fe.327c6e"],["da712bb6.97b178"],["8a618f80.b8502"]]},{"id":"1a9037fa.76b998","type":"http request","z":"60725fdb.ab566","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1410,"y":220,"wires":[[]]},{"id":"867e0768.c9c288","type":"http in","z":"60725fdb.ab566","name":"","url":"/send_message","method":"post","upload":false,"swaggerDoc":"","x":1440,"y":260,"wires":[[]]},{"id":"15adc860.6ad678","type":"subflow:bcbb1b33.d50ad8","z":"60725fdb.ab566","name":"","env":[],"x":1050,"y":280,"wires":[["1a9037fa.76b998"]]},{"id":"da712bb6.97b178","type":"subflow:da6310b4.82f05","z":"60725fdb.ab566","name":"","env":[],"x":660,"y":280,"wires":[]},{"id":"2c9362fe.327c6e","type":"subflow:c6081279.fe8b6","z":"60725fdb.ab566","name":"","env":[],"x":660,"y":220,"wires":[["1a9037fa.76b998"]]},{"id":"8a618f80.b8502","type":"switch","z":"60725fdb.ab566","name":"Manually or Auto input phone","property":"payload.message.text","propertyType":"msg","rules":[{"t":"eq","v":"phone","vt":"str"},{"t":"eq","v":"NoAutoPhoneInput","vt":"str"},{"t":"eq","v":"IAmAlreadyRegistered","vt":"str"},{"t":"eq","v":"IAmNotRegistered","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":5,"x":700,"y":360,"wires":[["15adc860.6ad678"],["f1bd4254.bc6f6"],["9bc6f3d.14ea41"],["8cbc3497.38d0a8"],["bc3de897.c7d5d8"]]},{"id":"bc3de897.c7d5d8","type":"subflow:fea15d6c.58e16","z":"60725fdb.ab566","name":"","env":[],"x":1060,"y":440,"wires":[["1a9037fa.76b998"],["7c195350.ce442c"]]},{"id":"f1bd4254.bc6f6","type":"subflow:6e15ed1c.05f3d4","z":"60725fdb.ab566","name":"","env":[],"x":1040,"y":320,"wires":[["1a9037fa.76b998"]]},{"id":"9bc6f3d.14ea41","type":"subflow:aa4e0ad4.553da8","z":"60725fdb.ab566","name":"","env":[],"x":1070,"y":360,"wires":[["1a9037fa.76b998"]]},{"id":"5893f9e5.e7fb38","type":"function","z":"8e043e59.f15c5","name":"IAmNotRegistered message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\":3,\n \"type\":\"text\",\n \"text\":\"Выбери функцию\",\n \"keyboard\": {\n\t\t\"Buttons\": [{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"share-phone\",\n \"ActionBody\": \"phone\",\n\t\t\t\"Text\": \"Отправить номер\",\n\t\t},\n\t\t{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"NoAutoPhoneInput\",\n\t\t\t\"Text\": \"Вписать номер вручную\",\n\t\t},\n\t\t{\n\t\t \"BgColor\": \"#02baba\",\n\t\t\t\"ActionType\": \"reply\",\n \"ActionBody\": \"IAmAlreadyRegistered\",\n\t\t\t\"Text\": \"Я уже зарегистрирован в другом мессенджере\",\n\t\t}],\n\t\t\"DefaultHeight\" : \"true\",\n\t\t\"InputFieldState\" : \"hidden\",\n\t}\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":240,"wires":[[]]},{"id":"7c195350.ce442c","type":"subflow:8a7eef08.275f6","z":"60725fdb.ab566","name":"","env":[],"x":1310,"y":520,"wires":[["1a9037fa.76b998"],[]]},{"id":"e61e9718.3c1d38","type":"function","z":"8e043e59.f15c5","name":"already_registered = 0","func":"msg.topic = `UPDATE User_Data_VB SET already_registered = 0 WHERE id_viber = \"${msg.payload.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":200,"wires":[["a0ba53eb.607bb"]]},{"id":"a0ba53eb.607bb","type":"sqlite","z":"8e043e59.f15c5","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":770,"y":200,"wires":[[]]},{"id":"8cbc3497.38d0a8","type":"subflow:8e043e59.f15c5","z":"60725fdb.ab566","name":"","env":[],"x":1060,"y":400,"wires":[["1a9037fa.76b998"]]},{"id":"cc92ec72.b4a47","type":"sqlite","z":"9aeb7186.69057","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":630,"y":220,"wires":[[]]},{"id":"d9f7f366.9ed56","type":"function","z":"9aeb7186.69057","name":"role,id_viber,username","func":"msg.topic = `INSERT INTO User_Data_TG (role,id_telegram, username,phone_inputStatus,category_status,basket_check) VALUES (\"user\",\"${msg.req.body.message.from.id}\",\"${msg.req.body.message.from.first_name}\",1,0,0)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":220,"wires":[["cc92ec72.b4a47"]]},{"id":"64a1b2e4.24ad2c","type":"function","z":"9aeb7186.69057","name":"Hello Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"🤖 Привет! Я - бот-каталог для магазина SneakerShop. \\nМне нужно, чтобы ты указал свой номер телефона\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"keyboard\":[[\n {\n \"text\":\"Отправить номер автоматически\",\n \"request_contact\":true,\n \n },\n {\n \"text\":\"Ввести вручную\"\n \n }\n ]],\n \"one_time_keyboard\":true,\n \"resize_keyboard\":true,\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":340,"wires":[["7e6824e9.39222c"]]},{"id":"bd719245.5a7c9","type":"switch","z":"e9dffb2e.039e58","name":"Check if contains 380","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"cont","v":"380","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":520,"y":380,"wires":[["96e35a58.9b4258"],["ac101d2d.32dab"]]},{"id":"96e35a58.9b4258","type":"function","z":"e9dffb2e.039e58","name":"Check_Amount_Of_Numbers","func":"msg.check_amount_of_phone_numbers = msg.req.body.message.text.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":840,"y":300,"wires":[["ac9c2f0e.7149c"]]},{"id":"ac9c2f0e.7149c","type":"switch","z":"e9dffb2e.039e58","name":"Check Amount of Numbers","property":"check_amount_of_phone_numbers","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1140,"y":300,"wires":[["353176e3.c79a6a","fc2eeed8.92686"],["ac101d2d.32dab"]]},{"id":"ac101d2d.32dab","type":"function","z":"e9dffb2e.039e58","name":"Input Error","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Неверный формат номера. Повтори попытку\",\n \"chat_id\": msg.req.body.message.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1410,"y":400,"wires":[[]]},{"id":"313cc906.935db6","type":"sqlite","z":"e9dffb2e.039e58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1650,"y":120,"wires":[["3996debd.3f9f82"]]},{"id":"353176e3.c79a6a","type":"function","z":"e9dffb2e.039e58","name":"Set Input Status to 0","func":"msg.topic = `UPDATE User_Data_TG SET phone_inputStatus = 0 WHERE id_telegram = \"${msg.req.body.message.chat.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1420,"y":120,"wires":[["313cc906.935db6"]]},{"id":"529b00ad.dadf8","type":"sqlite","z":"e9dffb2e.039e58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":2050,"y":200,"wires":[["420cae19.2832d"]]},{"id":"3996debd.3f9f82","type":"function","z":"e9dffb2e.039e58","name":"Insert Phone to DB","func":"msg.topic = `UPDATE User_Data_TG SET phone = \"${msg.req.body.message.text}\" WHERE id_telegram = \"${msg.req.body.message.chat.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1830,"y":200,"wires":[["529b00ad.dadf8"]]},{"id":"420cae19.2832d","type":"function","z":"e9dffb2e.039e58","name":"Success Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Ты успешно ввёл данные!\\nНиже ты можешь увидеть мои функции\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2270,"y":120,"wires":[[]]},{"id":"d265436a.7ddbf","type":"sqlite","z":"e9dffb2e.039e58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1730,"y":300,"wires":[[]]},{"id":"fc2eeed8.92686","type":"function","z":"e9dffb2e.039e58","name":"create user basket","func":"msg.topic = `CREATE TABLE \"${msg.req.body.message.text}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1490,"y":300,"wires":[["d265436a.7ddbf"]]},{"id":"8b6b1942.566d28","type":"subflow:e9dffb2e.039e58","z":"8c1865f9.3f7bc8","name":"","env":[],"x":1090,"y":180,"wires":[[]]},{"id":"e9fc3739.7587c8","type":"sqlite","z":"8c1865f9.3f7bc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1430,"y":400,"wires":[[]]},{"id":"ad49f5a0.108b28","type":"function","z":"8c1865f9.3f7bc8","name":"Get phone from DB","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE phone = \"${msg.req.body.message.text}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":340,"wires":[["d6f08324.b3d76"]]},{"id":"d6f08324.b3d76","type":"sqlite","z":"8c1865f9.3f7bc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":690,"y":340,"wires":[["17a906d9.08f209"]]},{"id":"17a906d9.08f209","type":"switch","z":"8c1865f9.3f7bc8","name":"Exists or not","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":340,"wires":[["8b6b1942.566d28"],["8cb63e9c.53015","31b51a1f.452716","1537a61d.ca4eea","7417371.0ca6fc8","e9651ae3.4158a8"]]},{"id":"8cb63e9c.53015","type":"function","z":"8c1865f9.3f7bc8","name":"Already in DB","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Этот номер уже зарегистрирован. Аккаунты Viber и Telegram синхронизированы.\",\n \"chat_id\": msg.req.body.message.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1160,"y":260,"wires":[[]]},{"id":"4a2d9fa3.1ba6f","type":"switch","z":"8c1865f9.3f7bc8","name":"Check status inputPhone","property":"payload[0].phone_inputStatus","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":420,"wires":[["ad49f5a0.108b28"],[]]},{"id":"146319a6.dd5466","type":"function","z":"8c1865f9.3f7bc8","name":"select input_Status","func":"msg.topic = `SELECT phone_inputStatus FROM User_Data_TG WHERE id_telegram = \"${msg.payload.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":240,"wires":[["fd4ce741.601228"]]},{"id":"31b51a1f.452716","type":"function","z":"8c1865f9.3f7bc8","name":"inputStatus = 0","func":"msg.topic = `UPDATE User_Data_TG SET phone_inputStatus = 0 WHERE id_telegram=\"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1160,"y":360,"wires":[["e9fc3739.7587c8"]]},{"id":"1537a61d.ca4eea","type":"function","z":"8c1865f9.3f7bc8","name":"phone to DB","func":"msg.topic = `UPDATE User_Data_TG SET phone = \"${msg.req.body.message.text}\" WHERE id_telegram=\"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1150,"y":400,"wires":[["e9fc3739.7587c8"]]},{"id":"7417371.0ca6fc8","type":"function","z":"8c1865f9.3f7bc8","name":"Success Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Ты успешно ввёл данные!\\nНиже ты можешь увидеть мои функции\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1170,"y":300,"wires":[[]]},{"id":"e9651ae3.4158a8","type":"function","z":"8c1865f9.3f7bc8","name":"create user basket","func":"\nmsg.topic = `CREATE TABLE \"${msg.req.body.message.text}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1170,"y":440,"wires":[["e9fc3739.7587c8"]]},{"id":"b4a683c4.58bad","type":"subflow:9aeb7186.69057","z":"d8982748.1d99e8","name":"","env":[],"x":900,"y":240,"wires":[[]]},{"id":"f4293894.fd8ea8","type":"switch","z":"d8982748.1d99e8","name":"inputStatus","property":"payload[0].phone_inputStatus","propertyType":"msg","rules":[{"t":"null"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":320,"wires":[["b4a683c4.58bad"],["b4a683c4.58bad"],["41efc035.2366e"]]},{"id":"b48c1de8.52816","type":"function","z":"d8982748.1d99e8","name":"Get phone_inputStatus","func":"msg.topic = `SELECT phone_inputStatus FROM User_data_TG WHERE id_telegram =\"${msg.payload.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":320,"wires":[["ef515b5f.f96b58"]]},{"id":"ef515b5f.f96b58","type":"sqlite","z":"d8982748.1d99e8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":450,"y":320,"wires":[["f4293894.fd8ea8"]]},{"id":"41efc035.2366e","type":"function","z":"d8982748.1d99e8","name":"Already Registered","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Ты уже зарегистрирован.\\n\\nУдаление аккаунта произойдёт только в мессенджере Telegram.\\nДля удаления из Viber удалите чат с ботом.\\n\\nЖелаете удалить свой аккаунт?\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Удалить аккаунт из TG\",\n \"callback_data\": \"Delete_Account\" \n },\n {\n \"text\": \"Вернуться\",\n \"callback_data\": \"Get_Back\" \n },\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":910,"y":380,"wires":[[]]},{"id":"87e384aa.1a8ee8","type":"switch","z":"69a66f9a.09815","name":"main callback data","property":"req.body.callback_query.data","propertyType":"msg","rules":[{"t":"eq","v":"Menu","vt":"str"},{"t":"eq","v":"Get_Back","vt":"str"},{"t":"eq","v":"Category","vt":"str"},{"t":"eq","v":"Basket","vt":"str"},{"t":"eq","v":"Delete_Account","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":190,"y":200,"wires":[["cb22e386.5eb"],["f0ef2adf.aa3118"],["e412bb66.6290d8"],["5f69bce8.3bc984"],["ef20ee85.edab7"]]},{"id":"f0ef2adf.aa3118","type":"function","z":"69a66f9a.09815","name":"Get Back","func":"var send_message = env.get(\"TELEGRAM_EDIT_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Главное меню:\",\n \"message_id\":msg.req.body.callback_query.message.message_id,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":140,"wires":[["8a627b76.bcb2c8"]]},{"id":"e412bb66.6290d8","type":"function","z":"69a66f9a.09815","name":"Category","func":"var send_message = env.get(\"TELEGRAM_EDIT_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Категории\",\n \"message_id\":msg.req.body.callback_query.message.message_id,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Ботинки\",\n \"callback_data\": \"Boots\" \n },\n {\n \"text\": \"Кеды\",\n \"callback_data\": \"Sneakers-1\" \n }, \n ],\n \n [\n {\n \"text\": \"Кроссовки\",\n \"callback_data\": \"Sneakers-2\" \n }, \n {\n \"text\": \"Мокасины\",\n \"callback_data\": \"Moccasins\" \n }, \n ],\n \n [\n {\n \"text\": \"Туфли\",\n \"callback_data\": \"Shoes\" \n }, \n {\n \"text\": \"Назад\",\n \"callback_data\": \"Get_Back\" \n }, \n ]\n \n ]\n }\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":180,"wires":[[]]},{"id":"5f69bce8.3bc984","type":"function","z":"69a66f9a.09815","name":"Basket","func":"var send_message = env.get(\"TELEGRAM_EDIT_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Корзина\",\n \"message_id\":msg.req.body.callback_query.message.message_id,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Просмотреть корзину\",\n \"callback_data\": \"Check_Basket\" \n },\n {\n \"text\": \"Очистить корзину\",\n \"callback_data\": \"Clear_Basket\" \n }, \n ],\n \n [\n {\n \"text\": \"Оплатить товар\",\n \"callback_data\": \"Buy_Basket\" \n }, \n ],\n \n [\n {\n \"text\": \"Назад\",\n \"callback_data\": \"Get_Back\" \n }, \n ]\n \n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":220,"wires":[[]]},{"id":"746860d7.aacad","type":"subflow:69a66f9a.09815","z":"8265f79d.547d38","name":"","env":[],"x":350,"y":260,"wires":[[]]},{"id":"ee34235.a6e0ae","type":"subflow:9ceb0f78.78d99","z":"8265f79d.547d38","name":"","env":[],"x":340,"y":320,"wires":[[]]},{"id":"6eadca5e.a2f6d4","type":"switch","z":"9ceb0f78.78d99","name":"Category CallBack data","property":"req.body.callback_query.data","propertyType":"msg","rules":[{"t":"eq","v":"Boots","vt":"str"},{"t":"eq","v":"Sneakers-1","vt":"str"},{"t":"eq","v":"Sneakers-2","vt":"str"},{"t":"eq","v":"Moccasins","vt":"str"},{"t":"eq","v":"Shoes","vt":"str"},{"t":"eq","v":"Next","vt":"str"},{"t":"eq","v":"Previous","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":270,"y":360,"wires":[["f201d05d.972cf"],["f201d05d.972cf"],["f201d05d.972cf"],["f201d05d.972cf"],["f201d05d.972cf"],["62e1ea01.31f764"],["235cdd32.7c4552"]]},{"id":"d25b3da.0c288c","type":"function","z":"9ceb0f78.78d99","name":"get category_status","func":"msg.topic = `SELECT category_status FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":510,"y":240,"wires":[["c700d207.fd833"]]},{"id":"c700d207.fd833","type":"sqlite","z":"9ceb0f78.78d99","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":710,"y":240,"wires":[["89defac3.9e2458"]]},{"id":"89defac3.9e2458","type":"function","z":"9ceb0f78.78d99","name":"get info from DB","func":"msg.category_status = msg.payload[0].category_status;\nmsg.topic = `SELECT id,url,url_image,brand,model,price,size FROM Database WHERE type = \"${msg.req.body.callback_query.data}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":880,"y":240,"wires":[["ac80931b.11a29"]]},{"id":"ac80931b.11a29","type":"sqlite","z":"9ceb0f78.78d99","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1050,"y":240,"wires":[["3c1700eb.4f384","8a9494eb.8cfb78"]]},{"id":"f0d7a916.452a18","type":"function","z":"9ceb0f78.78d99","name":"Send Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[0].brand+\"\\nМодель: \"+msg.payload[0].model+\"\\nДоступные размеры: \"+msg.payload[0].size+\"\\nЦена: \"+msg.payload[0].price,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous\"\n }\n ],\n [\n {\n \"text\":\"В корзину\",\n \"callback_data\":\"AddToBasket \"+msg.payload[0].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1440,"y":320,"wires":[[]]},{"id":"e3799996.ccc898","type":"subflow:8265f79d.547d38","z":"36bce78a.5b1d38","name":"","env":[],"x":770,"y":540,"wires":[["a3230171.e7eeb"]]},{"id":"6ac55c7a.3c24c4","type":"function","z":"8c1865f9.3f7bc8","name":"select input_Status","func":"msg.topic = `SELECT phone_inputStatus FROM User_Data_TG WHERE id_telegram = \"${msg.payload.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":200,"wires":[["fd4ce741.601228"]]},{"id":"fd4ce741.601228","type":"sqlite","z":"8c1865f9.3f7bc8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":590,"y":220,"wires":[["4a2d9fa3.1ba6f"]]},{"id":"f201d05d.972cf","type":"function","z":"9ceb0f78.78d99","name":"set last_category ","func":"msg.topic = `UPDATE User_Data_TG SET last_category = \"${msg.req.body.callback_query.data}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":180,"wires":[["9e9bfc74.db575"]]},{"id":"9e9bfc74.db575","type":"sqlite","z":"9ceb0f78.78d99","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":650,"y":180,"wires":[["d25b3da.0c288c"]]},{"id":"c2f8206f.7ec03","type":"function","z":"2bfd919c.f0f68e","name":"category_status increase","func":"msg.topic = `UPDATE User_Data_TG SET category_status = category_status+1 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":360,"wires":[["43ed8492.68242c"]]},{"id":"f2bd5a65.3541f8","type":"switch","z":"2bfd919c.f0f68e","name":"if more than 5","property":"payload[0].category_status","propertyType":"msg","rules":[{"t":"eq","v":"5","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":120,"y":300,"wires":[["18b0c189.cc678e"],["c2f8206f.7ec03"]]},{"id":"f38ef235.bf30e","type":"function","z":"2bfd919c.f0f68e","name":"get category_status","func":"msg.topic = `SELECT category_status FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":80,"wires":[["cf496b9d.263d68"]]},{"id":"cf496b9d.263d68","type":"sqlite","z":"2bfd919c.f0f68e","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":430,"y":80,"wires":[["f2bd5a65.3541f8"]]},{"id":"18b0c189.cc678e","type":"function","z":"2bfd919c.f0f68e","name":"category_status= 0","func":"msg.topic = `UPDATE User_Data_TG SET category_status = 0 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":240,"wires":[["43ed8492.68242c"]]},{"id":"43ed8492.68242c","type":"sqlite","z":"2bfd919c.f0f68e","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":570,"y":300,"wires":[["d8b83507.f20308"]]},{"id":"d8b83507.f20308","type":"function","z":"2bfd919c.f0f68e","name":"Get infro from DB","func":"msg.topic = `SELECT category_status,last_category FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":300,"wires":[["26dd6d7b.ea4572"]]},{"id":"26dd6d7b.ea4572","type":"sqlite","z":"2bfd919c.f0f68e","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":890,"y":300,"wires":[["1d7217c7.10eee8"]]},{"id":"1d7217c7.10eee8","type":"function","z":"2bfd919c.f0f68e","name":"Get info from DB","func":"msg.category_status = msg.payload[0].category_status;\nmsg.last_category = msg.payload[0].last_category;\nmsg.topic = `SELECT id,url,url_image,brand,model,price,size FROM Database WHERE type = \"${msg.last_category}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1070,"y":300,"wires":[["b310df11.cc601"]]},{"id":"b310df11.cc601","type":"sqlite","z":"2bfd919c.f0f68e","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1270,"y":300,"wires":[["321cb293.bdc54e","dc390301.1fbe2"]]},{"id":"9fff7e63.9bc3d","type":"function","z":"2bfd919c.f0f68e","name":"Send Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[msg.category_status].brand+\"\\nМодель: \"+msg.payload[msg.category_status].model+\"\\nДоступные размеры: \"+msg.payload[msg.category_status].size+\"\\nЦена: \"+msg.payload[msg.category_status].price,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous\"\n }\n ],\n [\n {\n \"text\":\"В корзину\",\n \"callback_data\":\"AddToBasket \"+msg.payload[msg.category_status].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1680,"y":200,"wires":[[]]},{"id":"62e1ea01.31f764","type":"subflow:2bfd919c.f0f68e","z":"9ceb0f78.78d99","name":"","env":[],"x":550,"y":420,"wires":[[]]},{"id":"2e68af60.e57ff","type":"function","z":"f033b019.ef1b3","name":"get category_status","func":"msg.topic = `SELECT category_status FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":100,"wires":[["69095294.cc93bc"]]},{"id":"69095294.cc93bc","type":"sqlite","z":"f033b019.ef1b3","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":450,"y":100,"wires":[["fda0d975.846d78"]]},{"id":"fda0d975.846d78","type":"switch","z":"f033b019.ef1b3","name":"if less than 0","property":"payload[0].category_status","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":280,"wires":[["517c318c.5a63d"],["78bcbe31.d0e2a"]]},{"id":"517c318c.5a63d","type":"function","z":"f033b019.ef1b3","name":"Category status = 5","func":"msg.topic = `UPDATE User_Data_TG SET category_status = 5 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":220,"wires":[["7efe6a21.1ff994"]]},{"id":"7efe6a21.1ff994","type":"sqlite","z":"f033b019.ef1b3","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":670,"y":280,"wires":[["53dcc0a5.8eb08"]]},{"id":"78bcbe31.d0e2a","type":"function","z":"f033b019.ef1b3","name":"category status decrease","func":"msg.topic = `UPDATE User_Data_TG SET category_status = category_status-1 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":340,"wires":[["7efe6a21.1ff994"]]},{"id":"53dcc0a5.8eb08","type":"function","z":"f033b019.ef1b3","name":"Get info from DB","func":"msg.topic = `SELECT category_status,last_category FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":280,"wires":[["5e0965f.551649c"]]},{"id":"5e0965f.551649c","type":"sqlite","z":"f033b019.ef1b3","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1050,"y":280,"wires":[["9439eb84.76f2d8"]]},{"id":"9439eb84.76f2d8","type":"function","z":"f033b019.ef1b3","name":"Get info from DB","func":"msg.category_status = msg.payload[0].category_status;\nmsg.last_category = msg.payload[0].last_category;\nmsg.topic = `SELECT id,url,url_image,brand,model,price,size FROM Database WHERE type = \"${msg.last_category}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1250,"y":280,"wires":[["532be186.927d4"]]},{"id":"532be186.927d4","type":"sqlite","z":"f033b019.ef1b3","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1430,"y":280,"wires":[["77f889fa.f0db08","692d3025.aabec"]]},{"id":"e8b8b05f.6cfad","type":"function","z":"f033b019.ef1b3","name":"Send Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[msg.category_status].brand+\"\\nМодель: \"+msg.payload[msg.category_status].model+\"\\nДоступные размеры: \"+msg.payload[msg.category_status].size+\"\\nЦена: \"+msg.payload[msg.category_status].price,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous\"\n }\n ],\n [\n {\n \"text\":\"В корзину\",\n \"callback_data\":\"AddToBasket \"+msg.payload[msg.category_status].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1780,"y":160,"wires":[[]]},{"id":"235cdd32.7c4552","type":"subflow:f033b019.ef1b3","z":"9ceb0f78.78d99","name":"","env":[],"x":550,"y":460,"wires":[[]]},{"id":"8a627b76.bcb2c8","type":"function","z":"69a66f9a.09815","name":"Make Category status Basket Status = 0","func":"msg.topic = `UPDATE User_Data_TG SET category_status = 0,basket_check = 0 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":140,"wires":[["5d4f3b6c.ea2ab4"]]},{"id":"5d4f3b6c.ea2ab4","type":"sqlite","z":"69a66f9a.09815","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1040,"y":140,"wires":[[]]},{"id":"606477f9.186af8","type":"subflow:efab7df5.d9e61","z":"8265f79d.547d38","name":"","env":[],"x":310,"y":380,"wires":[[]]},{"id":"ddea6472.75d1d8","type":"switch","z":"efab7df5.d9e61","name":"Check Function Basket","property":"req.body.callback_query.data","propertyType":"msg","rules":[{"t":"eq","v":"Check_Basket","vt":"str"},{"t":"eq","v":"Next_Basket","vt":"str"},{"t":"eq","v":"Previous_Basket","vt":"str"},{"t":"eq","v":"Clear_Basket","vt":"str"},{"t":"eq","v":"Buy_Basket","vt":"str"},{"t":"cont","v":"AddToBasket","vt":"str"},{"t":"cont","v":"DeleteFromBasket","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":330,"y":300,"wires":[["640b702d.40bab"],["a276ee63.ef4a5"],["f41c98c7.e053e8"],["6727d53f.3eec7c"],["ac3b018a.2fbe1"],["b94d6c68.a2aff"],["b1efc01c.3c1aa"]]},{"id":"d44301cf.81f91","type":"function","z":"56b45400.f580cc","name":"get id from phone(db)","func":"msg.phone = msg.payload[0].phone\n\nvar string = msg.req.body.callback_query.data;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `SELECT id FROM \"${msg.payload[0].phone}\" WHERE id =\"${number}\"`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":200,"y":140,"wires":[["4492d606.00a418"]]},{"id":"63e0b83d.b60288","type":"function","z":"56b45400.f580cc","name":"get phone","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":200,"y":60,"wires":[["c45dc81d.606958"]]},{"id":"c45dc81d.606958","type":"sqlite","z":"56b45400.f580cc","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":370,"y":60,"wires":[["d44301cf.81f91"]]},{"id":"2e5cbb14.94d4f4","type":"switch","z":"56b45400.f580cc","name":"null or not","property":"payload[0]","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":140,"y":300,"wires":[["49ea9967.e7f378"],["c9f2027b.009f6"]]},{"id":"43456b53.459534","type":"function","z":"56b45400.f580cc","name":"insert to basket","func":"var string = msg.req.body.callback_query.data;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `INSERT INTO \"${msg.payload[0].phone}\" (id) VALUES (\"${number}\")`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":120,"wires":[["de3f8966.6e9fe8"]]},{"id":"de3f8966.6e9fe8","type":"sqlite","z":"56b45400.f580cc","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1230,"y":120,"wires":[["8fc26c2a.afd7e"]]},{"id":"e188b0fa.02afd","type":"function","z":"56b45400.f580cc","name":"get phone","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":120,"wires":[["7b555c8a.49a084"]]},{"id":"7b555c8a.49a084","type":"sqlite","z":"56b45400.f580cc","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":890,"y":120,"wires":[["43456b53.459534"]]},{"id":"8fc26c2a.afd7e","type":"function","z":"56b45400.f580cc","name":"success message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Товар добавлен в корзину\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1430,"y":120,"wires":[[]]},{"id":"c9f2027b.009f6","type":"function","z":"56b45400.f580cc","name":"already in basket","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Товар уже в корзине\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":360,"wires":[[]]},{"id":"4492d606.00a418","type":"sqlite","z":"56b45400.f580cc","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":390,"y":140,"wires":[["2e5cbb14.94d4f4"]]},{"id":"b94d6c68.a2aff","type":"subflow:56b45400.f580cc","z":"efab7df5.d9e61","name":"","env":[],"x":670,"y":380,"wires":[[]]},{"id":"e03a8174.6c4cb","type":"function","z":"9ecd215f.b77f7","name":"Delete from","func":"msg.topic =`DELETE FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":420,"wires":[["6b0ee018.e0c66"]]},{"id":"6b0ee018.e0c66","type":"sqlite","z":"9ecd215f.b77f7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":420,"wires":[["fb40eae0.ee5b28"]]},{"id":"fb40eae0.ee5b28","type":"function","z":"9ecd215f.b77f7","name":"Send message","func":"var send_message = env.get(\"TELEGRAM_EDIT_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Корзина очищена\",\n \"message_id\":msg.req.body.callback_query.message.message_id,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n },\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ],\n \n \n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":420,"wires":[[]]},{"id":"3b851be5.802824","type":"sqlite","z":"9ecd215f.b77f7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":390,"y":300,"wires":[["e03a8174.6c4cb"]]},{"id":"6727d53f.3eec7c","type":"subflow:9ecd215f.b77f7","z":"efab7df5.d9e61","name":"","env":[],"x":660,"y":300,"wires":[[]]},{"id":"4e26eec0.f752c","type":"function","z":"9ecd215f.b77f7","name":"get phone","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":240,"y":300,"wires":[["3b851be5.802824"]]},{"id":"3dfd3d00.b1d894","type":"switch","z":"8c1865f9.3f7bc8","name":"type of message","property":"msg.payload.message.from.id","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":140,"y":220,"wires":[["6ac55c7a.3c24c4"],["146319a6.dd5466"]]},{"id":"6dfe2568.09818c","type":"function","z":"68c38691.5e9888","name":"Get info from DB","func":"msg.topic = `SELECT basket_check,phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":140,"wires":[["6626acaa.113ab4"]]},{"id":"6626acaa.113ab4","type":"sqlite","z":"68c38691.5e9888","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":370,"y":140,"wires":[["4a53e53.e8e831c"]]},{"id":"4a53e53.e8e831c","type":"function","z":"68c38691.5e9888","name":"Get info from DB","func":"msg.basket_check = msg.payload[0].basket_check;\nmsg.phone = msg.payload[0].phone;\nmsg.topic = `SELECT D.id,url,url_image,brand,model,type,price,size FROM Database D LEFT JOIN \"${msg.phone}\" M WHERE D.id=M.id `\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":220,"wires":[["984c85f6.4007f8"]]},{"id":"984c85f6.4007f8","type":"sqlite","z":"68c38691.5e9888","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":370,"y":220,"wires":[["671ba7f9.fc8558"]]},{"id":"6bb12862.29d618","type":"function","z":"68c38691.5e9888","name":"Send_Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[msg.basket_check].brand+\"\\nМодель: \"+msg.payload[msg.basket_check].model+\"\\nДоступные размеры: \"+msg.payload[msg.basket_check].size+\"\\nЦена: \"+msg.payload[msg.basket_check].price + \" грн\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next_Basket\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous_Basket\"\n }\n ],\n [\n {\n \"text\":\"Удалить из корзины\",\n \"callback_data\":\"DeleteFromBasket \"+msg.payload[msg.basket_check].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":380,"wires":[[]]},{"id":"640b702d.40bab","type":"subflow:68c38691.5e9888","z":"efab7df5.d9e61","name":"","env":[],"x":670,"y":180,"wires":[[]]},{"id":"a276ee63.ef4a5","type":"subflow:8de7f599.4e50a8","z":"efab7df5.d9e61","name":"","env":[],"x":690,"y":220,"wires":[[]]},{"id":"80b33af2.be2f18","type":"function","z":"69aec46f.aba83c","name":"Get info from DB","func":"msg.topic = `SELECT basket_check,phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":100,"wires":[["242b1d7.8f53ee2"]]},{"id":"242b1d7.8f53ee2","type":"sqlite","z":"69aec46f.aba83c","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":100,"wires":[["1527b130.97cf2f"]]},{"id":"1527b130.97cf2f","type":"function","z":"69aec46f.aba83c","name":"Get Count","func":"msg.basket_check = msg.payload[0].basket_check\nmsg.topic = `SELECT COUNT(*) AS \"Count11\" FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":190,"y":200,"wires":[["6fa4def2.14069"]]},{"id":"6fa4def2.14069","type":"sqlite","z":"69aec46f.aba83c","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":200,"wires":[["3c4b868e.555c8a"]]},{"id":"3c4b868e.555c8a","type":"switch","z":"69aec46f.aba83c","name":"Less or not","property":"basket_check","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":170,"y":340,"wires":[["b52861cd.d8f83"],["47025f2a.4025c"]]},{"id":"b52861cd.d8f83","type":"function","z":"69aec46f.aba83c","name":"if less","func":"msg.topic = `UPDATE User_Data_TG SET basket_check = \"${msg.payload[0].Count11 - 1}\" WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":300,"wires":[["cb12dc85.17ebd"]]},{"id":"cb12dc85.17ebd","type":"sqlite","z":"69aec46f.aba83c","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":340,"wires":[["d0832f5d.a2d74"]]},{"id":"d0832f5d.a2d74","type":"function","z":"69aec46f.aba83c","name":"Get info from DB","func":"msg.topic = `SELECT basket_check,phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":670,"y":340,"wires":[["64d000ff.1f2db"]]},{"id":"64d000ff.1f2db","type":"sqlite","z":"69aec46f.aba83c","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":830,"y":340,"wires":[["db6f7ca4.df851"]]},{"id":"ede242b3.748c","type":"function","z":"69aec46f.aba83c","name":"Send message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[msg.basket_check].brand+\"\\nМодель: \"+msg.payload[msg.basket_check].model+\"\\nДоступные размеры: \"+msg.payload[msg.basket_check].size+\"\\nЦена: \"+msg.payload[msg.basket_check].price,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next_Basket\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous_Basket\"\n }\n ],\n [\n {\n \"text\":\"Удалить из корзины\",\n \"callback_data\":\"DeleteFromBasket \"+msg.payload[msg.basket_check].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":220,"wires":[[]]},{"id":"db6f7ca4.df851","type":"function","z":"69aec46f.aba83c","name":"Get info from DB","func":"msg.basket_check = msg.payload[0].basket_check;\nmsg.phone = msg.payload[0].phone;\nmsg.topic = `SELECT D.id,url,url_image,brand,model,type,price,size FROM Database D LEFT JOIN \"${msg.phone}\" M WHERE D.id=M.id `\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":990,"y":340,"wires":[["8aede7d.3f47518"]]},{"id":"8aede7d.3f47518","type":"sqlite","z":"69aec46f.aba83c","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1170,"y":340,"wires":[["ecfb3d0e.bd234","10cfc825.47b418"]]},{"id":"47025f2a.4025c","type":"function","z":"69aec46f.aba83c","name":"if not","func":"msg.topic = `UPDATE User_Data_TG SET basket_check = basket_check - 1 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":380,"wires":[["cb12dc85.17ebd"]]},{"id":"f41c98c7.e053e8","type":"subflow:69aec46f.aba83c","z":"efab7df5.d9e61","name":"","env":[],"x":710,"y":260,"wires":[[]]},{"id":"dd482276.4527d","type":"function","z":"4782995d.094808","name":"Delete from DB","func":"var string = msg.req.body.callback_query.data;\nvar number = string.split(\" \")[1];\n\nmsg.topic = `DELETE FROM \"${msg.payload[0].phone}\" WHERE id =\"${number}\"`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":80,"wires":[["c947cc88.4216b"]]},{"id":"c947cc88.4216b","type":"sqlite","z":"4782995d.094808","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":770,"y":80,"wires":[["f19baf44.83fef"]]},{"id":"f19baf44.83fef","type":"function","z":"4782995d.094808","name":"Send Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Товар убран из корзины\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":80,"wires":[[]]},{"id":"e9ca218.90c38e","type":"function","z":"4782995d.094808","name":"Take name of the table","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":80,"wires":[["6d396f25.0f027","7c1b405e.8697e"]]},{"id":"6d396f25.0f027","type":"sqlite","z":"4782995d.094808","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":80,"wires":[["dd482276.4527d"]]},{"id":"b1efc01c.3c1aa","type":"subflow:4782995d.094808","z":"efab7df5.d9e61","name":"","env":[],"x":690,"y":420,"wires":[[]]},{"id":"3c1700eb.4f384","type":"function","z":"9ceb0f78.78d99","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[0].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1250,"y":180,"wires":[[]]},{"id":"8a9494eb.8cfb78","type":"delay","z":"9ceb0f78.78d99","name":"For not to overload","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1230,"y":320,"wires":[["f0d7a916.452a18"]]},{"id":"321cb293.bdc54e","type":"function","z":"2bfd919c.f0f68e","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[msg.category_status].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1450,"y":380,"wires":[[]]},{"id":"dc390301.1fbe2","type":"delay","z":"2bfd919c.f0f68e","name":"Fro not to overload","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1470,"y":200,"wires":[["9fff7e63.9bc3d"]]},{"id":"692d3025.aabec","type":"function","z":"f033b019.ef1b3","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[msg.category_status].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1590,"y":360,"wires":[[]]},{"id":"77f889fa.f0db08","type":"delay","z":"f033b019.ef1b3","name":"For not to overload","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1590,"y":160,"wires":[["e8b8b05f.6cfad"]]},{"id":"a3639c3d.58e7d","type":"function","z":"68c38691.5e9888","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[msg.basket_check].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":460,"wires":[[]]},{"id":"fbb249d4.94ed18","type":"delay","z":"68c38691.5e9888","name":"Fro not to OVL","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":380,"wires":[["6bb12862.29d618"]]},{"id":"671ba7f9.fc8558","type":"switch","z":"68c38691.5e9888","name":"empty or not","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":170,"y":340,"wires":[["c976e8aa.b763e8"],["fbb249d4.94ed18","a3639c3d.58e7d","b3501b31.026c88"]]},{"id":"c976e8aa.b763e8","type":"function","z":"68c38691.5e9888","name":"Basket clear","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Корзина пуста\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n },\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ],\n \n \n ]\n }\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":320,"wires":[[]]},{"id":"ecfb3d0e.bd234","type":"delay","z":"69aec46f.aba83c","name":"For not to OVL","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1260,"y":220,"wires":[["ede242b3.748c"]]},{"id":"10cfc825.47b418","type":"function","z":"69aec46f.aba83c","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[msg.basket_check].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1270,"y":420,"wires":[[]]},{"id":"4e0755b8.39f49c","type":"function","z":"8de7f599.4e50a8","name":"Get info from DB","func":"msg.topic = `SELECT basket_check,phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":120,"wires":[["2072c1f3.587a5e"]]},{"id":"2072c1f3.587a5e","type":"sqlite","z":"8de7f599.4e50a8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":120,"wires":[["9912edef.358a4"]]},{"id":"9912edef.358a4","type":"function","z":"8de7f599.4e50a8","name":"Get Count from DB","func":"msg.basket_check = msg.payload[0].basket_check\nmsg.topic = `SELECT COUNT(*) AS \"Count11\" FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":200,"wires":[["7dd5f789.ed3808"]]},{"id":"7dd5f789.ed3808","type":"sqlite","z":"8de7f599.4e50a8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":200,"wires":[["4c604072.ffda"]]},{"id":"305159a9.fc1206","type":"switch","z":"8de7f599.4e50a8","name":"more r not","property":"basket_check","propertyType":"msg","rules":[{"t":"eq","v":"payload[0].Count11","vt":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":170,"y":360,"wires":[["3a00eeef.cecb12"],["9ce8f0f7.f11f2"]]},{"id":"3a00eeef.cecb12","type":"function","z":"8de7f599.4e50a8","name":"If more","func":"msg.topic = `UPDATE User_Data_TG SET basket_check = 0 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":320,"wires":[["280e012.a023ffe"]]},{"id":"280e012.a023ffe","type":"sqlite","z":"8de7f599.4e50a8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":490,"y":360,"wires":[["9e9a154c.9575c8"]]},{"id":"9e9a154c.9575c8","type":"function","z":"8de7f599.4e50a8","name":"Get info from DB","func":"msg.topic = `SELECT basket_check,phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":360,"wires":[["5f29b187.06ec3"]]},{"id":"5f29b187.06ec3","type":"sqlite","z":"8de7f599.4e50a8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":870,"y":360,"wires":[["10885136.232eef"]]},{"id":"d5387e29.423bd","type":"function","z":"8de7f599.4e50a8","name":"Send Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Бренд: \"+msg.payload[msg.basket_check].brand+\"\\nМодель: \"+msg.payload[msg.basket_check].model+\"\\nДоступные размеры: \"+msg.payload[msg.basket_check].size+\"\\nЦена: \"+msg.payload[msg.basket_check].price,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [\n [\n {\n \"text\":\"Далее\",\n \"callback_data\":\"Next_Basket\"\n },\n {\n \"text\":\"Назад\",\n \"callback_data\":\"Previous_Basket\"\n }\n ],\n [\n {\n \"text\":\"Удалить из корзины\",\n \"callback_data\":\"DeleteFromBasket \"+msg.payload[msg.basket_check].id\n }\n ],\n [\n {\n \"text\":\"Меню\",\n \"callback_data\":\"Menu\"\n }\n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1600,"y":280,"wires":[[]]},{"id":"10885136.232eef","type":"function","z":"8de7f599.4e50a8","name":"Get info from DB","func":"msg.basket_check = msg.payload[0].basket_check;\nmsg.phone = msg.payload[0].phone;\nmsg.topic = `SELECT D.id,url,url_image,brand,model,type,price,size FROM Database D LEFT JOIN \"${msg.phone}\" M WHERE D.id=M.id `\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1070,"y":360,"wires":[["f7a7d664.378f68"]]},{"id":"f7a7d664.378f68","type":"sqlite","z":"8de7f599.4e50a8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1270,"y":360,"wires":[["9f12d6b1.061448","f8ee8478.b0df18"]]},{"id":"9ce8f0f7.f11f2","type":"function","z":"8de7f599.4e50a8","name":"If not","func":"msg.topic = `UPDATE User_Data_TG SET basket_check = basket_check +1 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":420,"wires":[["280e012.a023ffe"]]},{"id":"9f12d6b1.061448","type":"delay","z":"8de7f599.4e50a8","name":"For not to OVL","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1420,"y":280,"wires":[["d5387e29.423bd"]]},{"id":"f8ee8478.b0df18","type":"function","z":"8de7f599.4e50a8","name":"Send Photo","func":"var send_photo = env.get(\"TELEGRAM_SEND_PHOTO\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_photo;\n\nmsg.payload = {\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"photo\": msg.payload[msg.basket_check].url_image\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1410,"y":400,"wires":[[]]},{"id":"4c604072.ffda","type":"function","z":"8de7f599.4e50a8","name":"parseInt","func":"msg.basket_check = parseInt(msg.basket_check) +1\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":200,"wires":[["305159a9.fc1206"]]},{"id":"a3230171.e7eeb","type":"http request","z":"36bce78a.5b1d38","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1050,"y":460,"wires":[[]],"icon":"font-awesome/fa-certificate"},{"id":"b8e1e94b.5ff0c8","type":"http in","z":"36bce78a.5b1d38","name":"","url":"/send_message","method":"post","upload":false,"swaggerDoc":"","x":1080,"y":500,"wires":[[]]},{"id":"7e6824e9.39222c","type":"debug","z":"9aeb7186.69057","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":500,"wires":[]},{"id":"b35b68f7.f37a88","type":"switch","z":"61e699d3.bad628","name":"bot_command or not","property":"payload.message.entities[0].type","propertyType":"msg","rules":[{"t":"eq","v":"bot_command","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":220,"y":200,"wires":[["fd5ecc54.49a5d"],["a9d3b3e9.6c967"]]},{"id":"df888581.ae8068","type":"function","z":"1b39f8a3.d7f8b7","name":"Insert phone","func":"msg.phone = msg.req.body.message.contact.phone_number.slice(-12);\nmsg.topic = `UPDATE User_Data_TG SET phone = \"${msg.phone}\" WHERE id_telegram = \"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":270,"y":240,"wires":[["fa4974ad.effb18"]]},{"id":"fa4974ad.effb18","type":"sqlite","z":"1b39f8a3.d7f8b7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":240,"wires":[["5251a32e.9a9d5c","cceabc4.6866c4"]]},{"id":"d351f812.683128","type":"function","z":"1b39f8a3.d7f8b7","name":"check sync","func":"msg.phone_number = msg.req.body.message.contact.phone_number.slice(-12);\nmsg.topic = `SELECT phone FROM User_Data_VB WHERE phone = \"${msg.phone_number}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":270,"y":380,"wires":[["2d412e28.bca242"]]},{"id":"2d412e28.bca242","type":"sqlite","z":"1b39f8a3.d7f8b7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":380,"wires":[["4a3fdc78.38d854"]]},{"id":"4a3fdc78.38d854","type":"switch","z":"1b39f8a3.d7f8b7","name":"if exists","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":380,"wires":[["1adad457.21267c"]]},{"id":"1adad457.21267c","type":"function","z":"1b39f8a3.d7f8b7","name":"sync message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Найден зарегистрированный аккаунт в Viber. Аккаунты синхронизированы\",\n \"chat_id\":msg.req.body.message.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":380,"wires":[[]]},{"id":"1e19a638.f1a7fa","type":"function","z":"1b39f8a3.d7f8b7","name":"Success message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Главное меню:\",\n \"chat_id\": msg.req.body.message.from.id,\n \n \"reply_markup\": {\n \n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ],\n \n \n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":890,"y":240,"wires":[[]]},{"id":"5251a32e.9a9d5c","type":"delay","z":"1b39f8a3.d7f8b7","name":"For not to OVL","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":680,"y":200,"wires":[["c85822dc.2f142"]]},{"id":"9ce62f1f.6149c","type":"function","z":"1b39f8a3.d7f8b7","name":"Set phone_InputStatus = 0","func":"msg.topic = `UPDATE User_Data_TG SET phone_inputStatus = 0 WHERE id_telegram = \"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":160,"wires":[["44e8a020.1fb0e"]]},{"id":"44e8a020.1fb0e","type":"sqlite","z":"1b39f8a3.d7f8b7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":160,"wires":[[]]},{"id":"ef20ee85.edab7","type":"function","z":"69a66f9a.09815","name":"Make Category status Basket Status = 0","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":380,"wires":[["cfa6ec30.3bd62"]]},{"id":"cfa6ec30.3bd62","type":"sqlite","z":"69a66f9a.09815","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":540,"y":380,"wires":[["2d6bf2c8.2d6f9e","fd2d468e.15d0d8"]]},{"id":"2d6bf2c8.2d6f9e","type":"function","z":"69a66f9a.09815","name":"Make Category status Basket Status = 0","func":"msg.topic = `DELETE FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":380,"wires":[["7eaeb600.16e3dc"]]},{"id":"7eaeb600.16e3dc","type":"sqlite","z":"69a66f9a.09815","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1070,"y":380,"wires":[[]]},{"id":"fd2d468e.15d0d8","type":"function","z":"69a66f9a.09815","name":"Account deleted","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Аккаунт успешно удалён. Чтобы вернуться к боту пропишите /start\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":460,"wires":[[]]},{"id":"ec35418d.c4dc4","type":"function","z":"1b39f8a3.d7f8b7","name":"Create Basket","func":"msg.phone = msg.req.body.message.contact.phone_number.slice(-12);\nmsg.topic = `CREATE TABLE \"${msg.phone}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":200,"wires":[["37d618c3.2fc5c8"]]},{"id":"37d618c3.2fc5c8","type":"sqlite","z":"1b39f8a3.d7f8b7","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":200,"wires":[[]]},{"id":"33d0f5dc.26345a","type":"function","z":"d60ec569.fa2668","name":"Check_Amount_Of_Numbers","func":"msg.check_amount_of_phone_numbers = msg.req.body.message.text.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":120,"wires":[["faa2abad.829938"]]},{"id":"faa2abad.829938","type":"switch","z":"d60ec569.fa2668","name":"Check Amount of Numbers","property":"check_amount_of_phone_numbers","propertyType":"msg","rules":[{"t":"eq","v":"12","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":920,"y":120,"wires":[["768abcc6.4cf0a4","7d285a43.69c5b4","c2456784.83eed8","ce5d56f.78288a8"],["942b0cbb.1e418"]]},{"id":"942b0cbb.1e418","type":"function","z":"d60ec569.fa2668","name":"Input Error","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Неверный формат номера. Попробуй еще раз\",\n \"chat_id\": msg.req.body.message.from.id,\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1030,"y":300,"wires":[[]]},{"id":"804007de.12ef48","type":"sqlite","z":"d60ec569.fa2668","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1510,"y":80,"wires":[["eda22de.31bd9d"]]},{"id":"768abcc6.4cf0a4","type":"function","z":"d60ec569.fa2668","name":"Set Input Status to 0","func":"msg.topic = `UPDATE User_Data_TG SET phone_inputStatus = 0 WHERE id_telegram = \"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1280,"y":80,"wires":[["804007de.12ef48"]]},{"id":"16f0e5c1.5d5a5a","type":"sqlite","z":"d60ec569.fa2668","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":2090,"y":80,"wires":[["611c5969.5a0f08","2989dc99.a111e4"]]},{"id":"eda22de.31bd9d","type":"function","z":"d60ec569.fa2668","name":"Insert Phone to DB","func":"msg.topic = `UPDATE User_Data_TG SET phone = \"${msg.req.body.message.text}\" WHERE id_telegram = \"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1890,"y":80,"wires":[["16f0e5c1.5d5a5a"]]},{"id":"ecbbe3e9.3595e","type":"function","z":"d60ec569.fa2668","name":"Success Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Ты успешно зарегистрирован!\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"hide_keyboard\":true\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2450,"y":40,"wires":[[]]},{"id":"b0e0e0a5.51c05","type":"sqlite","z":"d60ec569.fa2668","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1510,"y":160,"wires":[[]]},{"id":"7d285a43.69c5b4","type":"function","z":"d60ec569.fa2668","name":"create user basket","func":"msg.topic = `CREATE TABLE \"${msg.req.body.message.text}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1270,"y":160,"wires":[["b0e0e0a5.51c05"]]},{"id":"7135150f.db10dc","type":"sqlite","z":"d60ec569.fa2668","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1510,"y":120,"wires":[[]]},{"id":"c2456784.83eed8","type":"function","z":"d60ec569.fa2668","name":"Set phone_Manually = 0","func":"msg.topic = `UPDATE User_Data_TG SET phone_Manually = 0 WHERE id_telegram = \"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1290,"y":120,"wires":[["7135150f.db10dc"]]},{"id":"ce5d56f.78288a8","type":"function","z":"d60ec569.fa2668","name":"check for sync with viber","func":"msg.topic = `SELECT phone FROM User_Data_VB WHERE phone = \"${msg.req.body.message.text}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1310,"y":220,"wires":[["7b580ac3.d144a4"]]},{"id":"7b580ac3.d144a4","type":"sqlite","z":"d60ec569.fa2668","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1510,"y":220,"wires":[["e6d9b722.e1ccd8"]]},{"id":"e6d9b722.e1ccd8","type":"switch","z":"d60ec569.fa2668","name":"if exists","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":1660,"y":220,"wires":[["f2139edf.32c7e"]]},{"id":"f2139edf.32c7e","type":"function","z":"d60ec569.fa2668","name":"sync message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Найден зарегистрированный аккаунт в Viber. Аккаунты синхронизированы\",\n \"chat_id\":msg.req.body.message.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1840,"y":220,"wires":[[]]},{"id":"fb5326ee.e096b8","type":"switch","z":"c97fc2aa.c8221","name":"Conversation Started","property":"payload.message.text","propertyType":"msg","rules":[{"t":"eq","v":"/start","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":240,"y":180,"wires":[["55b839c7.1e3348"],["82c51c58.d9e3"]]},{"id":"55b839c7.1e3348","type":"subflow:d8982748.1d99e8","z":"c97fc2aa.c8221","name":"","env":[],"x":480,"y":140,"wires":[[]]},{"id":"82c51c58.d9e3","type":"function","z":"c97fc2aa.c8221","name":"Unknown command","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Неизвестная команда\",\n \"chat_id\":msg.payload.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":220,"wires":[[]]},{"id":"fd5ecc54.49a5d","type":"subflow:c97fc2aa.c8221","z":"61e699d3.bad628","name":"","env":[],"x":430,"y":160,"wires":[["61fa63bf.03714c"]]},{"id":"e9d8e6ea.047038","type":"subflow:1b39f8a3.d7f8b7","z":"fc9c05b0.be2c58","name":"","env":[],"x":1020,"y":320,"wires":[[]]},{"id":"8e7f20dc.d4d5d","type":"switch","z":"fc9c05b0.be2c58","name":"contact or not","property":"req.body.message.contact","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":560,"y":200,"wires":[["4c737943.4a8f78"],["e9d8e6ea.047038"]]},{"id":"42d26e4b.a864a","type":"switch","z":"fc9c05b0.be2c58","name":"phone_inputStatus check","property":"payload[0].phone_inputStatus","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":170,"y":240,"wires":[["8e7f20dc.d4d5d"],["40bc62b.48cc59c"]]},{"id":"afeae0c6.dfa54","type":"function","z":"fc9c05b0.be2c58","name":"Get phone_inputStatus","func":"msg.topic = `SELECT phone_inputStatus FROM User_data_TG WHERE id_telegram =\"${msg.payload.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":40,"wires":[["ac331ee7.aeee3"]]},{"id":"4c737943.4a8f78","type":"switch","z":"fc9c05b0.be2c58","name":"manually or not","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"else"},{"t":"eq","v":"Ввести вручную","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":760,"y":160,"wires":[["378d8e29.a8a142"],["6951fd03.b028d4","4d70e884.631ad8"]]},{"id":"93ed98e1.54f3d8","type":"function","z":"fc9c05b0.be2c58","name":"Get phone_inputStatus","func":"msg.topic = `SELECT phone_inputStatus FROM User_data_TG WHERE id_telegram =\"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":120,"wires":[["ac331ee7.aeee3"]]},{"id":"ac331ee7.aeee3","type":"sqlite","z":"fc9c05b0.be2c58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":610,"y":80,"wires":[["42d26e4b.a864a"]]},{"id":"44ee2af7.1c7834","type":"switch","z":"fc9c05b0.be2c58","name":"callback or not","property":"payload.callback_query","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","repair":false,"outputs":2,"x":200,"y":80,"wires":[["afeae0c6.dfa54"],["93ed98e1.54f3d8"]]},{"id":"6951fd03.b028d4","type":"function","z":"fc9c05b0.be2c58","name":"message Manually","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Введи номер телефона формата\\n380ххххххххх\",\n \"chat_id\":msg.req.body.message.from.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":990,"y":240,"wires":[[]]},{"id":"378d8e29.a8a142","type":"function","z":"fc9c05b0.be2c58","name":"Get phone_Manually","func":"msg.topic = `SELECT phone_Manually FROM User_data_TG WHERE id_telegram =\"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":980,"y":100,"wires":[["895885d9.bf8368"]]},{"id":"895885d9.bf8368","type":"sqlite","z":"fc9c05b0.be2c58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1170,"y":100,"wires":[["c420099e.f24f98"]]},{"id":"d50dab04.721dc8","type":"sqlite","z":"fc9c05b0.be2c58","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1190,"y":180,"wires":[[]]},{"id":"c420099e.f24f98","type":"switch","z":"fc9c05b0.be2c58","name":"phone_Manually","property":"payload[0].phone_Manually","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1340,"y":100,"wires":[["79795cd8.b47784"]]},{"id":"40bc62b.48cc59c","type":"switch","z":"fc9c05b0.be2c58","name":"message or callback","property":"req.body.message.text","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":400,"wires":[["956f64aa.f426a8"],[]]},{"id":"956f64aa.f426a8","type":"function","z":"fc9c05b0.be2c58","name":"Unknown command","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Неизвестная команда\",\n \"chat_id\":msg.req.body.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1000,"y":400,"wires":[[]]},{"id":"79795cd8.b47784","type":"subflow:d60ec569.fa2668","z":"fc9c05b0.be2c58","name":"","env":[],"x":1560,"y":100,"wires":[[]]},{"id":"4d70e884.631ad8","type":"function","z":"fc9c05b0.be2c58","name":"set phone_Manually = 1","func":"msg.topic = `UPDATE User_Data_TG SET phone_Manually = 1 WHERE id_telegram =\"${msg.req.body.message.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1010,"y":180,"wires":[["d50dab04.721dc8"]]},{"id":"a9d3b3e9.6c967","type":"subflow:fc9c05b0.be2c58","z":"61e699d3.bad628","name":"","env":[],"x":450,"y":240,"wires":[["61fa63bf.03714c"],[]]},{"id":"c85822dc.2f142","type":"function","z":"1b39f8a3.d7f8b7","name":"Success message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Ты успешно зарегистрирован!\",\n \"chat_id\": msg.req.body.message.from.id,\n \n \"reply_markup\": {\n \"hide_keyboard\":true,\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":890,"y":160,"wires":[[]]},{"id":"cceabc4.6866c4","type":"delay","z":"1b39f8a3.d7f8b7","name":"For not to OVL","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":680,"y":260,"wires":[["1e19a638.f1a7fa"]]},{"id":"9d6f7682.5e4e58","type":"function","z":"d60ec569.fa2668","name":"Success Message","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Главное меню:\",\n \"chat_id\": msg.req.body.message.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2450,"y":120,"wires":[[]]},{"id":"611c5969.5a0f08","type":"delay","z":"d60ec569.fa2668","name":"For not to OVL","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2240,"y":40,"wires":[["ecbbe3e9.3595e"]]},{"id":"2989dc99.a111e4","type":"delay","z":"d60ec569.fa2668","name":"For not to OVL","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2240,"y":120,"wires":[["9d6f7682.5e4e58"]]},{"id":"97cc6740.4b79a8","type":"function","z":"d60ec569.fa2668","name":"Check 380 begins","func":"const phone = msg.req.body.message.text;\nconst phone_three_numbers = phone.slice(0,3);\nmsg.phone_numbers = phone_three_numbers;\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":280,"wires":[["ccb70ef1.7c073"]]},{"id":"ccb70ef1.7c073","type":"switch","z":"d60ec569.fa2668","name":"Check if begins with 380","property":"phone_numbers","propertyType":"msg","rules":[{"t":"eq","v":"380","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":280,"wires":[["33d0f5dc.26345a"],["942b0cbb.1e418"]]},{"id":"609390e.cf8f67","type":"function","z":"8a7eef08.275f6","name":"slice number","func":"msg.phone_number = msg.req.body.message.text.slice(0,3)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":300,"wires":[["a7db3e6f.676f"]]},{"id":"e97dc5ce.d355b8","type":"function","z":"8a7eef08.275f6","name":"Create basket","func":"msg.topic = `CREATE TABLE \"${msg.req.body.message.text}\" (key INT INCREMENT BY, id CHAR)`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1960,"y":20,"wires":[["7ed55e44.90262"]]},{"id":"7ed55e44.90262","type":"sqlite","z":"8a7eef08.275f6","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":2210,"y":20,"wires":[[]]},{"id":"7f843c77.2aa474","type":"function","z":"bcbb1b33.d50ad8","name":"check if already registered","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE phone = \"${msg.payload.message.contact.phone_number}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":280,"wires":[["1f85c392.4fe3dc"]]},{"id":"1f85c392.4fe3dc","type":"sqlite","z":"bcbb1b33.d50ad8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":630,"y":280,"wires":[["4c2656b3.92c478"]]},{"id":"4c2656b3.92c478","type":"switch","z":"bcbb1b33.d50ad8","name":"exists or not","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":810,"y":280,"wires":[["56b75564.dfd89c"]]},{"id":"56b75564.dfd89c","type":"function","z":"bcbb1b33.d50ad8","name":"Already reg. message","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Найден аккаунт в другом мессенджере. Аккаунты синхронизированы\",\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1020,"y":280,"wires":[[]]},{"id":"47cb831f.d1c37c","type":"delay","z":"bcbb1b33.d50ad8","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":340,"wires":[["7e52df9.e8b9e2"]]},{"id":"8b3e4ac8.380448","type":"switch","z":"fea15d6c.58e16","name":"Check if contains 380","property":"phone_number","propertyType":"msg","rules":[{"t":"eq","v":"380","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":860,"y":520,"wires":[["56fa0a2a.d124c4"],["7721776e.622d58"]]},{"id":"3793c8b3.51d758","type":"function","z":"fea15d6c.58e16","name":"slice number","func":"msg.phone_number = msg.req.body.message.text.slice(0,3)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":630,"y":540,"wires":[["8b3e4ac8.380448"]]},{"id":"bc49f2d0.234ec","type":"sqlite","z":"fea15d6c.58e16","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":1930,"y":380,"wires":[["fc095d6d.59612"]]},{"id":"a6491a.e26766e8","type":"function","z":"fea15d6c.58e16","name":"Check if exists","func":"\nmsg.topic = `SELECT phone FROM User_Data_TG WHERE phone = \"${msg.req.body.message.text}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1680,"y":380,"wires":[["bc49f2d0.234ec"]]},{"id":"fc095d6d.59612","type":"switch","z":"fea15d6c.58e16","name":"exists or not","property":"payload[0].phone","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":2110,"y":380,"wires":[["bf49140d.8ebff8"]]},{"id":"bf49140d.8ebff8","type":"function","z":"fea15d6c.58e16","name":"if exists","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Найден аккаунт в другом мессенджере. Аккаунты синхронизированы\",\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2300,"y":380,"wires":[[]]},{"id":"493424e.8e492dc","type":"delay","z":"fea15d6c.58e16","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2460,"y":320,"wires":[["dc488c11.23ebe"]]},{"id":"8862f5f7.c72348","type":"http request","z":"e683806a.488ab","name":"callback answer","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":540,"y":180,"wires":[[]],"icon":"font-awesome/fa-certificate"},{"id":"87b9902c.e3cc8","type":"function","z":"e683806a.488ab","name":"callback_answer","func":"var callback_answer = env.get(\"TELEGRAM_CALLBACK_ANSWER\")\n\nmsg.method = \"POST\";\n\nmsg.url = callback_answer\n\nmsg.payload = {\n \"callback_query_id\": msg.payload.callback_query.id,\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":180,"wires":[["8862f5f7.c72348"]]},{"id":"bd7e486a.056ff8","type":"subflow:e683806a.488ab","z":"36bce78a.5b1d38","name":"","env":[],"x":410,"y":500,"wires":[]},{"id":"b3501b31.026c88","type":"debug","z":"68c38691.5e9888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":210,"y":540,"wires":[]},{"id":"7c1b405e.8697e","type":"function","z":"4782995d.094808","name":"Take name of the table","func":"msg.topic = `UPDATE User_Data_TG SET basket_check = 0 WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":140,"wires":[["bd7c65ea.cfe618"]]},{"id":"bd7c65ea.cfe618","type":"sqlite","z":"4782995d.094808","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":410,"y":140,"wires":[[]]},{"id":"a001b760.f1ac38","type":"function","z":"a8eb2ba2.888468","name":"Buy Basket","func":"var send_message = env.get(\"TELEGRAM_EDIT_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Транзакция проведена успешно!\",\n \"message_id\":msg.req.body.callback_query.message.message_id,\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n },\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ],\n \n \n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":360,"wires":[[]]},{"id":"d5967dec.683d7","type":"function","z":"a8eb2ba2.888468","name":"Delete from","func":"msg.topic =`DELETE FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":310,"y":180,"wires":[["a4c14fe6.1795f"]]},{"id":"a4c14fe6.1795f","type":"sqlite","z":"a8eb2ba2.888468","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":490,"y":180,"wires":[[]]},{"id":"81adc3e2.73e51","type":"sqlite","z":"a8eb2ba2.888468","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":470,"y":60,"wires":[["d5967dec.683d7"]]},{"id":"784f60ba.cfacf","type":"function","z":"a8eb2ba2.888468","name":"get phone","func":"msg.topic = `SELECT phone FROM User_Data_TG WHERE id_telegram = \"${msg.req.body.callback_query.from.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":60,"wires":[["81adc3e2.73e51"]]},{"id":"ac3b018a.2fbe1","type":"subflow:a8eb2ba2.888468","z":"efab7df5.d9e61","name":"","env":[],"x":660,"y":340,"wires":[[]]},{"id":"8ca5caf5.af3b58","type":"function","z":"b5ae98db.c5b1c8","name":"Buy Basket","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Транзакция проведена успешно!\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":340,"wires":[[]]},{"id":"d974d911.8159e8","type":"function","z":"b5ae98db.c5b1c8","name":"Clear Basket","func":"msg.topic =`DELETE FROM \"${msg.payload[0].phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":160,"wires":[["f51cfb41.a667f8"]]},{"id":"f51cfb41.a667f8","type":"sqlite","z":"b5ae98db.c5b1c8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":160,"wires":[[]]},{"id":"b7b584f.1b5cc78","type":"function","z":"b5ae98db.c5b1c8","name":"Get phone from DB","func":"msg.topic =`SELECT phone FROM User_Data_VB WHERE id_viber = \"${msg.req.body.sender.id}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":100,"wires":[["823116f9.2b6468"]]},{"id":"823116f9.2b6468","type":"sqlite","z":"b5ae98db.c5b1c8","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":510,"y":100,"wires":[["d974d911.8159e8"]]},{"id":"cdf24d70.4dd51","type":"subflow:b5ae98db.c5b1c8","z":"c61231f7.8068a","name":"","x":550,"y":320,"wires":[[]]},{"id":"cb22e386.5eb","type":"function","z":"69a66f9a.09815","name":"Menu","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Главное меню:\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \"reply_markup\": {\n \"inline_keyboard\": [[\n {\n \"text\": \"Категории\",\n \"callback_data\": \"Category\" \n }, \n ],\n [\n {\n \"text\": \"Корзина\",\n \"callback_data\": \"Basket\" \n }, \n ]\n ]\n }\n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":100,"wires":[[]]},{"id":"1619fb47.e865b5","type":"function","z":"c34e9bdb.bbc688","name":"get array of basket","func":"msg.topic = `SELECT * FROM \"${msg.phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":360,"wires":[["80228242.d9122"]]},{"id":"80228242.d9122","type":"sqlite","z":"c34e9bdb.bbc688","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":570,"y":320,"wires":[["2f86ad97.a5cc32"]]},{"id":"2f86ad97.a5cc32","type":"function","z":"c34e9bdb.bbc688","name":"set length_basket","func":"msg.length_basket = msg.payload.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":360,"wires":[["2a03ab69.6886c4"]]},{"id":"2a03ab69.6886c4","type":"switch","z":"c34e9bdb.bbc688","name":"is full or not","property":"length_basket","propertyType":"msg","rules":[{"t":"lt","v":"6","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":830,"y":280,"wires":[["b6366859.cd9288"],["3310728c.048bfe"]]},{"id":"3310728c.048bfe","type":"function","z":"c34e9bdb.bbc688","name":"Basket is full","func":"var send_message = env.get(\"VIBER_SEND_MESSAGE\")\nvar token_viber = env.get(\"TOKEN_VIBER\")\nmsg.method = \"POST\";\nmsg.url = send_message;\nmsg.headers = {\n \"X-Viber-Auth-Token\": token_viber, \n \"Content-Type\": \"application/json\",\n};\nmsg.payload = {\n \"receiver\": msg.req.body.sender.id,\n \"min_api_version\": 3,\n \"type\":\"text\",\n \"text\": \"Корзина заполнена! Очистите либо удалите элементы из неё\",\n \"keyboard\":{\n \"Type\":\"keyboard\",\n \"DefaultHeight\":true,\n \"InputFieldState\" : \"hidden\",\n \"Buttons\":[\n {\n \"BgColor\":\"#3fbdbf\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Category\",\n \"Text\":\"Категории\",\n \"TextSize\":\"large\",\n \n },\n {\n \"BgColor\": \"#ccd141\",\n \"Columns\": 3,\n\t\t\t\"Rows\": 2,\n \"ActionType\":\"reply\",\n \"ActionBody\":\"Basket\",\n \"Text\":\"Корзина\",\n \"TextSize\":\"regular\",\n \n }\n ]\n },\n};\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1030,"y":360,"wires":[[]]},{"id":"49ea9967.e7f378","type":"function","z":"56b45400.f580cc","name":"select array basket","func":"msg.topic = `SELECT * FROM \"${msg.phone}\"`\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":280,"wires":[["7dc303a2.c4990c"]]},{"id":"7dc303a2.c4990c","type":"sqlite","z":"56b45400.f580cc","mydb":"87726f00.c270b","sqlquery":"msg.topic","sql":"","name":"DB","x":550,"y":240,"wires":[["3252d20d.c452ae"]]},{"id":"3252d20d.c452ae","type":"function","z":"56b45400.f580cc","name":"set length_basket","func":"msg.length_basket = msg.payload.length;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":670,"y":280,"wires":[["7ae7fdc1.8167e4"]]},{"id":"7ae7fdc1.8167e4","type":"switch","z":"56b45400.f580cc","name":"full or not","property":"length_basket","propertyType":"msg","rules":[{"t":"lt","v":"6","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":820,"y":240,"wires":[["e188b0fa.02afd"],["f12d55d4.98d608"]]},{"id":"f12d55d4.98d608","type":"function","z":"56b45400.f580cc","name":"basket is full","func":"var send_message = env.get(\"TELEGRAM_SEND_MESSAGE\");\n\nmsg.method = \"POST\";\n\nmsg.url = send_message;\n\nmsg.payload = {\n \"text\":\"Корзина заполнена! Очистите или удалите элементы из неё\",\n \"chat_id\": msg.req.body.callback_query.from.id,\n \n}\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":990,"y":280,"wires":[[]]}]