The influence of local environment on the emergence of AGN activity in galaxies