This concept is included in the hadith of the inhabitants of the cave. Because each of them mentioned one of their good deeds which they did only for Allah and to get close to him. So, when they were supplicating by their good deed, Allah responded to them.
Source: Bukhari: 2215
Duas from IslamicAPI's Masnun Dua dataset (based on the Quran, hadith, Hisnul Muslim and Rahe Belayat). See the dataset