It is random. If you and your friend open at the same time the game there is a high possibility to play together. In the next big update we will include a lobby scene.