Evolving intentions for social interaction: from entrainment to joint action