def submit(self, dispatcher, tracker, domain): try: entity_university = self.get_slot('entity_university')[0] entity_university_validated = self.get_slot( 'entity_university_validated')[0] except: entity_university = None entity_university_validated = None if entity_university_validated != None: res = [] res.append(['mã ngành', 'tên ngành', 'tổ hợp']) try: dt = db.universities.find_one( {'abbreviation': entity_university_validated}) dt = dt['majors'] for i in dt: res.append( [i['major_id'], i['major_name'], i['major_combine']]) except: dispatcher.utter_message( "không tìm thấy thông tin về khung đào tạo ngành " + entity_university) return [AllSlotsReset()] if len(res) == 1: dispatcher.utter_message( "không tìm thấy thông tin về khung đào tạo ngành " + entity_university) return [AllSlotsReset()] dispatcher.utter_message("Trường " + entity_university + " hiện đang đào tạo các ngành sau:") dispatcher.utter_message(json_message={"data": {"table": res}}) return [AllSlotsReset()]
def request_next_slot( self, dispatcher: "CollectingDispatcher", tracker: "Tracker", domain: Dict[Text, Any], ) -> Optional[List[EventType]]: """Request the next slot and utter template if needed, else return None""" for slot in self.required_slots(tracker): if self._should_request_slot(tracker, slot): ## Condition of validated slot that triggers deactivation if slot == "gender" and tracker.get_slot("age") == "below16": # dispatcher.utter_message(text="Sorry, I can't help you with that") dispatcher.utter_message(template="utter_under_16") return [self.deactivate(), AllSlotsReset()] elif slot == "gender" and tracker.get_slot( "age") == "above107": dispatcher.utter_message(template="utter_above_107") return [self.deactivate(), AllSlotsReset()] ## For all other slots, continue as usual # logger.debug(f"Request next slot '{slot}'") dispatcher.utter_message(template=f"utter_ask_{slot}", **tracker.slots) return [SlotSet("requested_slot", slot)] return None
def submit(self, dispatcher, tracker, domain): try: university = self.get_slot('entity_university')[0] university_validated = self.get_slot( 'entity_university_validated')[0] except: university = None university_validated = None try: university_id = self.get_slot('entity_university_id')[0] except: university_id = None if university_id != None: dt = db.universities.find_one({ 'abbreviation': re.compile('^' + university_id + '$', re.IGNORECASE) }) if dt != None: dispatcher.utter_message("Mã " + university_id + " là của trường " + dt['name']) else: dispatcher.utter_message( "Tôi không tìm thấy trường nào có mã là " + university_id) return [AllSlotsReset()] dispatcher.utter_message("Mã trường của " + university + " là " + university_validated) return [AllSlotsReset()]
def run(self, dispatcher, tracker, domain): #config={ "user_key":"f4924dc9ad672ee8c4f8c84743301af5"} #zomato = zomatopy.initialize_app(config) loc = tracker.get_slot('location') if loc == None: dispatcher.utter_message('Location got is None') return [AllSlotsReset()] if loc.lower() not in cities: print("----loc found == " + str(loc)) dispatcher.utter_message( "We don't operate in your location -- ++" + str(loc)) return [AllSlotsReset()] cuisine = tracker.get_slot('cuisine') price = tracker.get_slot('price') res = '' if cuisine == None or price == None: dispatcher.utter_message( "I didn't get all details, deafault results will be shown") cuisine = 'north' price = 'mid' else: res = self.fetch(loc, cuisine, price) dispatcher.utter_message(res + "\n\n\n")
def run(self, dispatcher, tracker, domain): loc = tracker.get_slot('location') cuisine = tracker.get_slot('cuisine') price = tracker.get_slot('price') res = self.fetch(loc,cuisine,price) email = tracker.get_slot('email') if email == None: email = '@gmail.com' s = smtplib.SMTP('smtp.gmail.com', 587) s.starttls() try: s.login("@gmail.com", "") except: dispatcher.utter_message('bad credentials, your preferences deleted') return [AllSlotsReset()] message = "The details of all the restaurants you inquried \n \n" message = message + res try: s.sendmail("@gmail.com", str(email), message) s.quit() dispatcher.utter_message( "Email sent please check your inbox. your preferances will be deleted " ) return [AllSlotsReset()] except: dispatcher.utter_message("Can't send the email. deleted your preferances") return [AllSlotsReset()]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: logger.debug("Here are all the slots") logger.debug(tracker.slots) dispatcher.utter_message(text="Hello World!") df = pd.read_csv('sample_dataset_chatbot.csv') agg = "mean" if tracker.get_slot("agg") is not None: agg = tracker.get_slot("agg") if tracker.get_slot("metric") is not None: metric = tracker.get_slot("metric") elif tracker.get_slot("prev_metric") is not None: metric = tracker.get_slot("prev_metric") else: dispatcher.utter_message( "No Metric mentioned in context. Can you tell me rephrase the sentance" ) return [AllSlotsReset()] for dim_col in dimension_columns: if tracker.get_slot(dim_col) is not None: dim = dim_col dim_val = tracker.get_slot(dim_col) answer = df[df[dim] == dim_val][metric].agg(agg) dispatcher.utter_message("Answer is {}".format(answer)) break return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain): try: entity_major = self.get_slot('entity_major')[0] entity_major_validated = self.get_slot('entity_major_validated')[0] except: entity_major = None entity_major_validated = None if entity_major_validated != None: res = [] res.append(['môn học']) try: dt = db.major_info.find_one({'major_id':entity_major_validated}) dt = dt['subjects'] for i in dt: res.append([i]) except: dispatcher.utter_message("không tìm thấy thông tin về khung đào tạo ngành " + entity_major) return [AllSlotsReset()] if len(res) == 1: dispatcher.utter_message("không tìm thấy thông tin về khung đào tạo ngành " + entity_major) return [AllSlotsReset()] dispatcher.utter_message("sau đây là khung đào tạo thông thường của " + entity_major) dispatcher.utter_message(json_message={"data":{"table" : res}}) return [AllSlotsReset()]
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') res = self.fetch(loc, cuisine, price) email = tracker.get_slot('email') msg = EmailMessage() msg['Subject'] = 'Foodie Chatbot - Search Result' s = smtplib.SMTP('smtp.gmail.com', 587) s.starttls() try: s.login("*****@*****.**", "phoenix999") except: dispatcher.utter_message('security issue while logging in') return [AllSlotsReset()] message = "Showing you the top rated restaurants:" message = message + res try: s.sendmail("*****@*****.**", str(email), message) s.quit() dispatcher.utter_message("") return [AllSlotsReset()] except: dispatcher.utter_message( "Can't send the email. deleted your preferances") return [AllSlotsReset()]
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') res = self.fetch(loc, cuisine, price) email = tracker.get_slot('email') if email == None: email = '*****@*****.**' s = smtplib.SMTP('smtp.office365.com', 587) s.starttls() try: s.login("*****@*****.**", "N30#P*zMmtaI%S") except: dispatcher.utter_message( 'bad credentials, your preferences deleted -- message =' + message + res) return [AllSlotsReset()] message = "The details of all the restaurants you inquried \n \n" message = message + res try: #s.sendmail("*****@*****.**", str(email), message) #s.quit() dispatcher.utter_message( "Email sent please check your inbox. your preferances will be deleted " ) return [AllSlotsReset()] except: dispatcher.utter_message( "Can't send the email. deleted your preferances") return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain): position = tracker.get_slot('position') device = tracker.get_slot('device') if not FormUtility.check_position_has_device(self, dispatcher, position, device): return [AllSlotsReset()] if not FormUtility.is_open(self, position, device): dispatcher.utter_message(text='%s的%s早就关上了' % (position, device)) return [AllSlotsReset()] FormUtility.set_device_property_value(self, position, device,'open', 0) dispatcher.utter_message(text='%s的%s关了' % (position, device)) return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain): if tracker.get_slot("confirm"): dispatcher.utter_message(template="utter_transfer_complete") return [ AllSlotsReset(), SlotSet("amount_transferred", tracker.get_slot("amount-of-money")), ] else: dispatcher.utter_message(template="utter_transfer_cancelled") return [AllSlotsReset()]
def run(self, dispatcher, tracker, domain): side_effects = {} medicine = tracker.get_slot('medicine') if medicine == None: dispatcher.utter_message( text= "No drug with the given name found. Please check if the spelling is right, or if there is an alternative name for the drug." ) return [AllSlotsReset()] url = "https://api.fda.gov/drug/event.json?search=patient.drug.medicinalproduct:\"" + medicine.upper( ) + "\"&limit=10" print(url) with urllib.request.urlopen(url) as record: values = json.load(record) record.close() for each_res in values['results']: for reaction in each_res['patient']['reaction']: se = reaction['reactionmeddrapt'] if se in side_effects: side_effects[se] += 1 else: side_effects[se] = 1 sorted_effects = sorted(side_effects.items(), key=operator.itemgetter(1), reverse=True) say_effects = "" count = len(sorted_effects) l = 0 for eff in sorted_effects: if eff[0] != "No adverse event": say_effects += (eff[0] + ", ") l += 1 if l == 7: break if l == 0: say_effects += "No side effects found. Please check if you gave the right spelling of the medicine." elif l == 1: say_effects += ("is the side effect caused due to" + medicine[0].upper() + medicine[1:].lower()) else: say_effects += ("are the side effects caused due to " + medicine[0].upper() + medicine[1:].lower()) print(say_effects) dispatcher.utter_message(text=say_effects) return [AllSlotsReset()]
def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: """Create an incident and return details or if localmode return incident details as if incident was created """ priority = tracker.get_slot("priority") email = tracker.get_slot("email") problem_description = tracker.get_slot("problem_description") incident_title = tracker.get_slot("incident_title") confirm = tracker.get_slot("confirm") if not confirm: dispatcher.utter_message( template="utter_incident_creation_canceled" ) return [AllSlotsReset(), SlotSet("previous_email", email)] if localmode: message = ( f"An incident with the following details would be opened " f"if ServiceNow was connected:\n" f"email: {email}\n" f"problem description: {problem_description}\n" f"title: {incident_title}\npriority: {priority}" ) else: snow_priority = snow.priority_db().get(priority) response = snow.create_incident( description=problem_description, short_description=incident_title, priority=snow_priority, email=email, ) incident_number = ( response.get("content", {}).get("result", {}).get("number") ) if incident_number: message = ( f"Successfully opened up incident {incident_number} " f"for you. Someone will reach out soon." ) else: message = ( f"Something went wrong while opening an incident for you. " f"{response.get('error')}" ) dispatcher.utter_message(message) return [AllSlotsReset(), SlotSet("previous_email", email)]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: logger.debug("---- [ActionCheckBody] ----") # Get slot value body = tracker.get_slot('body') suggest = tracker.get_slot('suggest') muscle = tracker.get_slot('muscle') facility = tracker.get_slot('facility') logger.debug("b:{}, s:{}, m:{}, f:{}".format(body, suggest, muscle, facility)) try: # Need a exercise suggestion. if suggest != None: rnd = random.choice(exerciseList) msg = "I recommend to do some {} exercise with {}!!\nFYI {}".format( rnd['Body'], rnd['equipment'], rnd['resource']) dispatcher.utter_message(msg) return [AllSlotsReset(), FollowupAction('action_restart')] # Body part question elif tracker.latest_message['intent'].get('name') == 'query': respond = "You can choice following body: {}".format( list(bodyMap.keys())[0:]) dispatcher.utter_message(respond) return [FollowupAction('action_listen')] # Check body is vaildated. if body != None and body.lower() in [ item.lower() for item in list(bodyMap.keys()) ]: dispatcher.utter_message(template='utter_check_muscle') return [ SlotSet('muscle', None), SlotSet('facility', None), SlotSet('deny', None), SlotSet('suggest', None) ] dispatcher.utter_message(template='utter_cannot_understand') respond = "Please check the spelling of body part\n" respond = respond + "\tFollowing is the body list: {}\n".format( list(bodyMap.keys())[0:]) respond = respond + "Which part of body exercise you want to know?" dispatcher.utter_message(respond) return [AllSlotsReset(), FollowupAction('action_restart')] except: dispatcher.utter_template('utter_system_wrong') return [AllSlotsReset(), FollowupAction('action_restart')]
def run(self, dispatcher, tracker, domain): object_name = tracker.get_slot('object_name') object_color = tracker.get_slot('object_color') placement_origin = tracker.get_slot('placement') # if placement_origin not in valid_placements: # placement_origin = "any" # dispatcher.utter_message(text="Hang on, I'll try to pick up the {} {} somewhere on the table".format( # object_color, # object_name # )) # else: # dispatcher.utter_message(text="Hang on, I'll try to pick up the {} {} in the {} area of the table".format( # object_color, # object_name, # placement_origin # )) if ENABLE_ROS: nlp_node.send_command("pick up", object_name, object_color, placement_origin) response = nlp_node.wait_for_response() try: msg, path_2dimg, _ = response except Exception: msg, path_2dimg = response if msg is not None: # dispatcher.utter_message(template="utter_executed_command") if path_2dimg is not None: imgpath = path_2dimg print("Image saved at {}".format(imgpath)) print("Found {} object: {}".format(msg.desired_color, msg.found_obj)) imgurl = "http://localhost:8888/{}?time={}".format( imgpath, int(time.time())) dispatcher.utter_attachment(None, image=imgurl) # dispatcher.utter_message(text="Got response code {} from gripper.".format(msg.grippercode)) if msg.grippercode in [1, 2, 3]: dispatcher.utter_message(template="utter_command_failed") else: dispatcher.utter_message( text="I've managed to pick it up!") else: dispatcher.utter_message(template="utter_command_failed") return [AllSlotsReset()] # dispatcher.utter_message(text="Error: {}...Check that the required ROS Service is running!".format(info)) else: dispatcher.utter_message(text="I've managed to pick it up!") return [AllSlotsReset()]
def run(self, dispatcher, tracker, domain): hospital_search = [] lat_long = { "hyderabad": ("17.3850", "78.4867"), "bangalore": ("12.9716", "77.5946"), "chennai": ("13.0827", "80.2707"), "pune": ("18.5204", "73.8567"), "delhi": ("28.7041", "77.1025"), "kolkata": ("22.5726", "88.3639"), "mumbai": ("19.0760", "72.8777"), "jaipur": ("26.9124", "75.7873"), "mysore": ("12.2958", "76.6394"), "agra": ("27.1767", "78.0081"), "vizag": ("17.6868", "83.2185"), "goa": ("15.2993", "74.1240"), "amritsar": ("31.6340", "74.8723"), "kochi": ("9.9312", "76.2673"), "ahmedabad": ("23.0225", "72.5714"), "thiruvananthapuram": ("8.5241", "76.9366"), "kolhapur": ("16.7050", "74.2433"), "solapur": ("17.6599", "75.9064"), "madurai": ("9.9252", "78.1198"), "kanchipuram": ("12.8185", "79.6947"), "lucknow": ("26.8467", "80.9462") } location = (tracker.get_slot('location')).lower() if location not in lat_long: dispatcher.utter_message( text= "Apologies :( The search for hospitals is currently unavailable in the given location." ) return [AllSlotsReset()] url = "https://api.tomtom.com/search/2/categorySearch/hospital.json?limit=10&lat=" + lat_long[ location][0] + "&lon=" + lat_long[location][ 1] + "&radius=10000&key=your_api_key" print(url) with urllib.request.urlopen(url) as record: res = json.load(record) record.close() say_hospitals = "" for idx, each in enumerate(res['results']): say_hospitals += str(idx + 1) + ". " + each['poi']['name'] + " - " say_hospitals += each['address']['freeformAddress'] + "\n" dispatcher.utter_message(text=say_hospitals) return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain, ): position = tracker.get_slot('position') device = tracker.get_slot('device') if not FormUtility.check_position_has_device(self, dispatcher, position, device): return [AllSlotsReset()] if not FormUtility.is_open(self, position, device): FormUtility.set_device_property_value(self, position, device, 'open', 1) dispatcher.utter_message(text='%s的%s打开' % (position, device)) mode = tracker.get_slot('mode') dispatcher.utter_message( text='%s的%s设置为%s' % (position, device, mode)) FormUtility.set_device_property_value(self, position, device, 'mode', mode) return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain): if tracker.get_slot("confirm"): if self.birthday: dispatcher.utter_message(template="utter_ticket_created") #dispatcher.utter_message(template="utter_goodbye_birthday") #self.birthday = False else: dispatcher.utter_message(template="utter_ticket_created") SlotSet("confirm", None) return [AllSlotsReset()] else: dispatcher.utter_message(template="utter_goodbye") self.birthday = True return [AllSlotsReset()]
def submit(self, dispatcher, tracker, domain): try: entity_major = self.get_slot('entity_major')[0] entity_major_validated = self.get_slot('entity_major_validated')[0] except: entity_major = None entity_major_validated = None if entity_major_validated != None: res = "" try: major_validated_int = int(entity_major_validated) dt = db.major_info.find_one({ 'major_id': { '$in': [major_validated_int, entity_major_validated] } }) res = dt['job'] dispatcher.utter_message( "sau đây là thông tin về cơ hội việc làm của " + entity_major) dispatcher.utter_message(res) except: dispatcher.utter_message( "không tìm thấy thông tin về cơ hội việc làm ngành " + entity_major) return [AllSlotsReset()]
def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: most_recent_state = tracker.current_state() sender_id = most_recent_state['sender_id'] phone_number = tracker.get_slot("phone_number") phone_number_converted = '+{}'.format(phone_number) sender_id_converted = '{}'.format(sender_id) #TODO: Check if user phone number exists in job DB phone_number = tracker.get_slot("phone_number") job_title = tracker.get_slot("job_title") # after phone number submission and previously applied for the same role, prompt this if has_already_applied(phone_number=int(phone_number), job_title=job_title): dispatcher.utter_message( template="utter_already_applied_for_this_job") # data = job_openings() # message = {"payload": "quickReplies", "data": data} # dispatcher.utter_message(text="These are the job openings we have right now.👇", json_message=message) return [ FollowupAction("action_show_job_openings"), AllSlotsReset() ] # after phone number submission and not previously applied for the same role, ask for email id else: ask_email = "Your 𝐞𝐦𝐚𝐢𝐥? <br> We'll use it to inform you in case you are selected 😊" dispatcher.utter_message(text=ask_email) return []
def run( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: latest_intent = tracker.latest_message["intent"].get("name") actions = get_action_with_help_intent(latest_intent) if actions: for action in actions: if action != tracker.latest_action_name: if action == "action_faq_selector": ActionFAQSelector().run( dispatcher=dispatcher, tracker=tracker, domain=domain, ) else: dispatcher.utter_message(template=action) elif (latest_intent == "affirm" and tracker.events[-4].get("text") == "Do you want to learn more?"): dispatcher.utter_message( template="utter_more_details_analysis_and_training") else: dispatcher.utter_message(template="utter_cannot_help") return [Form(None), AllSlotsReset()]
def run(self, dispatcher, tracker, domain): loc = tracker.get_slot('location') cuisine = tracker.get_slot('cuisine') price = tracker.get_slot('price') global restaurants restaurants = results(loc, cuisine, price) top_5 = restaurants.head(5) # top 5 results to display if not top_5.empty: response = 'Showing you top results:' + "\n" msg_template = 'Restaurant: {} in Address: {} has been rated: {}\n with cost for two of: {}\n' for _, row in top_5.iterrows(): response += msg_template.format(row["restaurant_name"], row['restaurant_address'], row['restaurant_rating'], row['budget_for2people']) else: response = 'No restaurants found' dispatcher.utter_message(str(response)) if not (price or cuisine): print('Location only reset') return [SlotSet("location", None)] return [AllSlotsReset()]
def run(self, dispatcher, tracker, domain): try: slots = tracker.current_slot_values() slot_time = slots['time'] f_date = convert_timestamp(slot_time) date_s = f_date.strftime("%Y-%m-%d") str_date = f_date.strftime('%B %d, %Y') except: f_date = date.today() date_s = f_date.strftime("%Y-%m-%d") str_date = f_date.strftime('%B %d, %Y') # dispatcher.utter_message(text='Please enter the date properly') # return [AllSlotsReset()] try: doc = get_doc(date_s) # st = f"""DATE: {date}\nAir Temparature: {doc['airTemp']}\nSoil Temparature: {doc['soilTemp']}\nMoisture: {doc['moisture']}\nPressure: {doc['pressure']}\nHumidity: {doc['humidity']}\nPhosphorus: {doc['phosphorus']}\nNitrogen: {doc['nitrogen']}\nPotassium: {doc['potassium']}\nSolar Radiation: {doc['solarRad']}\nSalinity: {doc['salinity']}\nPH: {doc['pH']}""" st = f'Sensor data on {str_date}' for key in param_arr: st += '\n{:<12}: {:.2f}'.format(key, float(doc[key])) dispatcher.utter_message(text=st) except: dispatcher.utter_message(text='No data recorded on ' + str_date) return [AllSlotsReset()]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: global central_verses central_verses = [] return [AllSlotsReset()]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: a = templates["utter_ask_availability"] dispatcher.utter_message(a) return [AllSlotsReset()]
def build_slot_sets(self, user_profile) -> List[Dict]: """Helper method to build slot sets""" return [ AllSlotsReset(), SlotSet("user_profile", user_profile), SlotSet("user_name", user_profile.get("name")) ]
def submit( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any], ) -> List[Dict]: ''' check if registered and has library library card if has_card == True: different options depending on operating system ''' print(tracker.get_slot("has_card")) print(tracker.get_slot("operating_system")) if tracker.get_slot("has_card") == True: ''' user has a card''' if tracker.get_slot("operating_system") == True: #True = mobile dispatcher.utter_message( "You can download the app Libby from Overdrive to download ebooks" ) elif tracker.get_slot("operating_system") == False: dispatcher.utter_message( "You will have to download the app Libby on a mobile device" ) else: dispatcher.utter_message( "If you are registered you can login with your Personummer and Pin code\nOtherwise you will have to come to the library with ID to register" ) return [AllSlotsReset()]
def run(self, dispatcher, tracker, domain): dispatcher.utter_message(text="Bye-bye") return [ AllSlotsReset(), # FollowupAction("utter_restart") ]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: dispatcher.utter_message(text="Hello World!") return [AllSlotsReset()]
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: libraries = { 'majorna': 'Majorna', 'angered': 'Angered', 'stadsbiblioteket': 'Stadsbiblioteket' } print(tracker.get_slot('library')) library = tracker.get_slot("library") library = library.lower() opening_times = { 'majorna': 'Due to Covid, Majorna is closed until further notice', 'angered': 'Angered library is open 10-16 on Mondays, Wednesdays and Fridays,\n10-19 on Tuesdays and Thursdays,\n10-16 on Saturdays and closed on Sundays', 'stadsbiblioteket': 'Stadsbiblioteket is open 8-19.30 Monday to Friday,\nand 10-17 on Saturdays and Sundays' } if library not in libraries.keys(): dispatcher.utter_message( "We don't have oppening times {} for that or maybe you need to check your spelling" .format(library.capitalize())) else: dispatcher.utter_message(opening_times[library]) return [AllSlotsReset()]