Start with basic four-part style. It takes practice. Start with just V-I cadences. Practice writing different variations on those with different inversions, sometimes adding the 7th to the V. Do this in both major and minor keys, getting used to raising the third of the V chord in the minor mode. Make sure you are following the rules each time. Once you master that, add the IV (iv in minor) triad to the mix. Don't just improvise them, though, because it's easy to accidentally play parallel octaves/fifths if you're not writing it out. Write it all out on bass and treble clef. Once you mess around with the I (i in minor), V, and IV (iv in minor) chords, add the vi (VI in minor) triad and the ii (ii° in minor) triad to the mix. (When using the ii° in minor mode, don't put it in root position). Once you can write clean four-part style with those chords, add the vii° (can substitute for the V chord) triad (like the ii° chord, don't use it in root position) and vii°7 (root position is okay with the 7th added). I don't recommend throwing the iii (III in minor) chord into the mix until you're set with all the other diatonic chords, simply because it's function is quite elusive.
Once you're good with those, add 7ths to the mix. Then secondary dominants, then chords borrowed from the major/minor, then augmented 6th chords, then the Neopolitan. Always be mindful to watch for those parallel fifths/octaves, voice crossings, augmented intervals, etc.
Basically, my answer to your question is that it's progression of learning. Start with the very basics and make sure you are solid there. Then add to it progressively. I assume your tonal theory book covers harmonic tendencies of the diatonic chords (ie. dominants (V, vii°), pre-dominants (vi, IV, ii), etc.) and common cadences.
Write it out on sheet music, employ different keys to train yourself. Once you're more comfortable with the voice-leading rules, you can start to improvise them at the piano as long as you're careful. But don't stop writing it out.
Practice makes perfect, good luck my friend. Get a workbook too, if you'd rather not design your own exercises.