Help them come to the realization that their pain is temporary and that they are valued by you.
Refuse to be sworn to secrecy. You may have to seek additional help from law enforcement or a professional counselor in order to keep them safe.
Encourage them to get professional help. Help them find treatment and offer to go with them.
It's not your responsibility to save them, but you can continue to reach out* and tell them you care about them.
*One exception here is if it's an ex trying to manipulate you. Refer them to another source of support, but don't prolonging the relationship any further.
Offer hope.
Don't promise confidentiality.
Get professional help.
Make a plan for life.
Keep reaching out to them.
Help them develop a “Plan for Life,” steps that they promise to follow if they find themselves in another crisis. Their plan for life can start with a verbal agreement not to act on their thoughts before talking to someone. The next step is reaching out to a professional. Provide them with emergency contact numbers such as the National Suicide Prevention Lifeline at 1-800-273-TALK(8255).