Often when this happens you will take damage on the first warp-in. As always, pull your SCVs to safety and send part of your army over to deal with it (you should never be sending your whole army, that would open you up somewhere else).
If you don't kill the warp prism the first time, it is very important to leave defense in your base:
- If its early in the game and you're both on 1 base, the most gateways he could have would be 3 or 4, so leave 6-8 bio units.
- If its in the mid to late game, patrol a viking off the cost of your base, and leave a dozen or so bio units.
- Building a turret behind your mineral line only costs 75 minerals, and having one there will force your opponent to warp-in in a different part of your base, which buys you precious seconds.
- If you have a factory sitting idle, build a widow mine or two and position them where you think the protoss player will come back with his warp prism.
Once you kill the warp prism, you're usually safe to relax a little bit, because the protoss player will need to be using his robotics bay for colossus/immortal production.