While it is difficult to be certain, it sounds like your rat ate something that became caught in its throat. That can cause drooling, foaming and a sticky mucus-like discharge from its mouth. If this is what has happened-- other than taking your rat to a vet that has experience treating rats-- all you can do is try to make your rat comfortable and make sure that it is still able to breathe. If you find that your rat is not able to breathe, then you should employ the Rat Swing or the rattie Heimlich maneuver (explained below).

In most cases when a rat exhibits the symptoms you mention, it is a case of an object or food caught in the throat. If this continues to be a problem today you may need to see a vet. However-- are you sure that you rat did not ingest a more toxic substance? Sticky foods can lead to choking / gagging in rats. But substances like a stray pill or household chemical can also cause problems.

The best way to prevent choking in your rat is to avoid foods such as peanutbutter and really fresh bread (toast doesn't seem to be as troublesome). Some rats literally inhale their treats and this causes the choking/drooling to occur. There is a rattie Heimlich (which should be used if your rat can't breathe and is turning blue from choking): press sharply up and in underneath the rat's ribcage. There is also something called the "rat fling" where you hold the rat around the neck with one hand and the base of the tail with the other, lift the rat overhead and bring the rat down in a rapid arc with the rat's head downward. It's supposed to work after about 3 or 4 times (according to Debbie Ducommun's Rat Health Care), at which point you should check the rat's mouth for the dislodged object/food.