Sample: Clear chat history after user idle
It will be nice to be able to specify a time in which the past messages are clear. Say every 2 minutes or something
Can you say more about this scenario? When would this be useful?
@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.
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
Thanks Bill. My bad with the caps.
@billba How far is MSFT with the solution you mentioned - editing/deleting messages?
@support, if someone has bandwidth, we'd love to get a Sample for this where there's only Clear History (as opposed to restore)
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, 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,
})
);
}
This is waiting on #1846 - redux needs to be updated, which is dependant on our bump to react 16.8