Automatically triggered chat-poll

I imagine this to be quite a lot of work, but recently I’ve seen polls created automatically upon x number of users sending chat messages that contain only a number.
So if 5 people type “1” and 6 people type “2” it will automatically create a chat-only (= not via twitch polls) poll and post the answers sorted by their number of appearance as well as an average. If no number is posted for X number of seconds, the poll closes. As long as that doesn’t happen, the preliminary results are posted at regular intervals.
The beauty seems to be that it isn’t restricted to any number of answers. For example one streamer was asking for the age of his viewers. A couple hundred people wrote their age in chat which resulted in an output like “Results: 27: 102, 29: 100, 25: 91, …, average: X”. It should make sure to only count a message by a specific user once even if this user reposts the same number. Optionally it could overwrite the initial answer if it differs. But I think just ignoring the second input would be fine.

Ideally this would have easily accesible options for:

  • Number of messages needed before the poll triggers (so that larger streamers can adjust accordingly)
  • Time after latest number-message before the poll closes