Skip to content

Commit

Permalink
Auto send "echo-typing" on connect
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Jan 13, 2019
1 parent 77ed1e1 commit cd829f5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions 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.
// Web Chat will send typing activity, on behalf of the user, when "sendTypingIndicator" is set to true.
// The typing indicator will be send when the send box by any means, including speech.
sendTyping: true
sendTypingIndicator: true,

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

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

0 comments on commit cd829f5

Please sign in to comment.