react-chat-widget icon indicating copy to clipboard operation
react-chat-widget copied to clipboard

Seed chat history

Open Dobby89 opened this issue 5 years ago • 6 comments

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.

Dobby89 avatar Oct 17 '19 14:10 Dobby89

use google firebase

fortesl avatar Nov 17 '19 04:11 fortesl

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

tabrza avatar Apr 21 '20 07:04 tabrza

@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.

Dobby89 avatar Apr 21 '20 09:04 Dobby89

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..

tabrza avatar Apr 21 '20 14:04 tabrza

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 avatar Sep 18 '20 17:09 Bonfims

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);
});

Bonfims avatar May 28 '23 04:05 Bonfims