src/website/iframeparent.html [110:141]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // perform actions on the parent dependent on the chatbot // loading. For example, enable the send button once the // chatbot UI is loaded $('#send-intent').prop('disabled', false); }) .catch(function (error) { console.error('chatbot UI failed to load', error); }); // Sample function illustrating dynamic messaging with the iframe using // the API. This function is called from the event handler of the "Send" // button. function sendUtterance(utterance) { // function to determine if the iframe is minimized function isBotMinimized() { // look at the options of the loader to determine the iframe // element ID var elementId = iframeLoader.options.elementId; // this class is present in the iframe when minimized var minimizedClass = 'lex-web-ui-iframe--minimize'; return $('#' + elementId).hasClass(minimizedClass); } return Promise.resolve() .then(function () { // use the toggleMinimizeUi API if the iframe is minimized return !isBotMinimized() || iframeLoader.api.toggleMinimizeUi(); }) .then(function () { return iframeLoader.api.postText(utterance); }) .then(function () { console.log('message succesfully sent'); }) .catch(function (err) { console.error('error sending message ', err); }); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - src/website/parent.html [198:233]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // perform actions on the parent dependent on the chatbot // loading. For example, enable the send button once the // chatbot UI is loaded $('#send-intent').prop('disabled', false); }) .catch(function (error) { console.error('chatbot UI failed to load', error); }); // Sample function illustrating dynamic messaging with the iframe using // the API. This function is called from the event handler of the "Send" // button. function sendUtterance(utterance) { // function to determine if the iframe is minimized function isBotMinimized() { // look at the options of the loader to determine the iframe // element ID var elementId = iframeLoader.options.elementId; // this class is present in the iframe when minimized var minimizedClass = 'lex-web-ui-iframe--minimize'; return $('#' + elementId).hasClass(minimizedClass); } return Promise.resolve() .then(function () { // use the toggleMinimizeUi API if the iframe is minimized return !isBotMinimized() || iframeLoader.api.toggleMinimizeUi(); }) .then(function () { return iframeLoader.api.postText(utterance); }) .then(function () { console.log('message succesfully sent'); }) .catch(function (err) { console.error('error sending message ', err); }); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -