def makeCoffee(self, hermes: Hermes, intent_message: IntentMessage): current_session_id = intent_message.session_id formatoCoffe_slot = intent_message.slots.coffeeFormat.first( ).value or coffee_dict_slot['formatoCoffe'] tipoCoffe_slot = intent_message.slots.coffeeType.first( ).value or coffee_dict_slot['tipoCoffe'] coffee_dict_slot['formatoCoffe'] = formatoCoffe_slot coffee_dict_slot['tipoCoffe'] = tipoCoffe_slot if not formatoCoffe_slot: result_sentence = "Certo! Come lo preferisci? Corto,lungo o espresso?" return hermes.publish_continue_session(current_session_id, result_sentence, [MAKE_COFFE]) if not tipoCoffe_slot: result_sentence = "Come lo preferisci? Schiumato,macchiato o decaffeinato?" return hermes.publish_continue_session(current_session_id, result_sentence, [MAKE_COFFE]) result_sentence = "Caffè {} {} in preparazione.".format( tipoCoffe_slot, formatoCoffe_slot) coffee_dict_slot['formatoCoffe'] = None coffee_dict_slot['tipoCoffe'] = None hermes.publish_end_session(current_session_id, result_sentence)
def test_continue_session_slot_filler(self): h = Hermes(HOST) h.ffi = mock.MagicMock() with h: h.publish_continue_session("session_id", "Tell me what the missing slot is", ["intent1"], None, False, "missing_slot") continue_session_message = ContinueSessionMessage( "session_id", "Tell me what the missing slot is", ["intent1"], None, False, "missing_slot") h.ffi.dialogue.publish_continue_session.assert_called_once_with( continue_session_message)
def makeTea(self, hermes: Hermes, intent_message: IntentMessage): current_session_id = intent_message.session_id formatoTea_slot = intent_message.slots.teaFormat.first().value if not formatoTea_slot: result_sentence = "Certo! Come lo preferisci? Grande, medio o piccolo?" return hermes.publish_continue_session(current_session_id, result_sentence, [MAKE_TEA]) result_sentence = "Tè {} in preparazione.".format(formatoTea_slot) hermes.publish_end_session(current_session_id, result_sentence)
def makeChoc(self, hermes: Hermes, intent_message: IntentMessage): current_session_id = intent_message.session_id formatoChoc_slot = intent_message.slots.chocFormat.first().value if not formatoChoc_slot: result_sentence = "Certo! Come la preferisci? Grande, media o piccola?" return hermes.publish_continue_session(current_session_id, result_sentence, [MAKE_CHOC]) result_sentence = "Cioccolata {} in preparazione.".format( formatoChoc_slot) hermes.publish_end_session(current_session_id, result_sentence)
def PickRandomBoardgameCallback(self, hermes: Hermes, intent_message: IntentMessage): num_players_slot = extractSlot(intent_message.slots, "numberOfPlayers") num_boardgames_slot = extractSlot(intent_message.slots, "numberOfPropositions") numberOfBoardgames = num_boardgames_slot if num_boardgames_slot else self.numberOfBoardgames if not num_players_slot: return hermes.publish_continue_session( intent_message.session_id, required_slots_questions["num_players"], ["hjwk:ElicitNumPlayers"], custom_data=str(numberOfBoardgames)) hermes.publish_end_session(intent_message.session_id, "") boardgames = self.apiHandler.getRandomBoardgames( num_players_slot, numberOfBoardgames) hermes.publish_start_session_notification( intent_message.site_id, self.GenerateBoardgamesAnswer(boardgames, num_players_slot), "")