Genies, like humans, have prophets of their own kind. What is well used in the verses of Surah Al-Jinn is that the Qur'an and Islam were revealed to everyone, even them, and the Prophet of Islam was sent to everyone, but there is no obstacle to the messengers and their representatives being invited by the Prophet PBUH. They have been. (1)
The Prophet of Islam, peace and blessings of God be upon him, also had contact with the jinn and offered them divine commands and duties. These matters are clearly stated in Surah Al-Jinn and verse 30 of Surah Al-Ahqaf.
The jinn considered themselves the addressees of the Qur'an and listened to it. A group of jinns pledged allegiance to the Prophet and became his representative among their tribe. Sometimes some jinns would come to the Messenger of God and ask their questions.
The pure Imams (as) also had relations with the jinn after the Messenger of God, due to the responsibility of their Imamate. When the representative of Imam Ali (as) among the jinn died, his son came to the Imam and got a homework. The Imam also replaced him with his father. It goes without saying that the relationship between the Imams and the Prophets and the jinn was not limited to these cases. Genies have more abilities than humans in some things due to the nature of their creation; Hence, the prophets and imams used their jinn friends and devotees to do difficult things.(2)
(1): Makarem Shirazi, Nasser, Tafsir Nomoneh, vol. 5, p. 443