Stuck User - Choice.trim is not a function thrown in done.js
Hi guys, I'm having an issue with my bot.
An important user account is stuck in a loop, we made a change to the choice prompt and added an invalid third parameter (not an string array), this is fixed now but any message sent by the user throws an error.
I saw similar issues already posted but none have a clear answer on how to unstuck the affected users.
What should I do? I'm running the latest version of the bot connector in a Node.js server.
I got this error just before the user got stuck. Maybe he is waiting for a choice in the list but there is no valid choice to pick.
{"error":{"message":"(#100) Param message[quick_replies][0][title] must be a UTF-8 encoded string","type":"OAuthException","code":100,"fbtrace_id":"FxA1o2CWH5u"}}
Do you have a bot.endConversationAction()? If you add this to your bot they can just say "goodbye" to reset their state and start over. The second option is you can add a dialogVersion() middleware:
bot.use(builder.Middleware..dialogVersion({ version: 1.0 }));
Anyytime you make a major change to your bot you can increment this version number and force to have all current conversations ended.
@alonsonic I too had this problem today. I solved it by clearing all the userData + conversationData for that particular user.
I tried bot.endConversationAction() but didn't work. Didn't try dialogVersion() middleware.
What I did instead:
- Get an authorization token as per MS botframework REST API for authentication
- Submit a DELETE request with the authorization token in the header to
https://state.botframework.com/v3/state/{channelId e.g. facebook}/users/{userId}as per documentation here
This should clean up all conversationData + userData of that particular user, i.e. user is back to a clean state. You could get and back up the userData before deleting (step 2) and set the userData back after deleting (step 2) to avoid losing userData. Hope this helps!
Hello @josephktcheung and @Stevenic thank you for the help!
I manage to fix it following @josephktcheung advice, didn't get to try the dialog version but it's good to know for the future as well.
Thank you both
Glad to hear @alonsonic , feel free to reach out for any issues in the future. Thanks @Stevenic and @josephktcheung for the valuable input. Happy bot coding :)