question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LUIS does not work when I integrate bot with webchat.js in any browser

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
tdurnfordcommented, Aug 8, 2019

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?

1reaction
guadalupejaimecommented, Aug 11, 2019

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

LUIS does not work when I integrate bot framework v4 with js ...
This is the current implementation for including BotFramework-WebChat in an html page, if not using an iframe. The page shouldn't block your ...
Read more >
Add natural language understanding to your bot - Bot Service
Learn how to use LUIS for natural language understanding in your bot.
Read more >
Embed a bot in a web page using Web Chat - Bot Framework
This post describes how to embed a bot in a web page using the Bot Framework Web Chat. The Web Chat control is...
Read more >
Microsoft/BotBuilder - Gitter
<iframe src='https://webchat.botframework.com/embed/NAME_OF_BOT?s=YOUR_SECRET_HERE' ... but LUIS doesn't work when I integrate it with js in any browser.
Read more >
Integrating Microsoft LUIS into the Bot Framework - Atmosera
To integrate our LUIS app into our bot we just have to update the app keys that our bot is using. In our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found