Feeding behaviour is modulated by both environmental cues and internal physiological states. Appetite is commonly boosted by the pleasant smell (or appearance) of food and destroyed by a bad taste. In reality, animals sense multiple environmental cues at the same time and it is not clear how these sensory inputs are integrated and a decision is made to regulate feeding behaviour accordingly. Here we show that feeding behaviour in Caenorhabditis elegans can be either facilitated by attractive odours or suppressed by repellents. By identifying mutants that are defective for sensory-mediated feeding regulation, we dissected a central flip-flop circuit that integrates two contradictory sensory inputs and generates bistable hormone output to regulate feeding behaviour. As feeding regulation is fundamental to animal survival, we speculate that the basic organizational logic identified here in C. elegans is likely convergent throughout different phyla.