Abu Hurairah reported,

The Prophet ﷺ said, "Allah the Exalted says, 'I am as My servant thinks of Me, and I am with him whenever he remembers Me.'"In another narration, "Allah عز وجل says, 'I am as My servant thinks of Me, and I am with him whenever he calls upon Me.'"

Azami 10879

Sahih

عن أبي هريرة قال

قال النبي ﷺ: يقول الله تعالى: أنا عند ظن عبدي بي، وأنا معه إذا ذكرني… وفي رواية: إن الله عز وجل يقول: أنا عند ظن عبدي بي، وأنا معه إذا دعاني

الأعظمي 10879صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Supplications, remembrances, and prayer upon the chosen Prophet ﷺ
Chapter
Virtue of supplication
Section
Allah is as His servant expects of Him, so He answers his supplication
Numbering
Jami al-Kamil 10879 (2nd edition)
Azami 10879