Skip to content

Commit

Permalink
Auto send "echo-typing" to MockBot
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 13, 2019
1 parent 805b242 commit 57e7b05
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion samples/07.b.customization-send-typing-indicator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,25 @@
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const { token } = await res.json();

// The following code is added for demo purpose only, it will send "echo-typing" to our MockBot when connection is established.
// When "echo-typing" is enabled on MockBot, it will echo back all typing indicator send from the user.
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({ type: 'WEB_CHAT/SEND_MESSAGE', payload: { text: 'echo-typing' } });
}

return next(action);
});

window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token }),

// Web Chat will send typing activity, on behalf of the user, when "sendTyping" is set to true.
// The typing indicator will be send when the send box by any means, including speech.
sendTyping: true
sendTyping: true,

// The following code is added for demo purpose only.
store
}, document.getElementById('webchat'));

document.querySelector('#webchat > *').focus();
Expand Down

0 comments on commit 57e7b05

Please sign in to comment.