Workaround for Whatsapp Business API-based Application to Get Customer’s Current Location in One-Time-Only Manner
Note: Meta now provides built in mechanism for user's location request (likely since Q1 2023) in this API documention
Whatsapp Business API is usually used by business organizations or companies to communicate with their customers.
In some cases, the company’s application server, e.g. CRM application, might need to know customer’s current location.
However, Whatsapp API doesn’t provide such information, except if customer shares his/her live location which most customers will not going to do.
Meanwhile, most CRM applications actually only needs customer’s location in one-time-only manner.
We know that Internet browser can capture user’s location with user consent.
So, the workaround is basically asking customer to open webpage which its Javascript will capture customer’s current location and send it to company’s application server.
This is the flow of the basic functionality:
The demo of explained method can be accessed IN THIS LINK.
This is example of simple HTML & Javascript code that captures user’s current location and redirects the user back to Whatsapp application:
The security of the workflow can be improved in several ways to protect against brute force & spamming, e.g.:
- Replace LOCATE.HTML with session-based dynamic page, i.e. “LOCATE.jsp?sessionid=3248738956746”, and put captcha before form submission
- Encrypt location coordinate data when it is sent from customer’s browser to company’s webserver OR when it is formatted into Whatsapp’s Click-to-Chat URL.
You can use Javascript’s builtin encryption mechanism to encrypt the data with RSA public key (https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt).
Function window.btoa can be used to convert binary data to Base64 text format.
My other articles in Linkedin:
Comments
Are you looking for WhatsApp API Service Provider? Do you want to raise your customer’s support for your brand? Do you want your company to lead in the market of India? Do you need your business to grow faster and lead the position of your business in the market of India by using WhatsApp API Service Provider? then you are in the right place. Start today with India’s most trusted WhatsApp Business API Service Provider that provides you with great deals, better services, and opportunities that your business is seeking, to be successful.