Search code examples
botframeworkbotsmicrosoft-edgedirect-line-botframeworkweb-chat

Invalid attempt to destructure non-iterable instance - Bot 4.0 WebChat.js


[object Error]: {message: "Invalid attempt to destructure non-iterable instance", stack: "TypeError: Invalid attempt to destructure non-iterable instance at e.exports (https://cdn.botframework.com/botframework-webchat/latest/webchat.js:1:566613) at e.exports at t.unstable_runWithPriority (https://cdn.botframework.com/botframework-webchat/latest/webchat.js:1:351563) at Rs (https://cdn.botframework.com/botframework-webchat/latest/webchat.js:1:339772) at Ps (https://cdn.botframework.com/botframework-webchat/latest/webchat.js:1:339567)"}

 (async function () {
        const res = await fetch('https://tokenservice/api/DLToken', { method: 'POST' });        
        const {token}  = await res.json();
        console.log({token});
        window.WebChat.renderWebChat(
            {
                bot: bot,
                directLine: window.WebChat.createDirectLine({token}),
                user: user,
                speechOptions: speechOptions,
                resize: 'detect',
                styleOptions: styleOptions
            },
            document.getElementById('BotChatGoesHere')
        );

I am getting this error in Edge and IE, in Chrome it works fine. Please suggest solution, will be obliged.


Solution

  • IE 11 doesn't support async/await keyword. We need to use es5 bundle in IE. Please try to use https://cdn.botframework.com/botframework-webchat/latest/webchat-es5.js instead.

    Reference:

    Latest WebChat : IE11 Compatibility

    Sample - Getting Started with Web Chat CDN with ES5 Polyfills