Getting user input time to time in node.js program

How can I get user input from front-end of my application while on the backend a game runs in a while loop. So there are multiple agents in my network and only one player. In each iteration random two nodes are chosen from the network in order to interact, agents interact with each other and sometimes with player as well, whenever an agent interacts with the player a user input is required in order to continue the game. However I can't find any way of pausing the game in order to receive data from front-end to continue the game on the backend. Is there a way of handling what I need in node js? The game is implemented in node js. I have shared my code in my previous question and the question is more explaining, here is the link Node application interactively get user input from react front end by pausing the current execution