Wolox / react-chat-widget

Awesome chat widget for your React App
MIT License
1.45k stars 458 forks source link

Seed chat history #132

Open Dobby89 opened 4 years ago

Dobby89 commented 4 years ago

Is there a way to Seed/save/rehydrate/keep/preserve the chat history from local storage or a cookie or something?

I'm thinking of a use case where the user is browsing from page to page and the chat history has to be preserved across page reloads so the user isn't presented with a clear chat every time.

fortesl commented 4 years ago

use google firebase

tabrza commented 4 years ago

@Dobby89 - I'm currently trying to do the same with Amazon Lex. Did you manage to figure this out?

Dobby89 commented 4 years ago

@tabrza I ended up making my own chat bot because it had too many custom requirements, so not exactly.

But I did use localstorage to persist certain state properties between page refreshes. For the conversation history I'm using a dynamo DB, but obviously any DB would suffice.

tabrza commented 4 years ago

Got it! Would you feel comfortable sharing the code/repo? As you probably saw, I'm trying to get this working with Amazon Lex - just trying to finish the final step of front-end interaction..

Bonfims commented 4 years ago

we can assume that we already have his backend / database part, so we just need to know how we can fill the chat with previous messages with things (like timestamp).

Bonfims commented 1 year ago

we can assume that we already have his backend / database part, so we just need to know how we can fill the chat with previous messages with things (like timestamp).

From this PR #275 we can active a history by


messages.forEach(({ who, message, messageId, date }) => {
  if(who == 'client')
      addUserMessage(message, messageId, date);
  else
      addResponseMessage(message, messageId, date);
});