1
votes

Using:

  • SDK Language: C#
  • SDK Version: 4.1.5
  • Enviroment: Localhost, Azure
  • Channel: webchat

Issue Description

When testing the bot in Bot Framework Emulator V4, it does work as expected as it can be seen in the next figure:

Figure 1: Bot working on emulator

After Deploying it in Azure following this instructions, bot stops working (neither sending or receiving messages) and got this alerts in the webchat channel section:

Figure 2: Alerts at the channel section

I've found these similar issues:

https://github.com/Microsoft/BotFramework-Emulator/issues/296

https://github.com/Microsoft/BotBuilder/issues/3329

But in my case both AppId and Password are defined and the other solution simply doesn't work at all. I even managed to find the error codes on the azure platform, but I was unable to find the details or get where the error is coming from...

Figure 3: AppInsights Error panel

Code Overview

public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
    {
        bool reintentar = false;
        //tried this but didn't work
        //MicrosoftAppCredentials.TrustServiceUrl("http://botrps.azurewebsites.net");         

        //obtener el contexto de los dialogos
        var dc = await _dialogs.CreateContextAsync(turnContext, cancellationToken);

        if (turnContext.Activity.Type == ActivityTypes.Message && turnContext.Activity.From.Id != turnContext.Activity.Recipient.Id)
        {
            //bot operations on users messages
        }    

        //if active dialog
        await dc.ContinueDialogAsync(cancellationToken);

        //else, start greeting dialog
        if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate &&
            turnContext.Activity.MembersAdded[0].Id != turnContext.Activity.Recipient.Id)
        {
            await dc.BeginDialogAsync("dialogo", null, cancellationToken);
        }

        await _accessors.ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);

        // Guarda los cambios realizados en el Contexto, si hay alguno
        await _accessors.UserState.SaveChangesAsync(turnContext, false, cancellationToken);
    }
1
Have you added a production endpoint to your bot file? - tdurnford
Does clicking on the "count" of the invalidOperationException in the log (application insights?) show you any kind of stack trace? - UpQuark
Thx for the answers. After adding production endpoint the bot seems to work fine, both in webchat and Skype. By the way, I realised it's working whitout the "abs" service. It's also necessary to specify it? - Julen
No, it is not necessary to specify the 'abs' service as the production endpoint points to it. Glad I could help. - tdurnford

1 Answers

0
votes

As said by tdurnford in the comment section, it was necessary to add to the .bot configuration the production enpoint service. The resulting bot file:

{
  "name": "BotMod2",
  "services": [
    {
      "type": "endpoint",
      "name": "development",
      "endpoint": "http://localhost:3978/api/messages",
      "appId": "",
      "appPassword": "",
      "id": "1"
    },
    {
      "appId": "**********************",
      "appPassword": "**********************",
      "endpoint": "https://**********************.azurewebsites.net/api/messages",
      "type": "endpoint",
      "name": "production",
      "id": "2"
    },
    {
      "appId": "**********************",
      "authoringKey": "**********************",
      "version": "0.1",
      "region": "westus",
      "type": "luis",
      "name": "**********************",
      "id": "3"
    },
    {
      "type": "qna",
      "name": "**********************",
      "kbId": "**********************",
      "hostname": "https://**********************.azurewebsites.net/qnamaker",
      "endpointKey": "**********************",
      "subscriptionKey": "**********************",
      "id": "4"
    }
  ],
  "padlock": "",
  "version": "2.0"
}