def format_bot_output( message: Dict[Text, Any] ) -> Text: """Format a bot response to be displayed in the history table.""" # First, add text to output output = message.get("text") or "" # Then, append all additional items data = message.get("data", {}) if not data: return output if data.get("image"): output += "\nImage: " + data.get("image") if data.get("attachment"): output += "\nAttachment: " + data.get("attachment") if data.get("buttons"): output += "\nButtons:" for idx, button in enumerate(data.get("buttons")): button_str = button_to_string(button, idx) output += "\n" + button_str if data.get("elements"): output += "\nElements:" for idx, element in enumerate(data.get("elements")): element_str = element_to_string(element, idx) output += "\n" + element_str return output
def format_bot_output( message: Dict[Text, Any] ) -> Text: """Format a bot response to be displayed in the history table.""" output = message.get("text") or "" # Append all additional items if data is not None data = message.get("data", {}) if not data: return output if data.get("image"): output += "\nImage: " + data.get("image") if data.get("attachment"): output += "\nAttachment: " + data.get("attachment") if data.get("buttons"): for idx, button in enumerate(data.get("buttons")): button_str = button_to_string(button, idx) output += "\n" + button_str if data.get("elements"): for element in data.get('elements'): import json output += "\nElements: " output += "\n" + json.dumps(element) return output
def print_bot_output(message, color=utils.bcolors.OKBLUE): if "text" in message: utils.print_color(message.get("text"), color) if "image" in message: utils.print_color("Image: " + message.get("image"), color) if "attachment" in message: utils.print_color("Attachment: " + message.get("attachment"), color) if "buttons" in message: for idx, button in enumerate(message.get("buttons")): button_str = button_to_string(button, idx) utils.print_color(button_str, color)
def print_bot_output(message, color=utils.bcolors.OKBLUE): if "text" in message: utils.print_color(message.get("text"), color) if "image" in message: utils.print_color("Image: " + message.get("image"), color) if "attachment" in message: utils.print_color("Attachment: " + message.get("attachment"), color) if "buttons" in message: for idx, button in enumerate(message.get("buttons")): button_str = button_to_string(button, idx) utils.print_color(button_str, color)
def print_bot_output(message, color=utils.bcolors.OKBLUE): if "text" in message: utils.print_color(message.get("text"), color) if "image" in message: utils.print_color("Image: " + message.get("image"), color) if "attachment" in message: utils.print_color("Attachment: " + message.get("attachment"), color) if "buttons" in message: utils.print_color("Buttons:", color) for idx, button in enumerate(message.get("buttons")): utils.print_color(button_to_string(button, idx), color) if "elements" in message: for idx, element in enumerate(message.get("elements")): element_str = "Elements:\n" + element_to_string(element, idx) utils.print_color(element_str, color)
def format_bot_output(message: Dict[Text, Any]) -> Text: """Format a bot response to be displayed in the history table.""" if "text" in message: output = message.get("text") else: output = "" # Append all additional items data = message.get("data", {}) if data.get("image"): output += "\nImage: " + data.get("image") if data.get("attachment"): output += "\nAttachment: " + data.get("attachment") if data.get("buttons"): for idx, button in enumerate(data.get("buttons")): button_str = button_to_string(button, idx) output += "\n" + button_str return output