The gut microbiota of Drosophila melanogaster mainly comprises Acetobacter spp. and Lactobacillus spp., and their relative abundance changes at the individual level and throughout development; however, how the microbiota is assembled is not well understood. Chun-Nin Wong et al. manipulated the fly gut microbiota and carried out behavioural and chemosensory assays that showed that the composition of the host microbiota can influence not only microbial acquisition but also nutritional preferences. These findings support the notion that the gut microbiota can modify host responses. Moreover, the data suggest that microbial acquisition and foraging decisions are driven by chemosensory responses.