Closed theodor961 closed 9 months ago
Hey @theodor961, thank you for reporting this! I should be able to take a look at this later tonight. In the meantime, if it's alright with you, would you be able to share screenshots showing the duplicate messages along with your bot configurations?
my pleasure,
i used the default flow and default bot options <ChatBot options={{chatHistory:{disabled:true}}}/>
below you can find the screenshoted result
@theodor961 Can I check if you're seeing this only in development environment? The issue is not reproducible on the playground. Any chance this is relevant for you?
Hey @theodor961! Just to share some observations:
Based on the above, I would assume StrictMode (refer to link in above comment) in react 18 is what is causing the duplicate message seen. There are some suggested workarounds online so I leave that exploration up to you 😝
Thank you for raising this up and I'll update the documentation to include this piece of information in case others come across the same issue in future.
That said, if you feel I am mistaken and you are still facing the issue even without StrictMode, kindly let me know and I'll try my best to look again 😀
okay, perfect!
thanks for checking it out, you have an amazing product.
when setting chatHistory:{disabled:true} , the first 2 messages are always a duplicate,
i solved it by simply adding the following in ChatBotContainer.tsx line 108 (an empty message if history is disabled ) but i don't think that's a good way to fix it , so if you can find the bug it would be amazing , best of luck!
if (botOptions.chatHistory?.disabled) { localStorage.removeItem(botOptions.chatHistory?.storageKey as string); //added to prevent bug const messageContent = { content: <></>, type: "object", isUser: false, timestamp: null, }; setMessages([messageContent]);