https://discord.gg/botpress logo
GET THE USER'S CITY BY IP?
# 🤝help
g
Is it possible to get the location (It must not be exact, I just want to distinguish the user by city) by the user's IP when he starts a conversation on Whatsapp? (I already have the integration active and functional)
w
Hi ! maybe you can use an external API call to an API like this : https://ipstack.com/
Hi ! maybe you can make an API call to an external API like ipstack
g
Thanks for the help, I just got the API access key in IPSTACK. how you could make the API call and more importantly save that data and view it.
w
For the code for the API call you can ask the botpress ai or chatgpt to generate it (after a look at the documentation)
And you could save the result in a workflow variable for exemple
Through the execute code card
g
I made the request in this way. Get the user's city using their IP address in: http://api.ipstack.com/ using this API access key '11b9770e588680fc1234558fffded999' stores the result in the variable called 'ciudadbo' (The API is just one example) The node runs smoothly, how do I know if it's okay? Also, the variable where the result should be saved is empty https://cdn.discordapp.com/attachments/1260610136796565555/1261023798195523674/image.png?ex=6691736e&is=669021ee&hm=4a22e8eb4493540f69e1e9bb814181b241fa52049f01eb34a75e605b6db37013&
I made the request in this way: Get the user's city using their IP address in: http:/api.ipstack.com (remove a / in the IPSTICK address as discord doesn't allow me to send links) using this API access key '11b9770e588680fc1234558fffded999' stores the result in the variable called 'ciudadbo' (Previously create a user variable with the name city ) (The API is just one example) https://cdn.discordapp.com/attachments/1260610136796565555/1261025372921790525/image.png?ex=669174e5&is=66902365&hm=96ccf8e80d209fea0e5cc0d073aeee6809de2fa74dd7877720ce56a2d4e78af2&
I appreciate any kind of guidance!!
w
Okay, but did that work ?
g
That's the problem, I look in "logs" and I don't find anything and the code appears to me that it runs fine.
w
It’s because you don’t have log anything Try to log the API response
It should be saved in your user variable e
g
I update the status: I make the API call ipinfo.io get the data and save the information in a table with the name of the city. But.... It logs me the IP address of another place. I did the test with different devices and they are all registered in the US (Ashburn) What could be wrong?
The return of the API call gives me these IP addresses, all in the US 3.235.40.22 52.90.95.114 3.85.203.182
w
Actually I don’t know anything about this API, just found and proposed it as a solution for you 😅
But maybe you can find something about that in the api documentation ?
g
I did the test with different apis, but I have the same problem, they all send me data from the US but not the real data
I would love to find a solution!!!
2 Views