Closed shreyashgupta68 closed 1 year ago
action.py code for the same
class ActionSearchHospitals(Action): def name(self) -> Text: return "action_search_hospitals"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
dispatcher.utter_message(text="Please allow me access to your location", json_message={
"payload": "location"
})
print()
print("====Inside ActionSearchHospitals====")
print()
location = tracker.get_slot("location")
lat = tracker.get_slot("latitude")
print("Latitude_slot", lat)
lon = tracker.get_slot("longitude")
print("Longitude_slot", lon)
latEntity = next(tracker.get_latest_entity_values("latitude"), None)
print(latEntity)
lonEntity = next(tracker.get_latest_entity_values("longitude"), None)
print(lonEntity)
user_locationEntity = next(tracker.get_latest_entity_values("user_location"), None)
print(user_locationEntity)
## if we latitude & longitude entities are found, set it to slot
if latEntity and lonEntity:
lat = latEntity
lon = lonEntity
if user_locationEntity or (latEntity and lonEntity):
## check if we already have the user location coordinates stoed in slots
if lat == None and lon == None:
dispatcher.utter_message("Sure, please allow me to access your location 🧐")
dispatcher.utter_custom_json({"payload": "location"})
return [UserUtteranceReverted()]
rule.yml
training data for inform intent.
do you get an error in slot validation or in another custom action? you can check this in the console
@bawa-v thanks for your comment, but I am able to solve it.
@shreyashgupta68 okay great! :)
sir, it's showing me in loop, after allowing it from the browser. It asks for the user permission again. How to stop the same?