JiteshGaikwad / Chatbot-Widget

MIT License
255 stars 128 forks source link

After accessing the user location. It's asking for the user location again and again it's not stopping. Please find the below screenshot for your reference if anyone could help me in it will be beneficial for me. #20

Closed shreyashgupta68 closed 1 year ago

shreyashgupta68 commented 1 year ago

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? image

shreyashgupta68 commented 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()]
shreyashgupta68 commented 1 year ago

image rule.yml

shreyashgupta68 commented 1 year ago

image training data for inform intent.

bawa-v commented 1 year ago

do you get an error in slot validation or in another custom action? you can check this in the console

shreyashgupta68 commented 1 year ago

@bawa-v thanks for your comment, but I am able to solve it.

bawa-v commented 1 year ago

@shreyashgupta68 okay great! :)