A new general synthesis of pharmaceutically important azolo[1,5-a]pyrimidines starting from widely available 3(5)aminoazoles, aldehydes, and triethylamine is developed. The key is to enable the vinylation reaction that allows the in situ generation of elusive acyclic enamines and the subsequent annulation reaction to occur. This direct and practical strategy is capable of constructing a range of 5,6-unsubstituted pyrazolo[1,5-a]pyrimidines and [1,2,4]triazolo [1,5-a]pyrimidines. More importantly, this protocol provides a concise synthetic route to prepare the clinically used zaleplon.