最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

webchat.js -> direct line API--> copilot studio, reset the chat bot messages - Stack Overflow

programmeradmin0浏览0评论

I am using custom UI webchat.js -->directline API--> Microsoft copilot studio.

I want to implement a reset function, which will reset the chat bot and remove the previous messages from the chat box.

in backend, the conversation is getting reset, but in the UI, the old chat messages are still there.

is there a way to clear that ?

Tried the below and still not clearing it chat bot in the UI

store.dispatch({ type: 'WEB_CHAT/CLEAR_MESSAGES' });

Any help highly appreciated.

Similar context- Is it possible to populate the input bar in webchat with an onclick method

I am using custom UI webchat.js -->directline API--> Microsoft copilot studio.

I want to implement a reset function, which will reset the chat bot and remove the previous messages from the chat box.

in backend, the conversation is getting reset, but in the UI, the old chat messages are still there.

is there a way to clear that ?

Tried the below and still not clearing it chat bot in the UI

store.dispatch({ type: 'WEB_CHAT/CLEAR_MESSAGES' });

Any help highly appreciated.

Similar context- Is it possible to populate the input bar in webchat with an onclick method

Share asked Mar 5 at 17:56 AnilalAnilal 335 bronze badges 1
  • Accepting / upvoting an answer serves the greater Stack Overflow community and anyone with a similar question. If you feel my answer was sufficient, please "accept" and upvote it. If not, let me know how else I can help! – Steven Kanberg Commented Mar 6 at 0:49
Add a comment  | 

1 Answer 1

Reset to default 1

Activities passed thru Web Chat's store are stored in an array. You can clear the store by assigning the activities property an empty array. Obviously, how or at what point you want to do this is up to you. Below is a simple example demonstrating one possible way.

const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
  if ( action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' ) {
    const activity = action.payload?.activity;

    if (activity.type === 'message' && activity.text === 'clear') {
      store.getState().activities = []
    }
  next( action );
} );

When 'clear' is typed into the send box the transcript window is cleared of any messages displayed up to that point.

发布评论

评论列表(0)

  1. 暂无评论