027.018 At length, when they came to a (lowly) valley of ants, one of the ants said: “O ye ants, get into your habitations, lest Solomon and his hosts crush you (under foot) without knowing it.”
027.019 So he smiled, amused at her speech; and he said: “O my Lord! so order me that I may be grateful for Thy favours, which thou hast bestowed on me and on my parents, and that I may work the righteousness that will please Thee: And admit me, by Thy Grace, to the ranks of Thy righteous Servants.”
Note that the Ant didn’t talk to Solomon but to her companions and warns them that they should protect themselves. It is a scientific fact that Ants communicate through chemicals called pheromones, but they also possess anatomical apparatus for producing sounds. Scientists have recorded signals that are believed to correspond to distress and attack in addition to an “all’s well” signal. Since God knows the speech of his creation, this is what He is reporting. Also note that God confirms that Solomon was given certain talents, miracles, if you will, which were not given to other people. And it is typical of Quran that anything that is out of the ordinary is mentioned as such, which is not the case with sacred scriptures of other religions. In other words, Solomon was able to hear this sound and who does he talk to? Certainly not to the Ant but to God Himself.