Dark matter accounts for 85% of the matter in our Universe. The mass assembly history (MAH) of dark matter halos plays a leading role in shaping the formation and evolution of galaxies. MAHs are used extensively in semi-analytic models of galaxy formation, yet current analytical methods to generate them are unable to capture their relationship with the halo internal structure and large-scale environment. This paper introduces FLORAH, a machine-learning framework for generating assembly histories of dark matter halos. We train FLORAH on the assembly histories from the MultiDark N-body simulations and demonstrate its ability to recover key properties such as the time evolution of mass and dark matter concentration. By applying the Santa Cruz semi-analytic model on FLORAH-generated assembly histories, we show that FLORAH correctly captures assembly bias, which cannot be reproduced with current analytical methods. FLORAH is the first step towards a machine learning-based framework for planting merger trees; this will allow the exploration of different galaxy formation scenarios with great computational efficiency at unprecedented accuracy.