Automatic water pump for water tank
A simplification of @spicetraders answer:

Pump up switch

You can do this with a "pump up float switch", which operates at line voltage and thus avoids the need for a relay, separate power supply, etc. These cost tens of dollars.



These often have a plug on the end so they can control a plug-in pump directly (be sure to get one with the appropriate plug type, voltage and power rating for your pump), but they can also be hardwired (just like you would with a regular switch).



Essentially the float operates on a wire, and the only concern is to ensure there's nothing for it to get hung up on:

 

By adjusting the length of wire, you can adjust the on/off setpoints.

Low water alarm

We used to often install a second float near the bottom of the tank, with a very short distance, that activated a warning light or alarm to indicate "tank almost empty" indicator. This would signal something was wrong with the main switch, pump, water supply, or simply that you were using water faster than the pump could keep up, and could take appropriate action.