Rule reminder
Pronouns (direct, indirect, reflexive, ci, ne) attach to the end of the gerund: parlandogli, alzandosi, farglielo, dicendole.
'Talking to him, I realised the truth.' Which is correct?