How to get conversation duration for the chat for the users and plot a widget for it.

Hi , I need to develop a dashboard which should have the details for the duration of time each user spent with the bot.
But I dont know how to get the end time and plot in the widget.
Could anyone help in this?

Thanks
Ravi