The mechanism by which they do this is pretty darn cool: gram - negative bacteria
secrete acyl - homoserine lactones — compounds that are similar in taste to bitter plants like angelica or dandelion, thereby activating T2R cells and triggering a release of antibacterial compounds into epithelial cells.