In 820, by which time Li Heng was emperor (as Emperor Muzong), Cui Tanjun was recalled to Chang'an, and he offered to Emperor Muzong, as a gift, a collection of over 100 poems by Yuan Zhen. Emperor Muzong was pleased, and asked Cui where Yuan was at that point, and Cui replied that Yuan was serving in an office lacking authority. That same day, Emperor Muzong promoted Yuan to be "Cibu Langzhong" (), a supervisorial official at the ministry of rites, and further put him in charge of drafting edicts for Emperor Muzong. However, because this was an irregular promotion, Yuan was looked down by his colleagues. On one occasion, when many imperial officials were gathering to eat melons, there were flies which gathered on the melons. Wu Ruheng () waved his fan to chase away the flies, and made the double entendre, "Where did you come from? Why did you come here?" This caused many of Wu's colleagues to be shocked and lose composure, but Wu did not. Nevertheless, Yuan's poetry continued to become increasingly popular at Chang'an, such that the people were rushing to learn it. Soon thereafter, Yuan was made chief imperial scholar (翰林承旨學士, "Hanlin Xueshi") as well as "Zhongshu Sheren" (), a mid-level official at the legislative bureau. Because of the friendship that Yuan had with Cui, the other eunuchs were also trying to become friendly with Yuan, particularly the one of the directors of palace communications ("Shumishi"), Wei Hongjian ().