Sefer Shem Mishmuel, translated to English by Rabbi Zvi Belovski (page 347), relates that:
While journeying to meet …Balak, with the intention of cursing the …Jewish nation, …Bila’am had difficulties with his donkey. The animal kept stopping [or straying off of the path], frightened by an angel that Bila’am was unable to see. Bila’am lashed out at the animal, and after the third time a miracle occured:
Hashem opened the mouth of the donkey, and it said to Bila’am. “What have I done to you, that you hit me these three times?” (Sefer Bamidbar Perek 22, posuk 28, as cited in the Sefer Shem Mishmuel, page 347)