The Messenger of Allah ﷺ said, "When the imam says, 'Allah hears whoever praises Him,' say, 'Our Lord, to You belongs all praise.'"
حدثنا عبد الرزاق حدثنا معمر عن الزهري
أن رسول الله ﷺ قال إذا قال الإمام سمع الله لمن حمده فقولوا ربنا ولك الحمد
Its isnad is sahih, mentioned previously at 9885.