Skip to content

Instantly share code, notes, and snippets.

@dhinag
Created May 6, 2019 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhinag/3f9c14237570cc17278e489bcf0c4905 to your computer and use it in GitHub Desktop.
Save dhinag/3f9c14237570cc17278e489bcf0c4905 to your computer and use it in GitHub Desktop.
renderWebchat();
async function renderWebchat()
{
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: { accessToken }
}
});
}
return next(action);
});
await window.WebChat.renderWebChat({
//You must not directly using the Direct line secret. This is just for proof of concept only.
directLine: await window.WebChat.createDirectLine({ token: 'JVGX1eOfFYhBxi-zPpMNk' }), //Direct line secret obtained from the Azure -> Web App Bot -> Channels -> Direct Line -> Secret Key.
userID: 'dhina', //random guid is acceptable
username: 'Web Chat User', //random guid is acceptable
locale: 'en-US',
store
}, document.getElementById('webchat'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment