You need to ring when you are still some way away, so they have time to react, and if they don't you can slow down and ring a second time. And travel at an appropriate speed for the location.
(I have an ebike, so this is especially important. Mine is a legal one: 25 km/h max, 250 W, etc. If yours is faster, this is even more important.)
i like to sing "geeettt outt of the biiiiike laaaannne!" as loud as possible with my big fat tenor voice as i ride past them ringing my bell repeatedly the entire time. a single bell ring never seems to get anyone's attention
(I have an ebike, so this is especially important. Mine is a legal one: 25 km/h max, 250 W, etc. If yours is faster, this is even more important.)