BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Sample: Clear chat history after user idle

Open theDavidOlasupo opened this issue 9 years ago • 9 comments

It will be nice to be able to specify a time in which the past messages are clear. Say every 2 minutes or something

theDavidOlasupo avatar Jun 09 '17 10:06 theDavidOlasupo

Can you say more about this scenario? When would this be useful?

billba avatar Jun 12 '17 13:06 billba

@billba, Say am building a banking bot, and I'd like to have transfers and balance requests and basically any transaction history wiped off automatically from the chat probably 5 minutes after the chats. Just for security.

theDavidOlasupo avatar Jun 12 '17 13:06 theDavidOlasupo

I see.

In the near future bots will have the ability to ask WebChat to delete or edit messages. That sounds like a better solution because you can tactically remove or edit sensitive details while retaining the overall history. Make sense?

Meta comment: PLEASE DON'T USE ALL-CAPS WHEN NAMING ISSUES BECAUSE IT LOOKS LIKE YOU'RE YELLING

billba avatar Jun 12 '17 15:06 billba

Thanks Bill. My bad with the caps.

theDavidOlasupo avatar Jun 12 '17 16:06 theDavidOlasupo

@billba How far is MSFT with the solution you mentioned - editing/deleting messages?

jakubbares avatar Apr 05 '18 15:04 jakubbares

@support, if someone has bandwidth, we'd love to get a Sample for this where there's only Clear History (as opposed to restore)

corinagum avatar Nov 28 '18 22:11 corinagum

I currently have a sample for this, but WebChat won't allow me to send new messages once I replace DirectLine and the Store to reset the conversation.

const res = await fetch('http://localhost:3978/directline/token', { method: 'POST' });
const { token } = await res.json();

this.setState(() => ({
    directLine: createDirectLine({ token }),
    createStore(
      {},
      () => next => action => {
        if (action.type === 'WEB_CHAT/SEND_MESSAGE') {
          this.setState({ status: STARTING });
        }
        return next(action);
      })
}));

Seems to be related to issue https://github.com/Microsoft/BotFramework-WebChat/issues/1846.

tdurnford avatar Apr 16 '19 20:04 tdurnford

@tdurnford, Probably because you have to wait for the existing directLine obj to finish disconnecting all the way through.

I would recommend listening for the DIRECT_LINE/DISCONNECT_FULLFILLED event, before dispatching a DIRECT_LINE/CONNECT event.

Try this. This could go in your store activityMiddleware.

import directLineConnect from "botframework-webchat-core/lib/actions/connect";
 if (action.type === "DIRECT_LINE/DISCONNECT_FULFILLED") {
        store.dispatch(
            directLineConnect({
                directLine: createDirectLine({ token }),
                userID: userEmail,
                username: userName,
            })
        );
    }

srimajji avatar Apr 18 '19 20:04 srimajji

This is waiting on #1846 - redux needs to be updated, which is dependant on our bump to react 16.8

corinagum avatar Jul 08 '19 18:07 corinagum