3
votes

I am new to C# and the Bot Framework (V3) and have been asked to begin testing an existing bot on a project I have joined. The bot itself works fine on the Bot Emulator and when hosted on Skype, but for some reason the web chat on Azure does not work. As the web chat uses the Direct Line, it kind of puts a halt to running tests for now. I have spent a lot of time scouring the V3 Github page and here on SO but I've not been able to find a solution.

The conversation seems to initiate OK to begin, as the Bot sends the user a message but all user responses don't get sent and the Bot responds with the error message 'Sorry, my bot code is having an issue'. See -

Bot error message

Azure lists it as a 500 error - internal server error. see

Error messages in Azure

Error messages in Azure

I then looked at the messages in the Chrome Dev Tools tab and get the same error as well as a 502 error and, more recently (or I never noticed it before), a CORS error as well. See

Chrome Dev Tools console

Chrome Dev Tools console

After this I used Application Insights on Azure and for each instance when I tried to use the Web Chat there would be three items;

  • A customEvent (StatusCode: 200), presumably for the message the Bot sends at the beginning of the conversation.
  • An exception with a problemId "System.Exception at Microsoft.Bot.ChannelConnector.BotAPI+d__31.MoveNext"
  • Another customEvent (StatusCode : 500)

As I'm not very familiar with the whole set-up between C# and the Bot Framework I'm not really sure where the issue lies. Here's some screenshot of what the exception message looks like -

Messages of single operationId

Messages for single operationId

Exception details (1)

Exception details (1)

Exception details (2)

Exception details (2)

Exception details (3)

Exception details (3)

Exception details (4)

Exception details (4)

I had some thoughts on these messages:

  1. The 'Outer assembly' is described as 'Microsoft.Bot.ChannelConnector, Version=3.2.2.5, Culture=neutral, PublicKeyToken=null' - does the lack of a PublicKeyToken mean that the user isn't getting assigned a token because of the error? Or should this be happening first and the error occurring because the user has no token?
  2. The stack trace is pointing at a line in one of the dialog files but from looking at the code, I can't really see what the issue is? I actually removed the section that was being flagged but it simply changed the line in the code where the issue was to the preceding section so I'm not really sure that there is an issue with this file at all?

If anyone has any thoughts on this and what the cause of the issue might be I would really appreciate it.

Additionally, here's two things I've tried to do to fix this that haven't made any difference;

  • Ensured that when publishing the profile to Azure to tick the box to 'Delete all
  • Made sure all packages were up to date (including installing the bot.connector.directline package, which wasn't already there for some reason)
1
Are you using a deployment slot for testing? Also, what is the bot using to manage state (table storage, CosmosDb, etc.)?Steven Kanberg
Ok, thanks for that info. It’s all pieces to the puzzle. New question: I see WebChat errors (including the CORS error) referencing a “testboteurope” resource. However, the Application Insights data references a “TestSlotNetHope” resource. Are you trying to access one resource from the other?Steven Kanberg
Ok, there are a few things I would also suggest you look into. One, check that your bots aren't using State Service for state management. I'm seeing State Store calls to this service, however it was deprecated several months ago. You can read more about State Service and alternative options here: blog.botframework.com/2018/04/02/…Steven Kanberg
Also, you mention having the bots in separate deployment slots using different app services. There is a good chance this is the cause of the CORS issue. The host web chat URI should be added as a Trusted Origin in the Direct Line channel for the bot, in question. Navigate to the bot, click the Channels blade and select Direct Line. Scroll to the bottom of that page and, under "Enhanced authentication options", add the URI and click done.Steven Kanberg
Lastly, there were some issues with Direct Line at the North Europe data center. The errors were over several hours and coincide with your bot's connection troubles.Steven Kanberg

1 Answers

0
votes

So the resolution to my problem was as per Steven Kanberg's suggestions in the comments above. While our state management had been using the deprecated version (which is now updated), it was a CORS issue caused by the bots being in different deployment slots to the app services. Once the URIs of the app services were added as Trusted Origins the problem was solved. Thanks to Steven Kanberg for all the help.