https://discord.gg/botpress logo
#🤝help
Hi, is there a way to capture the time it takes a user to respond to a bot?
# 🤝help
b

bored-eye-5625

11/22/2023, 3:54 PM
I'm building a bot that will need to capture the time in minutes/seconds that it takes a user to respond to a bot's last statement or question. For example, if the bot asks the user "what is 1 + 1?" I need to capture the time it took from after the bot asks the math question to when the user submits an answer. Any help here is greatly appreciated, I'm curious whether this is a coding solution or if BP has built in capability to measure elapsed time. Thanks!
f

famous-jewelry-85388

11/22/2023, 11:23 PM
Hey, That's a very good question, can you tell me more about your use case?
I believe it is possible using the luxion library in an execute code card
something like: workflow.startTime = new DateTime() Then after the user responds: workflow.elapsedTime = (new DateTime() - workflow.startTime) /1000
I am not sure, I wrote this code here and didn't test it
b

bored-eye-5625

12/13/2023, 7:35 PM
Interesting, that's worth a try thanks for the input. I saw in the BP docs that you can enable showTimestamp after every comment, so that's one way to accomplish the necessary, but I agree an execute code card is the better route
f

famous-jewelry-85388

12/18/2023, 3:32 PM
@bored-eye-5625 how is it going?
b

bored-eye-5625

12/20/2023, 10:45 PM
@famous-jewelry-85388 well I got sidetracked by client demands and another pet project, so I haven't yet worked through this one. But once I do I'll post the results, I could see this being a useful little tool for a lot of use cases
f

famous-jewelry-85388

01/08/2024, 6:45 PM
Perfect!
I have marked this thread as solved. Please start a new thread in case you have new inquirie or questions 🙂