Ejemplo n.º 1
0
    def run(self, dispatcher, tracker, domain):
        
        zomato = zomatopy.initialize_app(param.user_key)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        price=tracker.get_slot('price')

        location_detail=zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat=d1["location_suggestions"][0]["latitude"]
        lon=d1["location_suggestions"][0]["longitude"]
        cuisines_dict={'chinese':25,'mexican':73,'italian':55,'american':1,'south indian':85,'north indian':50}
        df=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)),price, 5)
        response="  "
        if df.empty:
            response= "No Results Found"
        else:
            iter_count=1
            for restaurant in df.itertuples():
                response=response+"  "+str(iter_count)+". "+ list(restaurant)[1]+ " in "+ list(restaurant)[2]+" has been rated "+str(list(restaurant)[3])+"\n"
                iter_count+=1
            response=response+"\n"
				        
        dispatcher.utter_message(response)
        return []
Ejemplo n.º 2
0
    def get_location_tier(self, location):
        # Tier1 cities
        tier1 = ["ahmedabad", "bengaluru", "bangalore", "chennai", "delhi", "hyderabad", "kolkata", "mumbai", "pune"]
        # Tier2 cities
        tier2 = ['agra', 'ajmer', 'aligarh', 'amravati', 'amritsar', 'asansol', 'aurangabad', 'bareilly',
                 'belgaum', 'bhavnagar', 'bhiwandi', 'bhopal', 'bhubaneswar', 'bikaner', 'bilaspur',
                 'bokaro steel city', 'chandigarh', 'coimbatore', 'cuttack', 'dehradun', 'dhanbad','bhilai',
                 'durgapur', 'dindigul', 'erode', 'faridabad', 'firozabad', 'ghaziabad', 'gorakhpur',
                 'gulbarga', 'guntur', 'gwalior', 'gurgaon', 'guwahati', 'hamirpur', 'hubli–dharwad', 'indore',
                 'jabalpur', 'jaipur', 'jalandhar', 'jammu', 'jamnagar', 'jamshedpur', 'jhansi', 'jodhpur',
                 'kakinada', 'kannur', 'kanpur', 'karnal', 'kochi', 'kolhapur', 'kollam', 'kozhikode',
                 'kurnool', 'ludhiana', 'lucknow', 'madurai', 'malappuram', 'mathura', 'mangalore', 'meerut',
                 'moradabad', 'mysore', 'nagpur', 'nanded', 'nashik', 'nellore', 'noida', 'patna',
                 'pondicherry', 'purulia', 'prayagraj', 'raipur', 'rajkot', 'rajahmundry', 'ranchi',
                 'rourkela', 'salem', 'sangli', 'shimla', 'siliguri', 'solapur', 'srinagar', 'surat',
                 'thanjavur', 'thiruvananthapuram', 'thrissur', 'tiruchirappalli', 'tirunelveli', 'ujjain',
                 'bijapur', 'vadodara', 'varanasi', 'vasai-virar city', 'vijayawada', 'visakhapatnam',
                 'vellore', 'warangal']


        zomato = zomatopy.initialize_app(self.config)
        location = location.lower()
        location_response = zomato.get_location(location, 1)
        location_json = json.loads(location_response)
        location_suggestions_len = len(location_json['location_suggestions'])

        if location.lower() in tier1:
            return [SlotSet('location', location), SlotSet('location_cat', "tier1")]
        elif location.lower() in tier2:
            return [SlotSet('location', location), SlotSet('location_cat', "tier2")]
        elif location_suggestions_len==0 or location not in map(str.lower, location_json["location_suggestions"][0]["city_name"].split()):
            return [SlotSet('location', None), SlotSet('location_cat', "other")]
        else:
            return [SlotSet('location', None), SlotSet('location_cat', "tier3")]
Ejemplo n.º 3
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"<API KEY>"}
		zomato = zomatopy.initialize_app(config)
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine').lower()
		pricerange = tracker.get_slot('price')
		price_min=0
		price_max=5000
		if (pricerange == '1'):
			price_max = 300
		else:
			if (pricerange == '2'):
				price_min = 300
				price_max = 700
			else:
				if (pricerange =='3'):
					price_min= 700
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85,'american':1,'mexican':73}
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)),price_min, price_max, 5)
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			for restaurant in d['restaurants']:
				response=response+ "Found "+ restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+ "has been rated" + restaurant['restaurant']['user_rating']['aggregate_rating'] +"\n"

		dispatcher.utter_message("-----"+response)
		return [SlotSet('location',loc)]
Ejemplo n.º 4
0
    def run(self, dispatcher, tracker, domain):
        #dispatcher.utter_message("Inside the restaurant search")

        config = {"user_key": "e556cab022363342ab67be69f38554f7"}
        zomato = zomatopy.initialize_app(config)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]
        cuisines_dict = {
            'bakery': 5,
            'chinese': 25,
            'cafe': 30,
            'italian': 55,
            'biryani': 7,
            'north indian': 50,
            'south indian': 85
        }
        results = zomato.restaurant_search("", lat, lon,
                                           str(cuisines_dict.get(cuisine)), 5)
        d = json.loads(results)
        response = ""
        if d['results_found'] == 0:
            response = "no results"
        else:
            for restaurant in d['restaurants']:
                response = response + "Found " + restaurant['restaurant'][
                    'name'] + " in " + restaurant['restaurant']['location'][
                        'address'] + "\n"

        dispatcher.utter_message("-----" + response)
        return [SlotSet('emailContent', response)]
Ejemplo n.º 5
0
    def run(self, dispatcher, tracker, domain):
        config={ "user_key":"641b84e1301a9db5ddb6cee18507f066"}
        zomato = zomatopy.initialize_app(config)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        pricerangemin = tracker.get_slot('pricerangemin')
        pricerangemax = tracker.get_slot('pricerangemax')
        location_detail= zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat=d1["location_suggestions"][0]["latitude"]
        lon=d1["location_suggestions"][0]["longitude"]
        cuisines_dict={'American':1,'Chinese':25,'Mexican':73,'Italian':55,'North Indian':50,'South Indian':85}
        results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 5)
        d = json.loads(results)
        response=""
        
        if d['results_found'] == 0:
            response= "No results found for Location and Cusine type requested"
        else:
            for restaurant in d['restaurants']:
                if  (float(restaurant['restaurant']['average_cost_for_two']) < float(pricerangemax)) &  (float(restaurant['restaurant']['average_cost_for_two']) > float(pricerangemin)):
                    response=response+restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+" has been rated "+restaurant['restaurant']['user_rating']['aggregate_rating']+" with Average Price: "+str(restaurant['restaurant']['average_cost_for_two'])+"\n"
                else:
                    response = response

        if response == "":
            response= "No results found for Location and Cusine type requested in the price range between "+str(pricerangemin)+ " and " + str(pricerangemax)
                    
        dispatcher.utter_message("-----"+response)
        return [SlotSet('pricerangemin',pricerangemin),SlotSet('pricerangemax',pricerangemax)]
Ejemplo n.º 6
0
 def run(self, dispatcher, tracker, domain):
     config = {"user_key": "f220c8cdf836b8fcd4dab5fbd535c646"}
     zomato = zomatopy.initialize_app(config)
     loc = tracker.get_slot('location')
     cuisine = tracker.get_slot('cuisine')
     pricerange = tracker.get_slot('pricerange')
     emailid = tracker.get_slot('emailaddress')
     cft = "1"
     if pricerange == '300':
         cft = "0"
     else:
         if pricerange == '700': cft = "2"
     location_detail = zomato.get_location(loc, 1)
     d1 = json.loads(location_detail)
     lat = d1["location_suggestions"][0]["latitude"]
     lon = d1["location_suggestions"][0]["longitude"]
     cuisines_dict = {
         'chinese': 25,
         'mexican': 73,
         'italian': 55,
         'american': 1,
         'north indian': 50,
         'south indian': 85
     }
     results = zomato.restaurant_search_by_rating_desc(
         "", lat, lon, str(cuisines_dict.get(cuisine)), cft, 20)
     data = utils.transformSearchOutput(json.loads(results), pricerange,
                                        "email")
     utils.sendBotEmail(emailid, data)
     print("-- Email Sent")
     return [SlotSet('emailaddress', emailid)]
Ejemplo n.º 7
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"0c86ab66477137a1932d60111ad07b96"}
		zomato = zomatopy.initialize_app(config)
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		price = tracker.get_slot('price')
		email = tracker.get_slot('emailid')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'american':1,'chinese':25,'mexican':73,'italian':55,'north indian':50,'south indian':85}
		response=""
		subject = "Top "+ cuisine + " restaurants in " + loc
		price_min = 0
		price_max = 99999
		if price == 'low':
			price_max = 300
		elif price == 'mid':
			price_min = 300
			price_max = 700
		elif price == 'high':
			price_min = 700
		else:
			price_min = 300
			price_max = 9999
		iter = 0
		rest_found = 0
		
		while(True):
			results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine.lower())), limit = 20,start=iter*20+1)
			found = json.loads(results)
			if found['results_found'] == 0 & iter== 0:
				response= "no results"
			elif found['results_found'] == 0 :
				break;
			else:
				for restaurant in found['restaurants']:
					if restaurant['restaurant']['average_cost_for_two'] > price_min and restaurant['restaurant']['average_cost_for_two'] < price_max :
							response=response+ str(rest_found+1) +". "+ restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+" has been rated "+ restaurant['restaurant']['user_rating']['aggregate_rating'] +" and average cost for two people is " + str(restaurant['restaurant']['average_cost_for_two']) +"\n"
							rest_found = rest_found +1
					if rest_found==10:
						break;
			if rest_found==10:
				break;
			else:
				itr = iter+1
		if rest_found == 0:
			response= "no results"

		sendmai = smtplib.SMTP_SSL('smtp.gmail.com', 465)
		sendmai.login("*****@*****.**", "Chat@1234")
		msg = EmailMessage()
		msg['Subject'] = subject 
		msg['From'] = "*****@*****.**"
		msg['To'] = email
		msg.set_content(response)
		sendmai.sendmail('*****@*****.**',email,msg.as_string())
		dispatcher.utter_message("Mail Sent. Thank You!!!")
		return ;
Ejemplo n.º 8
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"f4924dc9ad672ee8c4f8c84743301af5"}
		zomato = zomatopy.initialize_app(config)
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85}
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 10, "&sort=rating&order=desc")
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			for restaurant in d['restaurants']:
				response=response+ "<ul><li> Restaurant name: "+ restaurant['restaurant']['name']+ "</li><li>Restaurant locality address: "+ restaurant['restaurant']['location']['address'] + "</li><li>Zomato user rating: "+ restaurant['restaurant']['user_rating']['aggregate_rating'] + "</li></ul>"
		user_email = tracker.get_slot('email')
		msg = MIMEMultipart('alternative')
		msg['Subject'] = "Restaurants tailored for you"
		msg['From'] = "*****@*****.**"
		msg['To'] = user_email
		msg.attach(MIMEText(response, 'html'))
		# Send the message via our own SMTP server.
		server = smtplib.SMTP_SSL('smtp.gmail.com',465)
		server.ehlo()
		server.login('*****@*****.**','Certanity@123')
		server.sendmail('*****@*****.**',user_email,msg.as_string())
		server.close()
		dispatcher.utter_message('Mail sent')
    def run(self, dispatcher, tracker, domain):
        config = {"user_key": "Kee your Zomato Key"}
        zomato = zomatopy.initialize_app(config)

        loc = tracker.get_slot('location')
        locuttermsg = "None"
        validate_location = 'None'
        try:
            validate_location = zomato.validatelocation(loc)
            #print('validate_location ::', validate_location)
            d2 = json.loads(validate_location)
            validate_location = d2['data']['validate_location']
            #print('incoming location : ', loc)
            #print('location validation flag : ', validate_location)
            if validate_location == 'valid':
                locuttermsg = 'Thanks for entering valid city'
            else:
                locuttermsg = "Sorry, we do not serve at the requested location. Please try for other city"

        except:
            validate_location = 'invalid'
            locuttermsg = "Sorry, we do not serve at the requested location. Please try for other city"

        dispatcher.utter_message("-----" + locuttermsg)
        return [
            SlotSet("location", loc),
            SlotSet("validate_location", validate_location)
        ]
Ejemplo n.º 10
0
    def run(self, dispatcher, tracker, domain):
        loc = tracker.get_slot('location')
        city = str(loc)
        #print(city)
        try:

            if city.lower() in valid_tier_cities:
                return [SlotSet('valid_location', "yes")]

            else:
                zomato = zomatopy.initialize_app(config)
                results = zomato.get_city_ID(city)
                #print('---Location not covered-----')
                dispatcher.utter_template("utter_location_not_operable",
                                          tracker)

                #dispatcher.utter_template("utter_did_not_understand", tracker)
                #tracker.trigger_follow_up_action(self.try_again)

                #return [SlotSet('valid_location',"no")]
                return [Restarted()]

        # For invalid city names, the code will fall in this exception block
        except:

            #dispatcher.utter_template("utter_did_not_understand", tracker)
            ('***** Exception ******')
            dispatcher.utter_message(
                "Sorry, didn’t find any such location. Can you please try again?"
            )
            #tracker.trigger_follow_up_action(ActionListen)

            return [Restarted()]
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"6ce88a5ec1419e335afa1c7f92f4b739"}
		zomato = zomatopy.initialize_app(config)
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		budget_range = tracker.get_slot('budget')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85}
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 5)
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			for restaurant in d['restaurants']:
				if(budget_range[0] < restaurant['restaurant']['average_cost_for_two'] <= budget_range[1]):
					response=response+ "Found \n"+ restaurant['restaurant']['name']+
					" In "+ restaurant['restaurant']['location']['address']+
					" has been rated "+ restaurant['restaurant']['user_rating']['aggregate_rating']
				else:
					response =  response+"No Budget range avaliable in "+ restaurant['restaurant']['name']
		
		dispatcher.utter_message("-----"+response)
		return [SlotSet('location',loc)]
Ejemplo n.º 12
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":zomato_api_key}
		zomato = zomatopy.initialize_app(config)
		counter = 1
		loc_list =['AGRA','AJMER','ALIGARH','ALLAHABAD','AMRAVATI','AMRITSAR','ASANSOL','AURANGABAD','BAREILLY','BELGAUM','BHAVNAGAR','BHIWANDI','BHOPAL','BHUBANESWAR','BIKANER','BOKARO STEEL CITY','CHANDIGARH','COIMBATORE','CUTTACK','DEHRADUN','DHANBAD','DURG-BHILAI NAGAR','DURGAPUR','ERODE','FARIDABAD','FIROZABAD','GHAZIABAD','GORAKHPUR','GULBARGA','GUNTUR','GURGAON','GUWAHATI‚ GWALIOR','HUBLI-DHARWAD','INDORE','JABALPUR','JAIPUR','JALANDHAR','JAMMU','JAMNAGAR','JAMSHEDPUR','JHANSI','JODHPUR','KANNUR','KANPUR','KAKINADA','KOCHI','KOTTAYAM','KOLHAPUR','KOLLAM','KOTA','KOZHIKODE','KURNOOL','LUCKNOW','LUDHIANA','MADURAI','MALAPPURAM','MATHURA','GOA','MANGALORE','MEERUT','MORADABAD','MYSORE','NAGPUR','NANDED','NASHIK','NELLORE','NOIDA','PALAKKAD','PATNA','PONDICHERRY','RAIPUR','RAJKOT','RAJAHMUNDRY','RANCHI','ROURKELA','SALEM','SANGLI','SILIGURI','SOLAPUR','SRINAGAR','SULTANPUR','SURAT','THIRUVANANTHAPURAM','THRISSUR','TIRUCHIRAPPALLI','TIRUNELVELI','TIRUPPUR','UJJAIN','VIJAYAPURA','VADODARA','VARANASI','VASAI-VIRAR CITY','VIJAYAWADA','VISAKHAPATNAM','WARANGAL','AHMEDABAD','BANGALORE','CHENNAI','DELHI','HYDERABAD','KOLKATA','MUMBAI','PUNE']
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		prices = tracker.get_slot('price')
		print(loc)
		print(cuisine)
		print(prices)
		r=range(1000,1700)
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'american':1,'chinese':25,'mexican':73,'italian':55,'north indian':50,'south indian':85}
		results=zomato.restaurant_search("", lat, lon,str(cuisines_dict.get(cuisine)),"",15000)
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			for restaurant in d['restaurants']:
			    if restaurant['restaurant']['average_cost_for_two'] in r:
				    if counter <= 5:
				        response=response+ "Found "+ restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+ " with rating "+ restaurant['restaurant']['user_rating']['aggregate_rating']+ " and average price for two is Rs: " +  str(restaurant['restaurant']['average_cost_for_two']) +"\n"
				        counter=counter+1
		dispatcher.utter_message("-----"+response)
		return [SlotSet('location',loc)]
Ejemplo n.º 13
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"4a60e18c65349da0fcad6f844878a4cd"}
		zomato = zomatopy.initialize_app(config)
		try:
			loc = tracker.get_slot('location')
			print("loc ",loc)
			cuisine = tracker.get_slot('cuisine')
			print("cuisine ",cuisine)
			print("price", tracker.get_slot('price'))

			if tracker.get_slot('price').lower() == "cheap":
				print("inside less than 300")
				price_range_min = 0;
				price_range_max = 300
			elif tracker.get_slot('price').lower() == "mid" :
				print("inside between 300 to 700")
				price_range_min = 301;
				price_range_max = 700
			elif tracker.get_slot('price').lower() == "fine dining" :
				print("greater 700")
				price_range_min = 701
				price_range_max = 10000
			else:
				print("You had to enter from the above three options")
			
			print("price_range_min", price_range_min)
			print("price_range_max", price_range_max)
			
			if str(loc) not in DataForValidation.Tier1 and str(loc) not in DataForValidation.Tier2:
				response = "We do not operate in that area yet"
			else:
				location_detail=zomato.get_location(loc, 1)
				d1 = json.loads(location_detail)
				lat=d1["location_suggestions"][0]["latitude"]
				lon=d1["location_suggestions"][0]["longitude"]
				cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85,'American': 1, 'Mexican': 73}
				results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 100)
				try:
					d = json.loads(results)
				except Exception:
					print ("Exception in loads hence, going with encode")
					result = results.encode('utf8')
					d = json.loads(result)
				response=""
				print("response from zomato", d)
				if d['results_found'] == 0:
					response= "No restaurents found matching given criteria"
				else:
					count = 0
					for restaurant in d['restaurants']:
						if ((restaurant['restaurant']['average_cost_for_two']) >= price_range_min and (restaurant['restaurant']['average_cost_for_two']  <=  price_range_max) and count < 10): 
							count = count + 1;
							response=response+ "Found "+ restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+ " has been rated "+ restaurant['restaurant']['user_rating']['aggregate_rating'] +"\n"

			dispatcher.utter_message("-----"+response)
			os.environ["EMAIL_CONTENT"] =  str(response)
			return [SlotSet('location',loc)]
			#return [AllSlotsReset()]
		except Exception as e:
			print ("Exception is : ", e)
Ejemplo n.º 14
0
	def run(self, dispatcher, tracker, domain):
		config={ "user_key":"6ce88a5ec1419e335afa1c7f92f4b739"}
		zomato = zomatopy.initialize_app(config)
		budget = tracker.get_slot('budget')
		print(budget)
		loc = tracker.get_slot('location')
		print("Location : ", loc)
		cuisine = tracker.get_slot('cuisine')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85}
		query = "average_cost_for_two>100"
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 50)
		#print(results)
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			for restaurant in d['restaurants']:
				avg_cost = restaurant['restaurant']['average_cost_for_two']
				print(avg_cost)
				response=response+ "Found "+ restaurant['restaurant']['name']+ " in "+ restaurant['restaurant']['location']['address']+"\n"
		
		dispatcher.utter_message("-----"+response)
		return [SlotSet('location',loc)]
Ejemplo n.º 15
0
    def run(self, dispatcher, tracker, domain):
        configZomato = {"user_key": "c86b663aedfe8a2b54af34bfb337bb5c"}
        zomato = zomatopy.initialize_app(configZomato)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        price = tracker.get_slot('price')
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]
        cuisines_dict = {
            'mexican': 73,
            'chinese': 25,
            'american': 1,
            'italian': 55,
            'north indian': 50,
            'south indian': 85
        }

        if cuisine in cuisines_dict:
            response = self.findTopTen(lat, lon,
                                       str(cuisines_dict.get(cuisine)), price,
                                       zomato)
        elif cuisine not in cuisines_dict:
            response = "Sorry this cuisine is not available"

        config = {"user_mail": "UserName", "user_password": "******"}
        mail = mailpy.initialize_app(config)
        to = tracker.get_slot('emailid')
        mail.send_mail(to, response)
Ejemplo n.º 16
0
 def run(self, dispatcher, tracker, domain):
     config = {"user_key": "f4924dc9ad672ee8c4f8c84743301af5"}
     zomato = zomatopy.initialize_app(config)
     loc = tracker.get_slot('location')
     cuisine = tracker.get_slot('cuisine')
     price = tracker.get_slot('price')
     location_detail = zomato.get_location(loc, 1)
     d1 = json.loads(location_detail)
     lat = d1["location_suggestions"][0]["latitude"]
     lon = d1["location_suggestions"][0]["longitude"]
     cuisines_dict = {
         'chinese': 25,
         'Mexican': 73,
         'italian': 55,
         'north indian': 50,
         'south indian': 85
     }
     results = zomato.restaurant_search("", lat, lon,
                                        str(cuisines_dict.get(cuisine)), 5)
     d = json.loads(results)
     response = ""
     if d['results_found'] == 0:
         response = "no results"
     else:
         for restaurant in d['restaurants']:
             response = response + "Found " + restaurant['restaurant'][
                 'name'] + " in " + restaurant['restaurant']['location'][
                     'address'] + "\n"
     print(response)
     dispatcher.utter_message("-----" + response)
     return [SlotSet('address', response)]
Ejemplo n.º 17
0
    def run(self, dispatcher, tracker, domain):
        config = {"user_key": "1d4135a3fffd11b1ad7587b5e1471c69"}
        zomato = zomatopy.initialize_app(config)
        
        cuisine = tracker.get_slot('cuisine')
        
        loc = tracker.get_slot('location')
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]

        price_range_selected = tracker.get_slot('price_range')

        results = zomato.restaurant_search(
            "", lat, lon, str(self.cuisines_codes.get(cuisine.lower())), 10)
        d = json.loads(results)
        response = ""
        if d['results_found'] == 0:
            response = "no results"
        else:
            filtered_results = self.filterRestaurantsForBot(d, price_range_selected)
            
            if len(filtered_results) == 0:
                response = 'There are no restaurants available in the given price range, \nplease choose a different price range.'
                dispatcher.utter_message(response)
                return [SlotSet('change_price_range', 'Yes')]
            elif len(filtered_results) > 0:
                response = 'Showing you top rated restaurants: \n'+'\n'.join(filtered_results[0:5])

        dispatcher.utter_message(response)
        return [SlotSet('change_price_range', 'No')]
Ejemplo n.º 18
0
	def run(self, dispatcher, tracker, domain):
		print("Running Restaurant Search")
		config={ "user_key":"edc113a4b46e63420883a00b873fa61a"}
		zomato = zomatopy.initialize_app(config)
		global loc
		loc = tracker.get_slot('location')
		search_results = tracker.get_slot('search_results')
		global cuisine
		cuisine = tracker.get_slot('cuisine').lower()
		budget=tracker.get_slot('price')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		cuisines_dict={'Chinese':25, 'Mexican':73,'Italian':55,'American':1,'North Indian':50,'South Indian':85}
		budget_dict={'low':1,'mid':2,'high':3}
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 50)
		d = json.loads(results)
		response=""
		if d['results_found'] == 0:
			response= "Sorry, we could not find any matching restaurants."
			search_results= False
		else:
			response=self.filterOnBudget(budget_dict.get(budget),d['restaurants'])
			if response=="Sorry, we could not find any matching restaurants." :
				search_results=False
			else:
				search_results= True
		
		dispatcher.utter_message("-----"+"\n"+response)
		return [SlotSet('location',loc),SlotSet('search_results',search_results)]
Ejemplo n.º 19
0
	def run(self, dispatcher, tracker, domain):
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		budget = tracker.get_slot('budget')

		zomato = zomatopy.initialize_app(zomato_config)
		location_detail=zomato.get_location(loc, 1)

		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]

		cuisines_dict={
		'american':1,
		'mexican':73,
		'italian':55,
		'chinese':25,
		'north indian':50,
		'south indian':85
		}

		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 50)

		d = json.loads(results)
		response=""

		if d['results_found'] == 0:
			response= "Sorry, we didn't find any results for this query."
		else:
			# dispatcher.utter_message(str(d))
			response = self.filterRestaurantBasedOnBudget(budget, d['restaurants'])

		dispatcher.utter_message(str(response))
		return [SlotSet('location',loc)]
Ejemplo n.º 20
0
 def run(self, dispatcher, tracker, domain):
     config = {"user_key": "f09be5808671fa125d64a0ea398f5dd5"}
     zomato = zomatopy.initialize_app(config)
     loc = tracker.get_slot('location')
     cuisine = tracker.get_slot('cuisine')
     if zomato.is_city_available(loc):
         city_id = zomato.get_city_ID(loc)
         location_detail = zomato.get_location(loc, 1)
         d1 = json.loads(location_detail)
         lat = d1["location_suggestions"][0]["latitude"]
         lon = d1["location_suggestions"][0]["longitude"]
         cuisines_dict = zomato.get_cuisines(city_id)
         results = zomato.restaurant_search("", lat, lon,
                                            str(cuisines_dict.get(cuisine)),
                                            5)
         d = json.loads(results)
         response = []
         if d['results_found'] == 0:
             response = "no results"
         else:
             for restaurant in d['restaurants']:
                 response.append(
                     restaurant['restaurant']['name'] + " in " +
                     restaurant['restaurant']['location']['address'] +
                     " has been rated " + restaurant['restaurant']
                     ['user_rating']['aggregate_rating'])
         dispatcher.utter_message(" Showing you top rated restaurants:\n" +
                                  ("\n".join(response)))
         return [SlotSet('location', loc)]
     else:
         dispatcher.utter_message("We do not operate in that area yet:\n")
         return [SlotSet('location', loc)]
Ejemplo n.º 21
0
    def run(self, dispatcher, tracker, domain):
        config = {"user_key": "b48450bc56c13d370c756085aa379597"}
        zomato = zomatopy.initialize_app(config)
        toemailaddress = tracker.get_slot('email')
        response = 'email logic starts here'
        try:
            msg = MIMEMultipart()
            msg['From'] = "*****@*****.**"
            msg['To'] = str(toemailaddress)
            msg['Subject'] = 'Foodie - Resturant Search'
            body = 'Please find resturants below:\n' + Restaurant_data
            msg.attach(MIMEText(body, 'plain'))
            text = msg.as_string()
            server = smtplib.SMTP('smtp.gmail.com', 587)
            server.ehlo()
            server.starttls()
            server.login(msg['From'], "samplepassword")
            server.sendmail(msg['From'], toemailaddress, text)
            server.quit()
            response = "Email sent successfully"
        except Exception as error:
            response = "Unable to send email due to exception" + str(error)
        #print('Caught this error: ' + error))
        #raise

        response = response + str(toemailaddress)
        dispatcher.utter_message(response)
        return [SlotSet('email', toemailaddress)]
Ejemplo n.º 22
0
 def run(self, dispatcher, tracker, domain):
     config = {"user_key": "f09be5808671fa125d64a0ea398f5dd5"}
     zomato = zomatopy.initialize_app(config)
     receiver_email = tracker.get_slot('email')
     reciever_ack = tracker.get_slot('acknowledge')
     if reciever_ack.lower() == 'yes':
         loc = tracker.get_slot('location')
         cuisine = tracker.get_slot('cuisine')
         city_id = zomato.get_city_ID(loc)
         location_detail = zomato.get_location(loc, 1)
         d1 = json.loads(location_detail)
         lat = d1["location_suggestions"][0]["latitude"]
         lon = d1["location_suggestions"][0]["longitude"]
         cuisines_dict = zomato.get_cuisines(city_id)
         results = zomato.restaurant_search("", lat, lon,
                                            str(cuisines_dict.get(cuisine)),
                                            5)
         d = json.loads(results)
         response = []
         if d['results_found'] == 0:
             response = "no results"
         else:
             for restaurant in d['restaurants']:
                 response.append(
                     restaurant['restaurant']['name'] + " in " +
                     restaurant['restaurant']['location']['address'] +
                     " has been rated " + restaurant['restaurant']
                     ['user_rating']['aggregate_rating'])
         zomato.send_email(ec.sender, receiver_email, ec.sender_password,
                           response, ec.smtp_server, ec.smtp_port)
         dispatcher.utter_message("Email has been sent ")
         return [SlotSet('location', loc)]
     else:
         dispatcher.utter_message("Thanks")
Ejemplo n.º 23
0
	def run(self, dispatcher, tracker, domain):
		config = {"user_key": "75502752c8a4b706194ec22543a11dc1"}
		zomato = zomatopy.initialize_app(config)
		loc = tracker.get_slot('location')
		cuisine = tracker.get_slot('cuisine')
		budget = tracker.get_slot('budget')
		location_detail = zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat = d1["location_suggestions"][0]["latitude"]
		lon = d1["location_suggestions"][0]["longitude"]
		cuisines_dict = {'chinese': 25, 'italian': 55, 'north indian': 50,'south indian': 85, 'american': 1, 'mexican': 73}

		if(budget.lower() == 'low'):
			options = {'mincft': 0, 'maxcft': 300, 'sort': 'rating', 'order': 'dsc'}
		elif(budget.lower() == 'medium'):
			options = {'mincft': 300, 'maxcft': 700, 'sort': 'rating', 'order': 'dsc'}
		elif(budget.lower() == 'high'):
			options = {'mincft': 700, 'maxcft': 99999, 'sort': 'rating', 'order': 'dsc'}
		else:
			options = {'sort': 'rating', 'order': 'dsc'}

		results = zomato.restaurant_advance_search(
"", lat, lon, str(cuisines_dict.get(cuisine)), options, 5)
		d = json.loads(results)
		# d['restaurants'] = sorted(d['restaurants'], key=lambda k: k['restaurant']['user_rating']['aggregate_rating'], reverse=True)
		response = ""
		if d['results_found'] == 0:
			response = "no results found. Please try something else."
		else:
			for restaurant in d['restaurants']:
				response = response + "Found " + \
				    restaurant['restaurant']['name'] + " in " + \
				        restaurant['restaurant']['location']['address']+"\n"
		dispatcher.utter_message("-----"+response)
		return [SlotSet('location', loc), SlotSet('restaurant_found', True)]
Ejemplo n.º 24
0
 def run(self, dispatcher, tracker, domain):
     config = {"user_key": "7657af8025bf771012673de9bf8b16cb"}
     zomato = zomatopy.initialize_app(config)
     loc = tracker.get_slot('location')
     cuisine = tracker.get_slot('cuisine')
     budget = tracker.get_slot('budget')
     low = 0
     high = 999999
     if budget == "Lesser than Rs. 300":
         low = 0
         high = 300
     elif budget == "Rs. 300 to 700":
         low = 300
         high = 700
     elif budget == "More than 700":
         low = 700
         high = 999999
     location_detail = zomato.get_location(loc, 1)
     d1 = json.loads(location_detail)
     lat = d1["location_suggestions"][0]["latitude"]
     lon = d1["location_suggestions"][0]["longitude"]
     cuisines_dict = {
         'american': 10,
         'mexican': 15,
         'bakery': 5,
         'chinese': 25,
         'cafe': 30,
         'italian': 55,
         'biryani': 7,
         'north indian': 50,
         'south indian': 85
     }
     results = zomato.restaurant_search("", lat, lon,
                                        str(cuisines_dict.get(cuisine)), 5)
     d = json.loads(results)
     response = ""
     cnt = 1
     if d['results_found'] == 0:
         response = "no results"
     else:
         for restaurant in d['restaurants']:
             if (restaurant['restaurant']['average_cost_for_two'] >= low
                 ) & (restaurant['restaurant']['average_cost_for_two'] <=
                      high):
                 cnt = cnt + 1
                 if cnt > 5:
                     break
                 else:
                     response = response + " " + restaurant['restaurant'][
                         'name'] + " in " + restaurant['restaurant'][
                             'location'][
                                 'address'] + " has been rated " + restaurant[
                                     'restaurant']['user_rating'][
                                         'aggregate_rating'] + ".\n"
     if response == "":
         dispatcher.utter_message("Sorry no results found for the criteria")
         dispatcher.utter_template("utter_goodbye", tracker)
     else:
         dispatcher.utter_message("-----" + response)
     return []
Ejemplo n.º 25
0
    def run(self, dispatcher, tracker, domain):
        config = {"user_key": "652380b363a0a211c839e239d04a356a"}
        zomato = zomatopy.initialize_app(config)
        loc = tracker.get_slot('place')
        cuisine = tracker.get_slot('cuisine')
        budget = tracker.get_slot('budget')
        if budget == "300":
            pass
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]
        cuisines_dict = {
            'bakery': 5,
            'chinese': 25,
            'cafe': 30,
            'italian': 55,
            'biryani': 7,
            'north indian': 50,
            'south indian': 85
        }
        results = zomato.restaurant_search("", lat, lon,
                                           str(cuisines_dict.get(cuisine)), 5)
        d = json.loads(results)
        response = ""
        if d['results_found'] == 0:
            response = "no results"
        else:
            for restaurant in d['restaurants']:
                response = response + "Found " + restaurant['restaurant']['name'] + " in " + \
                           restaurant['restaurant']['location']['address'] + "\n"

        dispatcher.utter_message("-----" + response)
        return [SlotSet('place', loc)]
Ejemplo n.º 26
0
	def run(self, dispatcher, tracker, domain):
		
		def create_response(restaurants):
			response=""
			if d['results_found'] == 0:
				response= "no results"
			else:
				srnum=0
				for restaurant in restaurants:
					srnum=srnum+1
					response=response+str(srnum)+". "+restaurant[0]+ " in "+ restaurant[1]+" has been rated "+str(restaurant[3])+"."+"\n"
			return response

		def filter_restaurants_by_price(d, price_limit):
			result = []
			for restaurant in d['restaurants']:
				if price_limit != -1 and restaurant['restaurant']['average_cost_for_two'] <= price_limit:
					result.append(restaurant_tuple(restaurant))
				else:
					result.append(restaurant_tuple(restaurant))
			result = sorted(result,reverse=True, key=lambda x:x[3])
			result = result[:5]
			return result

		def restaurant_tuple(restaurant):
			tup = (
						restaurant['restaurant']['name'],
						restaurant['restaurant']['location']['address'],
						restaurant['restaurant']['average_cost_for_two'],
						restaurant['restaurant']['user_rating']['aggregate_rating']
					)
			return tup
		
		config={ "user_key":"e09b845afff853b9646348fb80920eaf"}
		zomato = zomatopy.initialize_app(config)
		
		loc = tracker.get_slot('location')
		location_detail=zomato.get_location(loc, 1)
		d1 = json.loads(location_detail)
		lat=d1["location_suggestions"][0]["latitude"]
		lon=d1["location_suggestions"][0]["longitude"]
		
		cuisine = tracker.get_slot('cuisine')
		cuisines_dict={'bakery':5,'chinese':25,'cafe':30,'italian':55,'biryani':7,'north indian':50,'south indian':85,'american':1,'mexican':3}
		
		results=zomato.restaurant_search("", lat, lon, str(cuisines_dict.get(cuisine)), 5)
		d = json.loads(results)
		
		response=""
		if d['results_found'] == 0:
			response= "no results"
		else:
			price_dict = {'low': 300, 'medium': 700, 'high': -1} #-1 is for no limit in price
			price_limit = price_dict.get(tracker.get_slot('price'))
			restaurants = filter_restaurants_by_price(d, price_limit)
			response = create_response(restaurants)
		
		dispatcher.utter_message(response)
		
		return [SlotSet('results',response)]
Ejemplo n.º 27
0
 def __init__(self):
     zomatoConfig = {"user_key": "6ce88a5ec1419e335afa1c7f92f4b739"}
     self.zomato = initialize_app(zomatoConfig)
     # With ref from : https://en.wikipedia.org/wiki/Classification_of_Indian_cities #
     self.selectedCityList = [
         'Ahmedabad', 'Bangalore', 'Chennai', 'Delhi', 'Delhi NCR',
         'Hyderabad', 'Kolkata', 'Mumbai', 'Pune', 'Agra', 'Ajmer',
         'Aligarh', 'Allahabad', 'Amravati', 'Amritsar', 'Asansol',
         'Aurangabad', 'Bareilly', 'Belgaum', 'Bhavnagar', 'Bhiwandi',
         'Bhopal', 'Bhubaneswar', 'Bikaner', 'Bokaro Steel City',
         'Chandigarh', 'Coimbatore', 'Cuttack', 'Dehradun', 'Dhanbad',
         'Durg-Bhilai Nagar', 'Durgapur', 'Erode', 'Faridabad', 'Firozabad',
         'Ghaziabad', 'Gorakhpur', 'Gulbarga', 'Guntur', 'Gurgaon',
         'Guwahati', 'Gwalior', 'Hubli-Dharwad', 'Indore', 'Jabalpur',
         'Jaipur', 'Jalandhar', 'Jammu', 'Jamnagar', 'Jamshedpur', 'Jhansi',
         'Jodhpur', 'Kannur', 'Kanpur', 'Kakinada', 'Kochi', 'Kottayam',
         'Kolhapur', 'Kollam', 'Kota', 'Kozhikode', 'Kurnool', 'Lucknow',
         'Ludhiana', 'Madurai', 'Malappuram', 'Mathura', 'Goa', 'Mangalore',
         'Meerut', 'Moradabad', 'Mysore', 'Nagpur', 'Nanded', 'Nashik',
         'Nellore', 'Noida', 'Palakkad', 'Patna', 'Pondicherry', 'Raipur',
         'Rajkot', 'Rajahmundry', 'Ranchi', 'Rourkela', 'Salem', 'Sangli',
         'Siliguri', 'Solapur', 'Srinagar', 'Sultanpur', 'Surat',
         'Thiruvananthapuram', 'Thrissur', 'Tiruchirappalli', 'Tirunelveli',
         'Tiruppur', 'Ujjain', 'Vijayapura', 'Vadodara', 'Varanasi',
         'Vasai-Virar City', 'Vijayawada', 'Visakhapatnam', 'Warangal'
     ]
Ejemplo n.º 28
0
    def run(self, dispatcher, tracker, domain):
        config = {"user_key": "API-KEY"}
        zomato = zomatopy.initialize_app(config)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        price = tracker.get_slot('price')
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]
        cuisines_dict = {
            'american': 1,
            'chinese': 25,
            'mexican': 73,
            'italian': 55,
            'north indian': 50,
            'south indian': 85
        }
        results = zomato.restaurant_search("", lat, lon,
                                           str(cuisines_dict.get(cuisine)), 20)
        d = json.loads(results)
        response = ""
        if d['results_found'] == 0:
            response = "no results"
        else:
            response = self.filterRestOnBudget(price, d)

        dispatcher.utter_message(response)
        return [SlotSet('location', loc)]
    def run(self, dispatcher, tracker, domain):
        zomato = zomatopy.initialize_app(config)
        loc = tracker.get_slot('location')
        cuisine = tracker.get_slot('cuisine')
        budget = tracker.get_slot('budget')
        location_detail = zomato.get_location(loc, 1)
        d1 = json.loads(location_detail)
        lat = d1["location_suggestions"][0]["latitude"]
        lon = d1["location_suggestions"][0]["longitude"]
        cuisines_dict = {
            'mexican': 73,
            'american': 1,
            'bakery': 5,
            'chinese': 25,
            'cafe': 30,
            'italian': 55,
            'biryani': 7,
            'north indian': 50,
            'south indian': 85
        }
        results = zomato.restaurant_search("", lat, lon,
                                           str(cuisines_dict.get(cuisine)), 5)
        d = json.loads(results)
        response = ""
        if d['results_found'] == 0:
            response = "no results"
        else:
            response = self.RestaurantBasedOnBudget(budget, d['restaurants'])

        dispatcher.utter_message("-----" + response)
        return [SlotSet('location', loc)]
Ejemplo n.º 30
0
    def run(self, dispatcher, tracker, domain):
        zomato = zomatopy.initialize_app(self.config)
        # Get location from slot
        loc = tracker.get_slot('location')

        # Get cuisine from slot
        cuisine = tracker.get_slot('cuisine')
        cost_min = tracker.get_slot('budgetmin')
        cost_max = tracker.get_slot('budgetmax')
        results, lat, lon = self.get_location_suggestions(loc, zomato)

        if (results != 0):
            # Zomato API could not find suggestions for this location.
            restaurant_exist = True
            d_rest = self.get_restaurants(lat, lon, cost_min, cost_max,
                                          cuisine)

            # Filter the results based on budget
            d_budget = [
                d_rest_single for d_rest_single in d_rest
                if ((d_rest_single['restaurant']['average_cost_for_two'] >
                     cost_min) & (d_rest_single['restaurant']
                                  ['average_cost_for_two'] < cost_max))
            ]
            # Sort the results according to the restaurant's rating
            d_budget_rating_sorted = sorted(
                d_budget,
                key=lambda k: k['restaurant']['user_rating']['aggregate_rating'
                                                             ],
                reverse=True)

        else:
            dispatcher.utter_message(
                "Sorry, no results found in this location:(" + "\n")

            # Build the response
            response = ""
            restaurant_exist = True
            if len(d_budget_rating_sorted) != 0:
                # Pick the top 5
                d_budget_rating_top5 = d_budget_rating_sorted[:5]
                global d_email_rest
                d_email_rest = d_budget_rating_sorted[:10]
                if (d_email_rest and len(d_email_rest) > 0):
                    restaurant_exist = True
                for restaurant in d_budget_rating_top5:
                    response = response + ">> " + restaurant['restaurant'][
                        'name'] + " in " + restaurant['restaurant']['location'][
                            'address'] + " has been rated " + restaurant[
                                'restaurant']['user_rating'][
                                    'aggregate_rating'] + "\n"
                dispatcher.utter_message("Here are the restaurants for you:" +
                                         "\n" + response)

            else:
                dispatcher.utter_message("Sorry, no results found :(" + "\n")
        return [
            SlotSet('location', loc),
            SlotSet('restaurant_exist', restaurant_exist)
        ]