Become aware of your emotional state and see temptation coming before it arrives.
Relapse is not an event that suddenly occurs. By using Michael Dye's "The Faster Scale", a person can train themself to notice their pattern of biological, psychological, and social changes that lead to relapse.
Once identified, evasive action can be taken. This website is an online version of The Faster Scale.