working code for both text and voice sessions