https://discord.gg/botpress logo
Hey guys! I'm trying to build a code to
# 💻developers
w
Hey guys! I'm trying to build a code to compare the user last interaction time with the current time. And based on that difference, it should change a variable to true. I'll send the code that i came with, but its not working, so i hope you guys could help me Code:
Copy code
const lastInteraction = luxon.DateTime.fromISO(conversation.lastInteractionTime)
const currentTime = luxon.DateTime.now()
const difference = currentTime.diff(lastInteraction, 'minutes').minutes

if (difference >= 2) {
  conversation.followUpMessage = true // Set followUpMessage to true if the difference is greater than or equal to 1 minute
}
w
i've created an EC and write this before your code and it works:
conversation.lastInteractionTime = "2025-02-20T17:04:22.436+00:00"
Has
conversation.lastInteractionTime
a value? is it a string?
w
Its a string in ISO format
I catch that variable with a hook
That part actually works, the problem i guess is with the "if" part
It doesn't set the conversation.followUpMessage = true when matches de condition