def handle_set_session_data(self, event): data = event.get("data", "{}") try: dict_data = json.loads(data) var_data = self.state.get("var_data", {}) final_var_data = Util.merge_dicts(var_data, dict_data) self.state["var_data"] = final_var_data except ValueError: logger.error(f"Set session data payload is not in json format {data}") return []
def __get_node(self, message_data): """ Get next_node(ANA output node) to send to user depending on current_node and the incoming message. If it's a first time user, next_node is first_node """ get_started_node = self.state.get( "flow_id", "") + "." + flow_config["first_node_key"] next_node_id = get_started_node event_data = [] if bool(self.state.get("current_node_id")): # user already in ana flow current_node_id = self.state.get( "current_node_id", get_started_node) # give first_node as default next_node_data = AnaNode(current_node_id).get_next_node_data( message_data, self.state) event_data = next_node_data.get("publish_events", []) next_node_id = next_node_data["node_id"] var_data = self.state.get("var_data", {}) new_var_data = next_node_data.get("input_data", {}) logger.debug(f"var_data type is {type(var_data)} {var_data}") logger.debug( f"new_var_data type is {type(var_data)} {new_var_data}") logger.debug(f"var_data type is {type(var_data)} {var_data}") logger.debug( f"new_var_data type is {type(new_var_data)} {new_var_data}") final_var_data = Util.merge_dicts(var_data, new_var_data) self.state["var_data"] = final_var_data self.state["new_var_data"] = new_var_data # self.state["current_node_id"] = next_node_id node = AnaNode(next_node_id).get_contents() return {"node": node, "publish_events": event_data}