BotFramework-WebChat: LUIS does not work when I integrate bot with webchat.js in any browser

Hello, I created a chatbot in C# with my virtual assistant template and the web chat works fine with the iframe

<iframe src='https://webchat.botframework.com/embed/NAME_OF_BOT?s=YOUR_SECRET_HERE'  style='min-width: 400px; width: 100%; min-height: 500px;'></iframe>

but LUIS doesn’t work when I integrate it with js in any browser

<div id="webchat" role="main"></div>
  <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
  <script>
     window.WebChat.renderWebChat(
        {
           directLine: window.WebChat.createDirectLine({
              secret: 'YOUR_DIRECT_LINE_SECRET'
           }),
        },
        document.getElementById('webchat')
     );
</script>

What can I do for this to work? I already tried to make it work by adding the secrets of webchat and directline.

This is the location of the error it send me:

public class DefaultAdapter : BotFrameworkHttpAdapter`
   {
        public DefaultAdapter(
            BotSettings settings,
            ICredentialProvider credentialProvider,
            IBotTelemetryClient telemetryClient,
            BotStateSet botStateSet)
            : base(credentialProvider)
        {
            OnTurnError = async (turnContext, exception) =>
            {
                await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.Message}"));
                await turnContext.SendActivityAsync(new Activity(type: ActivityTypes.Trace, text: $"{exception.StackTrace}"));
                await turnContext.SendActivityAsync(MainStrings.ERROR);
                telemetryClient.TrackException(exception);
            };`

            Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container)));
            Use(new TelemetryLoggerMiddleware(telemetryClient, logPersonalInformation: true));
            Use(new ShowTypingMiddleware());
            Use(new SetLocaleMiddleware(settings.DefaultLocale ?? "en-us"));
            Use(new EventDebuggerMiddleware());
            Use(new AutoSaveStateMiddleware(botStateSet));
        }
    }

which is in the startup.cs file:

services.AddSingleton<IBotFrameworkHttpAdapter, DefaultAdapter>();

the bot responds to me well when it enters the user data request flow (which does not need LUIS nor QnA) But it sends me the error when I send a message that needs to use LUIS and QnA

(Edited by @compulim for code formatting)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 25 (10 by maintainers)

Most upvoted comments

This also looks like a duplicate of this Stack Overflow question. @guadalupejaime can you try @stevkan’s recommendations and let us know if his answer resolves your issue?

I changed the code to this:

<html>
<body>
<div id = "webchat" role = "main"> </div>
<script src = "https://cdn.botframework.com/botframework-webchat/latest/webchat.js"> </script>
<script>
window.WebChat.renderWebChat (
{
directLine: window.WebChat.createDirectLine ({
file: ''
}),
locale: 'en-US',
},
document.getElementById ('webchat')
);
</script>
</body>
</html>```
to change the language and the bot already work well in webchat.js

Thank you very much everyone, how kind

I’m going to transfer this over to the webchat repo because it doesn’t seem VA specific.