How to end the chat conversation for user inactivity

Hi, I am trying to end the chat conversation if there is no user input for 120 seconds. I am not sure how to achieve the desired output. Can someone help me out.

Example: Bot: Welcome to chatbot. User: hi Bot: how can I help you?

(After 120 secs)

Bot: The conversation will now be closed due to inactivity. Bye Have a great day.