Sefer Chasidim Siman 100
Can copy this into an AI, or connect the whole library to your assistant. For deeper learning, you can directly use the original seforim, sites, and apps.
אם באת מצוה לידך שלא בכוונה תשמח ותתן שבח והודיה להקב"ה שאינה אותה לידך לעשותה:
Medieval Jewish mysticism, translated by Sholom Alchanan Singer. Northbrook, Ill. Whitehall Co., 1971
If unintentionally a meritorious deed came to your hand, rejoice and give praise and thanks to the Holy One, blessed be He, that He caused it to come to your hand for you to perform it.¹
footnotes: ¹ Toseftah, Peah, Chapter III.