Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:27:18

Until, when they came upon the valley of the ants, an ant said, "O ants, enter your dwellings that you not be crushed by Solomon and his soldiers while they perceive not."  

When they came to the Valley of the Ants — which is ˹located˺ either in Tā’if or in Syria, and whose ants are either small or large — an ant, the queen ant, who had seen Solomon’s hosts, said, ‘O ants, enter your dwellings, lest Solomon and his hosts crush you while they are unaware!’ — the ants are likened to rational beings in their use of the latter’s speech.
القرآن:٢٧:١٨

حَتَّىٰ إِذَا أَتَوْا عَلَىٰ وَادِ النَّمْلِ قَالَتْ نَمْلَةٌ يَا أَيُّهَا النَّمْلُ ادْخُلُوا مَسَاكِنَكُمْ لَا يَحْطِمَنَّكُمْ سُلَيْمَانُ وَجُنُودُهُ وَهُمْ لَا يَشْعُرُونَ  

{حتى إذا أتوْا على وادِ النمل} هو بالطائف أو بالشام، نمله صغار أو كبار {قالت نملة} ملكة النمل وقد رأت جند سليمان {يا أيها النمل ادخلوا مساكنكم لا يحطمنكم} يكسرنكم {سليمان وجنوده وهم لا يشعرون} نزل النمل منزلة العقلاء في الخطاب بخطابهم.