How do crossbow traps work?

Solution 1:

Weapon traps with ranged weapons are exactly like weapon traps with anything else - when the trap is triggered, the weapon attacks.

Ranged Weapon Traps specifically, however, do require ammo and need to be reset, same as Stonefall and Cage Traps (but with bolts rather than stones or cages). They'll use whatever bolts your mechanic can get their hands on, so you might want to forbid certain bolts / use burrows if you'd rather the trap be loaded with a specific batch.