If the chain broke, but there is still a bit of chain sticking out, then just buy a new chain pull from any hardware store, or even just Walmart.
If the chain is no longer showing outside the housing at all, then check out the links below. The first link below shows the basic process of replacing the light switch pull, and the second video shows the procedure for the 3-speed fan switch replacement. Your model may be different, but the procedure is basically the same. The only difference may be the disassembly process and the location of the screws. If you post the fan's model information, we may be able to assist further.
https://youtu.be/3r_KSkhdtpQ
https://youtu.be/lhzDiARHTfk