Habitat models rarely consider macroinvertebrate communities as ecological targets in rivers. Available approaches mainly focus on single macroinvertebrate species, not addressing the ecological needs and functionality of the whole community.This research aimed at providing an approach to model the habitat of the macroinvertebrate communities. The study was carried out in three rivers, located in Italy and characterized by a braiding morphology, gravel riverbeds, and low flows during the summer period. The approach is based on the recently developed Flow-T index, together with a Random Forest (RF) regression, which is employed to apply the Flow-T index at the mesohabitat scale. Using different datasets gathered from field data collection and 2D hydrodynamic simulations, the model was calibrated in the Trebbia River (2019 field campaign) and validated in the Trebbia, Taro, and Enza rivers (2020 field campaign).The RF model selected 12 mesohabitat descriptors as important for the macroinvertebrate community. These descriptors belong to different frequency classes of water depth, flow velocity, substrate grain size, and connectivity to the main river channel. The cross-validation R2 coefficient (R2cv) of the training dataset was 0.71, whereas the R2 coefficient (R2test) for the validation dataset was 0.63. The agreement between the simulated results and the experimental data shows sufficient accuracy and reliability. The outcomes of the study reveal that the model can identify the ecological response of the macroinvertebrate community to possible flow regime alterations and river morphological modifications.Lastly, the proposed approach allowed to extend the MesoHABSIM methodology, widely used for the fish habitat assessment, to a different ecological target community. Further applications of the approach can be related to ecological flows design in both perennial and non-perennial rivers, including river reaches in which fish fauna is absent.