Felahu's-Sail that; "Whoever wants to have the honor of seeing the Commander of the Faithful, Imam Ali (a.s.) in his dream, should say the following before sleeping:
اَللهُمَّ اِنّي اَسْئَلُكَ يا مَنْ لَهُ لُطْفٌ خَفِىٌّ وَ اَياديهِ باسِطَةٌ لا تَنْقَضي اَسْئَلُكَ بِلُطْفِكَ الْخَفِىِّ الَّذي ما لَطُفْتَ بِهِ لِعَبْدٍ الاّ كُفِىَ أنْ تُرِيَني مَوْلاىَ عَلِىَّ ابْنَ اَبي طالِبٍ عَلَيْهِ السَّلامُ في مَنامي
Allahumme innî es'eluke yâ men lehu lutfun hafiyy, ve eyâdîhi bâsitatun lâ tenqazî es'eluke bi-lutfikel hafiyyillezî mâ letufte bihi li'abdin illâ illâ kufiye en turiyeni mevlâye aliyyebne ebi talibin aleyhisselâmu fî menâmî.
[O Allah, your grace is secret and your blessings are inexhaustible, my Lord! I ask you to show my master Ali ibn Abu Talib (a.s) in my dream, by means of your secret grace. Because when you are gracious to one of your servants, you are sufficient for him.]