I have an error that only happens with already log...
# 🤝help
b
If I go to the emulator and login, then continue the conversation everything works just fine. However, in my test device where I'm already "logged in" if I do the same path, I get this error. I haven't been able to fix it since there's literally no way (that I've found) to repro on the emulator. So, is there a way I can force a WhatsApp user to sign out? (not sure how, I only know //state/reset would work, are there any others like this? (I also tried deleting the conversation to try to force it to restart but I can't delete the user var on WhatsApp)
f
Hey there👋 Could you share the code that throws this error?
b
sure sure, it seems to all be from here:
Copy code
const DateTime = luxon.DateTime.now().setZone('America/New_York').toFormat('dd-MM-yyyy @ HH:mm:ss')

const currFlow = 'chat-flow'
const lastNode = 'antes-de-flow'

if (workflow.userSessionId != -1) {
  if (!workflow.userPathToNow[currFlow]) {
    workflow.userPathToNow[currFlow] = []
  }

  workflow.userPathToNow[currFlow].push(lastNode)

  const updateRecord = {
    usageEnds: DateTime,
    lastFlowVisited: currFlow,
    lastInteractionNode: lastNode,
    userPathDetails: workflow.userPathToNow
  }

  const updateRecordSuccess = await UserPathTable.updateRecord(workflow.userSessionId, updateRecord)

} else {
  workflow.userPathToNow[currFlow] = [lastNode]

  const newRecord = {
    userId: parseInt(user.userId),
    userName: user.userName_api, 
    usageEnds: DateTime,
    lastFlowVisited: currFlow,
    lastInteractionNode: lastNode,
    userPathDetails: workflow.userPathToNow
  }

  const createdRecord = await UserPathTable.createRecord(newRecord)
  workflow.userSessionId = createdRecord.id
}
I should note that this has been working just fine until recently, I didn't change anything rather, people who hadn't spoken to the bot for a while talked to it and the error was triggered. Also, I have a default variable created with value to -1 if there is none available
f
Hey there, Sorry for getting back to you so late
If its okay, could you send me the bot. Will be a bit easier to dive deeper
20 Views