Duplicate multiple messages by bot

Hey guys,

I am trying to built a bot which can take location and search for some stores using some external API. Bot is giving correct result if identify the entity. But when it didnt find the right entity ie. location , it is asking for the location twice.

I am including the screenshot and my story. Please suggest me if i need to improve my story or I am making a mistake in action implementation.

and my story is - ## success story

  • greet
    • utter_greet
    • utter_ask_location
  • enter_data{“location”: “banglore”}
    • slot{“location”: “banglore”}
    • action_search_store
    • action_slot_reset

Generated Story -7817183320599229400

  • greet
    • utter_greet
    • utter_ask_location
  • enter_data
    • action_search_store
    • action_slot_reset
    • utter_ask_location
  • enter_data{“location”: “banglore”}
    • slot{“location”: “banglore”}
    • action_search_store
    • action_slot_reset
    • utter_ask_location
  • enter_data{“location”: “delhi”}
    • slot{“location”: “delhi”}
    • action_search_store
    • action_slot_reset

Thanks

I am also including my custom action ‘action_store_search’

class ActionSearchStore(Action):
    def name(self):
        return "action_search_store"

def run(self, dispatcher, tracker, domain):

    loc = tracker.get_slot('location')

    if loc:
        print("location identified")
        # ------- Searching for coordinates---------------#
        geolocator = GoogleV3(botsetting.GOOGLE_API_KEY)
        location = geolocator.geocode(loc, language='en')
        print("this is location", location)

        if location:
            lat = location.latitude
            long = location.longitude

            # -------------searching for zone id using lat and long----------#
            payload_header = {'authorization': botsetting.ZONE_API_AUTH,
                              'language': "en"}

            payload = {'latitude': str(lat),
                       'longitude': str(long)}

            zone_id_details = requests.post(botsetting.ZONE_SEARCH_API, headers=payload_header, data=payload)
            zone_id_d = zone_id_details.json()
            if zone_id_details.status_code == 400:
                error_message = zone_id_d['message']
                dispatcher.utter_message(error_message)
            elif zone_id_details.status_code == 404:
                error_message = zone_id_d['message']
                dispatcher.utter_message(error_message)
            elif zone_id_details.status_code == 500:
                error_message = "Internal server error. Please try after some time "
                dispatcher.utter_message(error_message)
            else:

                zone_details = zone_id_details.json()
                print("these are zone details", zone_details)
                zoneId = zone_details['data']['zoneId']
                print("------ zoneid", zoneId)

                # ----------------------getting store details -------------------------#
                store_details = requests.get(
                    botsetting.STORE_API + '/' + str(zoneId) + '/' + str(0) + '/' + str(lat) + '/' + str(long),
                    headers={'language': 'en'})
                s_details = store_details.json()
                storeList = []

                for i in s_details['data']:
                    storeList.append(i['storeAddr'])

                print("store list", storeList)

                if storeList:
                    store_list = str(storeList)
                    print("This is the store list ------------ ", store_list)
                    dispatcher.utter_template("utter_stores_found", tracker)
                    dispatcher.utter_message(store_list)

                else:
                    dispatcher.utter_template("utter_no_stores_availabe", tracker)
        else:
            dispatcher.utter_template("utter_invalid_location", tracker)

    else:
        dispatcher.utter_template("utter_ask_location", tracker)

    return []

Hi,

Is this issue resolved?

I am facing the same issue, is there a fix for this?