Someone who is determined to commit suicide will do so, and will do so in such a way that no one finds out about it until it's too late. You can't help them. They've made their choice. Everyone else... EVERYONE else is looking for attention, and is waiting to see what the people in their lives do when they tell them what they are contemplating. What you do and say will determine whether they decide to go through with it or not.
Take them seriously and listen to them. Listen to them until they want to stop talking, even if it takes minutes, hours or days. Listen to them and try to get them to say more. Talking helps, and if they think someone truly cares about how they feel, what they think and what happens to them then maybe... just maybe.. they won't go through with it.
The seriousness of this cannot be overblown. If they're down to threatening suicide, even if they aren't really serious, then you are playing catch up and whatever their problems are, you won't solve them right away, even if you are a trained psychologist. If you understand this, then you have three tasks: Make them understand it, make them believe that their problems CAN be solved, and give them a reason to try.
Basically, if someone tells you they are going to commit suicide, then you just became their life-line. They came to you for a reason, and that reason could be the way you turn them around. Either you are the source of their problems (in their mind at least), or you are the only thing keeping them alive. Either way.... sucks to be you.