English Wikisource had a bot which would perform OCR on request by a user when the user pressed a button in the Wikisource website interface.
Is that like what you are trying to achieve?
I think it used categories as a work queue. JavaScript placed the page in a category, and the bot picked up the page from the category and removed it from the category once the bot task had completed.
Some tools use a wiki page as a register of bot commands to be executed by the bot.
If you need more complex interaction between user and bot via JavaScript, the bot will likely need to provide a http listener that the JS and bot can communicate via.