During the next ten years he lived in poverty and taught for a living. He was later granted several important official posts during the Tang dynasty. Yan was promoted when Li Shimin  ascended the throne, but resumed his duty after his mother's funeral.
For the next decade, Yan experienced economic hardship and worked as an educator. He was subsequently appointed to several influential positions during the Tang dynasty. Upon Li Shimin's ascension to the throne, Yan was elevated, only to return to his role following his mother's death.