An allergic reaction will only happen if you are already sensitized to an allergen. It means that you have previously encountered the allergen, and your immune system has skewed towards the allergic response to that particular allergen. It has produced allergen-specific IgE antibodies that bind to mast cells via a high-affinity FcεRI receptors. Read more about the allergic sensitization.
The mast cells contain granules that hold a mixture of pre-formed chemical mediators, including histamine, cytokines and leukotrienes. The second time the body encounters the allergen, the IgE antibodies on the surface of the mast cells recognize and bind it. If the allergen binds to two or more IgE antibodies simultaneously, the IgE's cross-link. This activates a signaling pathway that leads to degranulation of the mast cells and the release of histamine and other chemicals.
While histamine is the chemical causing the perceptible allergic symptoms, some of the cytokines promote further differentiation of B cells to plasma cells. The plasma cells in turn produce more IgE proteins, which can bind more allergens. This maintains the cycle of the allergic response.