Esempio n. 1
0
def search_hotel_at_dest(request, responder):
    l_t.delIntent()
    id = request.params.dynamic_resource['id']
    _,_,_,res = firebase.getHotelPref(id)
    
    if res is None:
        responder.params.target_dialogue_state = "set_hotel_pref"
        responder.reply("Sure, please first tell us the preferences for the hotels (number of rooms/ac/non-ac/etc)")
    else:
        spot_name = request.entities[0]["value"][0]["cname"]
        lat,long = _fetch_spot_from_kb(spot_name)
        print(lat,long)
        hotel_msg = hotelList(id,lat,long)
        if hotel_msg is None:
            responder.reply("Currently, We don't have any hotel preferences for you😕.\nYou can set your preference saying. ➡" + _fetch_hotel_pref_suggestion()["suggestion"])
        else:
            r,b,p,a = firebase.getHotelPref(id)
            if a==0:
                a='non ac'
            else:
                a='ac'
            pref = ' '.join([r,b,p,a])
            responder.frame["for_confirmation"] = 1
            responder.frame["for_confirmation_message"] = "Yupp"+"~"+"I have found some hotel🏘 at your destination"+"~"+"Check out the following list of hotels:\n~"+hotel_msg
            responder.frame["for_denial"] = 1
            responder.frame["for_denial_message"] = "Ok, please first tell us the preferences for the hotels (number of rooms/ac/non-ac/etc)"
            responder.reply("Your previous preferences for hotel was: "+pref+"\nWould you like to continue")
Esempio n. 2
0
def search_at_dest(request, responder):
    l_t.delIntent()

    spot_name = request.entities[0]["value"][0]["cname"]
    id = request.params.dynamic_resource['id']
    lat, long = _fetch_spot_from_kb(spot_name)
    res = firebase.getFoodPref(id)

    if not res:
        responder.params.target_dialogue_state = "set_food_pref"
        responder.reply(
            "Sure, please first tell us the preferences for the (veg/non-veg/italian/etc)"
        )
    else:
        res_msg = getRestaurant(id, lat, long)
        if res_msg == '':
            responder.reply(
                "Oops! I cannot find any restaurants near you, must be a remote place 🙂~why don't you try searching with a place name....."
            )
        else:
            responder.frame["for_confirmation"] = 1
            responder.frame[
                "for_confirmation_message"] = "There are some restaurants at your destination😋~" + "Kindly check out the following list:\n~" + res_msg
            responder.frame["for_denial"] = 1
            responder.frame[
                "for_denial_message"] = "Ok, please first tell us the preferences for the (veg/non-veg/italian/etc)"
            responder.reply("Your previous preferences for food was: " + res +
                            "\nWould you like to continue?")
Esempio n. 3
0
def search_nearby_food(request, responder):
    print('f')
    l_t.delIntent()
    id = request.params.dynamic_resource['id']
    res = firebase.getFoodPref(id)

    if not res:
        responder.params.target_dialogue_state = "set_food_pref"
        responder.reply(
            "Sure, please first tell us the preferences for the (veg/non-veg/italian/etc)"
        )
    else:
        try:
            lat, long = firebase.getCurrLocation(id)
            if lat and long:
                res_msg = getRestaurant(id, lat, long)
                if res_msg == '':
                    responder.reply(
                        "Oops! I cannot find any restaurants near you, must be a remote place 🙂~why don't you try searching with a place name....."
                    )
                else:
                    responder.frame["for_confirmation"] = 1
                    responder.frame[
                        "for_confirmation_message"] = "Yay ..I found some restaurants nearby you🌮~Go and enjoy some yummy local food there😋~Below is list of restaurants, check it out:\n" + res_msg
                    responder.frame["for_denial"] = 1
                    responder.frame[
                        "for_denial_message"] = "Ok, please first tell us the preferences for the (veg/non-veg/italian/etc)"
                    responder.reply(
                        "Your previous preferences for food was: " + res +
                        "\nWould you like to continue?")
        except (TypeError, AttributeError):
            responder.params.target_dialogue_state = "search_food_at_curr"
            responder.reply(
                'I know you are hungry😅.~But can you please share your location first so that I can help you in finding restaurants nearby you...🙂'
            )
Esempio n. 4
0
def present_city(request, responder):
    print('f')
    id = request.params.dynamic_resource['id']
    city_name = request.entities[0]["value"][0]["cname"]
    lat, long = fetch_city_coord_from_kb(city_name)
    intent = l_t.getIntent()
    hotel_msg = res_msg = ''
    if intent == 'loc_for_hotel':
        hotel_msg = hotelList(id, lat, long)
        if hotel_msg is None:
            responder.reply("We don't have any hotels for you😕.")
        else:
            responder.reply(
                "I have found some hotels at your current location." + "~" +
                "Checkout the following list of hotels:\n~" + hotel_msg + "\n")
    elif intent == 'loc_for_food':
        res_msg = getRestaurant(id, lat, long)
        if res_msg:
            responder.reply(
                "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n"
                + res_msg)
        else:
            responder.reply("We don't have any restaurants for you😕.")
    else:
        pass
    l_t.delIntent()
Esempio n. 5
0
def set_source(request, responder):
    l_t.delIntent()
    data = request.entities[0]["value"][0]["cname"]
    id = request.params.dynamic_resource['id']
    res = firebase.setSource(data, id)
    responder.params.target_dialogue_state = 'food_pref'
    # responder.params.allowed_intents = ['tourism.food_pref']
    responder.reply(
        "Before we personalize your journey, we would like to ask some preferences😀.\nPlease tell us any preferences about your food (veg/non-veg/italian/etc)"
    )
Esempio n. 6
0
def search_food_at_curr(request, responder):
    l_t.delIntent()

    # code for getting nearest_city for the loc
    id = request.params.dynamic_resource['id']
    lat, long = firebase.getCurrLocation(id)
    # end

    res_msg = getRestaurant(id, lat, long)
    responder.reply(
        "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n"
        + res_msg)
Esempio n. 7
0
def search_hotel_at_curr(request, responder):
    l_t.delIntent()
    # code for getting nearest_city for the loc
    id = request.params.dynamic_resource['id']
    lat,long = firebase.getCurrLocation(id)
    # end
    _,_,_,res = firebase.getHotelPref(id)
    print(res)
    if res is None:
        responder.params.target_dialogue_state = "set_hotel_pref"
        responder.reply("Sure, please first tell us the preferences for the hotels (number of rooms/ac/non-ac/etc)")
    else:
        try:
            # code for getting hotels list
            hotel_msg = hotelList(id,lat,long)
            if hotel_msg is None:
                responder.reply("We don't have any hotels for you😕. You can always try saying "+ _fetch_find_hotel_in_suggestion()["suggestion"] + firebase.getDest(id))
            else:
                responder.reply("I have found some hotels at your current location."+"~"+"Checkout the following list of hotels:\n~"+hotel_msg+"\n")
        except :
            responder.reply("Ooops!"+"~"+"Sorry..We couldn't find best hotels at your current location😕."+"~"+"Please try sending your location again")
Esempio n. 8
0
def present_city(request, responder):
    print('f')
    id = request.params.dynamic_resource['id']
    city_name = request.entities[0]["value"][0]["cname"]
    lat, long = fetch_city_coord_from_kb(city_name)
    intent = l_t.getIntent()
    hotel_msg = res_msg = ''
    if intent == 'loc_for_hotel':
        hotel_msg = hotelList(id, lat, long)
        if hotel_msg is None:
            responder.reply("We don't have any hotels for you😕.")
        else:
            responder.reply(
                "I have found some hotels at your current location." + "~" +
                "Checkout the following list of hotels:\n~" + hotel_msg + "\n")
    elif intent == 'loc_for_food':
        res_msg = getRestaurant(id, lat, long)
        if res_msg:
            responder.reply(
                "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n"
                + res_msg)
        else:
            responder.reply("We don't have any restaurants for you😕.")
    elif intent == 'loc_for_source':

        responder.reply(
            "Your current location has been set. Feel free to search hotels and restaurants near you"
        )

    else:
        lat, long = fetch_city_coord_from_kb(city_name)
        location = {'Latitude': lat, 'Longitude': long}
        result = firebase.setCurrLocation(location, id)
        responder.reply(
            "Your current location has been set. Feel free to search hotels and restaurants near you"
        )

    l_t.delIntent()
Esempio n. 9
0
def search_nearby_hotel(request,responder):
    print('f')
    l_t.delIntent()
    id = request.params.dynamic_resource['id']

    _,_,_,res = firebase.getHotelPref(id)
    if res is None:
        responder.params.target_dialogue_state = "set_hotel_pref"
        responder.reply("Sure, please first tell us the preferences for the hotels (number of rooms/ac/non-ac/etc)")
    
    else:
        try:
            lat,long = firebase.getCurrLocation(id)
            if lat and long:
                hotel_msg = "We are facing issue with our scrapper rght now."
                try:
                    hotel_msg = hotelList(id,lat,long)
                except:
                    responder.reply(hotel_msg)
                if hotel_msg == '':
                    responder.reply("Currently, We don't have any hotels for you😕 But you can always try saying find hotels near " + firebase.getDest(id)+"~"+"I will be there to help you 🙂")
                else:
                    r,b,p,a = firebase.getHotelPref(id)
                    if a==0:
                        a='non ac'
                    else:
                        a='ac'
                    pref = ' '.join([r,b,p,a])
                    responder.frame["for_confirmation"] = 1
                    responder.frame["for_confirmation_message"] = "I have found some hotels🛏 near by you, you can check it out:\n~"+hotel_msg
                    responder.frame["for_denial"] = 1
                    responder.frame["for_denial_message"] = "Ok, please first tell us the preferences for the hotels (number of rooms/ac/non-ac/etc)"
                    responder.reply("Your previous preferences for hotel was: "+pref+"\nWould you like to continue")
            else :
                responder.reply("I Didn't understand😕.\n Try saying find hotels near " + firebase.getDest(id))
        except (TypeError):
            responder.params.target_dialogue_state = "search_at_curr"
            responder.reply("Oops ! Sorry, can you please share your location first so that I can assist you in finding hotels nearby you...🙂")
Esempio n. 10
0
                    client.messages.create(body=msg, from_="whatsapp:+14155238886", to="whatsapp:+"+str(number))

    def run(self, host="localhost", port=7150):
        self.app.run(host=host, port=port)

    def start_remainder(self):
        remainder_service = remainderHelper(self.firebase)
        remainder_service.start(self.firebase.getReminders())


if __name__ == '__main__':
    app = Flask(__name__)
    configure_logs()
    server = WhatsappBotServer(name='whatsapp', app_path='./chatbot')
    nth.delTarget()
    l_t.delIntent()
    # create schedule for printing time
    scheduler = BackgroundScheduler()
    scheduler.start()
    scheduler.add_job(
        func=server.start_remainder,
        trigger=IntervalTrigger(seconds=5*60),
        id='send_remainders',
        name='send remainder every minute',
        replace_existing=True)
    # Shut down the scheduler when exiting the app
    atexit.register(lambda: scheduler.shutdown())

    port_number = 8080
    print('Running server on port {}...'.format(port_number))
    server.run(host='localhost', port=port_number)
Esempio n. 11
0
def set_curr_loc(request, responder):
    l_t.delIntent()
    responder.params.target_dialogue_state = 'food_pref'
    responder.reply(
        "Before we personalize your journey, we would like to ask some preferences😀.\nPlease tell us any preferences about your food (veg/non-veg/italian/etc)"
    )