Automatic Thread Creation after a Certain Number of Messages

I would like a feature where the bot automatically creates a thread after so and so many replies to a message or subsequent replies to it. This way, larger discussions could be moved to a thread. Perhaps it’s also possible for the bot (using Webhooks) to send the previously sent messages into the thread once it has created it.