WSAPP - Check if a number has Whatsapp account from Mautic

In this flow you will use an API from a https://wsapp.com.br to check if a phone number is a whatsapp number. And return the result like a Mautic tag.

How to:

1 - Enter with your credential for simple auth in to your Mautic instance.

2 - Send a get with the params: email and mobile.

3 - when the flow go on, it will result in 3 tags: * MOBILE-ERRO: where the mobile number has no in a valid mobile format * WA_YES: where the mobile number was a Whatsapp number * WA_NO: whare the mobile number wasn´t a whatsapp number.

This API is a free service, but have a limitation from 100 consults per hour. If you is a wsapp client, modify the "Send To WSAPP.com.br", and add your key on the get url to remove the limit.

 * if you need a help, send me an email: [email protected]
[{"id":"caa91245.215a6","type":"tab","label":"WSAPP_CheckisWhatsapp","disabled":false,"info":""},{"id":"7397eda3.3298a4","type":"http request","z":"caa91245.215a6","name":"Send To WSAPP.com.br","method":"GET","ret":"obj","paytoqs":"query","url":"https://api.wsapp.com.br/v1?srv=ISWHAVALID&phone={{{payload.phone}}}","tls":"","persist":false,"proxy":"","authType":"","x":410,"y":320,"wires":[["6934347a.391bec","1b4735de.67d60a"]]},{"id":"96365e5e.7bc41","type":"debug","z":"caa91245.215a6","name":"MOBILE-ERRO","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":540,"wires":[]},{"id":"6beedc7.379aa24","type":"http in","z":"caa91245.215a6","name":"","url":"wsapp","method":"get","upload":false,"swaggerDoc":"","x":110,"y":60,"wires":[["dcb662ae.307a2","e98e93ee.35d68"]]},{"id":"e7ae80ee.6547e","type":"switch","z":"caa91245.215a6","name":"IF Status...","property":"payload.records.0.status","propertyType":"msg","rules":[{"t":"eq","v":"S","vt":"str"},{"t":"eq","v":"I","vt":"str"},{"t":"eq","v":"P","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":170,"y":560,"wires":[["9588e08a.a809d"],["a3819423.e57d58"],["efedbc1e.0b554"]]},{"id":"efedbc1e.0b554","type":"delay","z":"caa91245.215a6","name":"If \"P\", try again in 5 sec","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":170,"y":460,"wires":[["7397eda3.3298a4"]]},{"id":"dc8fefa9.bd1e9","type":"json","z":"caa91245.215a6","name":"Convert to string","property":"payload","action":"str","pretty":false,"x":740,"y":100,"wires":[["fe5acd9a.72b48"]]},{"id":"fe5acd9a.72b48","type":"string","z":"caa91245.215a6","name":"Parse string","methods":[{"name":"getRightMost","params":[{"type":"str","value":"%"}]},{"name":"between","params":[{"type":"str","value":"\"contacts\":{\""},{"type":"str","value":"\":{"}]},{"name":"trim","params":[]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":330,"y":200,"wires":[["c1fb9cf5.99c2a"]]},{"id":"e0dbe384.3cc5e","type":"http request","z":"caa91245.215a6","name":"Search Mautic Lead ID","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://mautic.yourdomain.com.br/api/contacts?search=email:{{{payload.email}}}","tls":"","persist":true,"proxy":"","authType":"basic","x":520,"y":100,"wires":[["dc8fefa9.bd1e9"]]},{"id":"e98e93ee.35d68","type":"change","z":"caa91245.215a6","name":"Trim Email","rules":[{"t":"set","p":"req.params.email","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":100,"wires":[["e0dbe384.3cc5e"]]},{"id":"24ad7a5c.cb6fc6","type":"http request","z":"caa91245.215a6","name":"add Mautic Tag","method":"use","ret":"txt","paytoqs":"ignore","url":"https://mautic.yourdomain.com.br/api/contacts/{{{payload.id}}}/edit","tls":"","persist":false,"proxy":"","authType":"basic","x":500,"y":660,"wires":[["c957c364.84cdc"]]},{"id":"4a941710.249c28","type":"change","z":"caa91245.215a6","name":"WA_YES","rules":[{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":660,"wires":[["24ad7a5c.cb6fc6","27cd52d4.d7adee"]]},{"id":"20c7589e.db3e28","type":"change","z":"caa91245.215a6","name":"WA_NO","rules":[{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":720,"wires":[["ab77e782.9dc278","27cd52d4.d7adee"]]},{"id":"ab77e782.9dc278","type":"http request","z":"caa91245.215a6","name":"add Mautic Tag","method":"use","ret":"txt","paytoqs":"ignore","url":"https://mautic.yourdomain.com.br/api/contacts/{{{payload.id}}}/edit","tls":"","persist":false,"proxy":"","authType":"basic","x":500,"y":720,"wires":[["c957c364.84cdc"]]},{"id":"dcb662ae.307a2","type":"http response","z":"caa91245.215a6","name":"","statusCode":"","headers":{},"x":130,"y":200,"wires":[]},{"id":"ef00c931.93eec8","type":"switch","z":"caa91245.215a6","name":"VALID request?","property":"payload.resultado","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"9","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":520,"wires":[["96365e5e.7bc41","e7ae80ee.6547e"],["18d78a5e.a4f426","96365e5e.7bc41"]]},{"id":"b969db16.0568f8","type":"change","z":"caa91245.215a6","name":"MOBILE-ERRO","rules":[{"t":"set","p":"method","pt":"msg","to":"PATCH","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":660,"wires":[["f75b1342.6cf9e","27cd52d4.d7adee"]]},{"id":"f75b1342.6cf9e","type":"http request","z":"caa91245.215a6","name":"add Mautic Tag","method":"use","ret":"txt","paytoqs":"ignore","url":"https://mautic.yourdomain.com.br/api/contacts/{{{payload.id}}}/edit","tls":"","persist":false,"proxy":"","authType":"basic","x":760,"y":720,"wires":[["c957c364.84cdc"]]},{"id":"27cd52d4.d7adee","type":"debug","z":"caa91245.215a6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":330,"y":820,"wires":[]},{"id":"9588e08a.a809d","type":"template","z":"caa91245.215a6","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"tags\": \"WA_YES, -WA_NO, -MOBILE-ERRO\",\n  \"id\": \"{{mautic_id}}\"\n}","output":"json","x":140,"y":660,"wires":[["4a941710.249c28","ba8b70c7.938a2"]]},{"id":"a3819423.e57d58","type":"template","z":"caa91245.215a6","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"tags\": \"WA_NO, -WA_YES, -MOBILE-ERRO\",\n  \"id\": \"{{mautic_id}}\"\n}","output":"json","x":140,"y":720,"wires":[["20c7589e.db3e28","ba8b70c7.938a2"]]},{"id":"18d78a5e.a4f426","type":"template","z":"caa91245.215a6","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"tags\": \"MOBILE-ERRO, -WA_YES, -WA_NO\",\n  \"id\": \"{{mautic_id}}\"\n}","output":"json","x":740,"y":600,"wires":[["b969db16.0568f8"]]},{"id":"c1fb9cf5.99c2a","type":"json","z":"caa91245.215a6","name":"Mautic_id JSON","property":"payload","action":"obj","pretty":false,"x":520,"y":200,"wires":[["9cb2f5df.404c48","3d2aaaec.c70396"]]},{"id":"ba8b70c7.938a2","type":"debug","z":"caa91245.215a6","name":"Template","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":120,"y":820,"wires":[]},{"id":"c957c364.84cdc","type":"debug","z":"caa91245.215a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":820,"wires":[]},{"id":"9cb2f5df.404c48","type":"template","z":"caa91245.215a6","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{ \"mautic_id\":\"{{payload}}\",\n  \"phone\":\"{{req.params.email.mobile}}\"\n  }","output":"json","x":140,"y":300,"wires":[["7397eda3.3298a4"]]},{"id":"6934347a.391bec","type":"debug","z":"caa91245.215a6","name":"Debug WSAPP","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":320,"wires":[]},{"id":"1b4735de.67d60a","type":"string","z":"caa91245.215a6","name":"Parse Response","methods":[{"name":"getLeftMost","params":[{"type":"str","value":"%"}]},{"name":"between","params":[{"type":"str","value":"mautic_id="},{"type":"str","value":"&"}]}],"prop":"responseUrl","propout":"mautic_id","object":"msg","objectout":"msg","x":470,"y":420,"wires":[["ef00c931.93eec8","c906b56b.75c518"]]},{"id":"3d2aaaec.c70396","type":"debug","z":"caa91245.215a6","name":"Debug Mautic_id","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":200,"wires":[]},{"id":"c906b56b.75c518","type":"debug","z":"caa91245.215a6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":420,"wires":[]},{"id":"1bb80669.6c0d9a","type":"comment","z":"caa91245.215a6","name":"node-red-contrib-string","info":"","x":470,"y":460,"wires":[]},{"id":"5aed0405.68e67c","type":"comment","z":"caa91245.215a6","name":"node-red-contrib-string","info":"","x":320,"y":240,"wires":[]}]

Flow Info

Created 5 years ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • change (x4)
  • comment (x2)
  • debug (x7)
  • delay (x1)
  • http in (x1)
  • http request (x5)
  • http response (x1)
  • json (x2)
  • switch (x2)
  • template (x4)
Other

Tags

  • whatsapp
  • number
  • check
  • wsapp
  • leo
  • borlot
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option