Geo location custom slot

One of the functions we’re building for our WhatsApp service is to provide nearby services (e.g., shelters, clinics), using the ability in WhatsApp to send a pin with longitude & latitude.

I can’t see a natural slot type among the built-in types to hold this, and I’d prefer to have it in a slot. It would seem straightforward enough to create it as a custom slot, which I’ve started to do, but not sure how to approach featurization.

I guess a naive approach would be to do a two-dimension vector with long & lat each one dimension and set to 1 if present, though I can’t really think of an instance where one would be set and not the other.

There’s one other slight complication which is for our users (very low spec mobile devices) the accuracy of the coordinates can vary a lot, so maybe one dimension for present/not and another for accuracy.

Final option would just be a text slot with standard format (long, lat) and the custom action that later uses it just pulls out the coordinates.

Any suggestions on best way to implement? And/or a better way entirely?

Any reason you can’t just store this in a normal slot as a dictionary? It’ll get stored as a string, but you can then just use literal_eval when you need to do something with it in an action

Ah, right makes complete sense. Hadn’t thought of using literal_eval. Will do that. Thanks!

Hey Luke, i came across this post and i am trying to do something similar. In the case that you did this - could you possibly guide me on how you can capture lat/lon from whatsapp location using a custom action.

Hey Ria, I’m afraid this is a while ago now and I can’t fully remember. I recall that the WhatsApp API delivered the lat/lon in a JSON dict (but not sure if that’s still how it does it), and literal_eval gave access to the non-tokenized, exact incoming context, so I used that and a JSON parse to extract the data. Sorry I can’t remember more specifics than that, but hopefully it helps a little.