The reaction of 5-benzenesulfonyl-3,4-dihydro-1 H-pyridin-2-one derivatives with azides or isocyanides provided two new classes of compounds, triazolo[4,5-b]pyridin-5-ones 3 or pyrrolo[3,4-b]pyridin-2-ones 4, respectively, in good yields and regioselectivity. A representative set of 20 compound 3 and 12 compound 4 was prepared.