She started getting noticed with her roles in Buffy the Vampire Slayer as Willow Rosenberg and in the American Pie movies as Michelle Flaherty . She is currently on the television series How I Met Your Mother She is known for her roles as Willow Rosenberg on the cult classic television series Buffy the Vampire Slayer , Michelle Flaherty in three American Pie films and Lily Aldrin on the CBS sitcom How I Met Your Mother .