c# - Microsoft Bot Framework works locally, but fails remotely


I have this bot that is fairly complicated, but it works locally. But as soon as I publish it, it fails with the error:

Sorry, my bot code is having an issue.

I have tried using Application Insights, but it isn't showing the error details. The error always happens at the same point:

/// <summary>
/// Start our response
/// </summary>
/// <param name="context">The current context</param>
/// <returns></returns>
public async Task StartAsync(IDialogContext context)

    // Get our current step
    _groups = await _groupProvider.ListAsync();
    _group = _groups.First();

    // Post the question header
    await context.PostAsync(_group.Text);

    // Wait for the users response

/// <summary>
/// When our message is recieved we execute this delegate
/// </summary>
/// <param name="context">The current context</param>
/// <param name="result">The result object</param>
/// <returns></returns>
private async Task AskQuestion(IDialogContext context, IAwaitable<IMessageActivity> result)

    // Get our question and answers
    var question = this._group.Questions[_currentQuestion];
    var questionText = question.Text;
    var answers = question.Answers.Select(m => m.Text).ToList();
    var answerCount = question.Answers.Count;

    // Create our options
    var options = new PromptOptions<string>(questionText, options: answers);

    // Ask our question
    Choice<string>(context, GetAnswer, options);

/// <summary>
/// Get our answer and decide what to do next
/// </summary>
/// <param name="context">The current context</param>
/// <param name="result">The answer text</param>
/// <returns></returns>
private async Task GetAnswer(IDialogContext context, IAwaitable<string> result)

    // Get our quest
    var questions = _group.Questions;
    var length = questions.Count;
    var question = _group.Questions[_currentQuestion];
    var selectedAnswer = await result;

    // Assign our answer to our question
    foreach (var answer in question.Answers)
        if (answer.Text == selectedAnswer)
            question.Answer = answer;

    // If we have an answer, filter the products
    if (question.Answer != null)
        _productProvider.Score(await GetCurrentProducts(), _groups);

    // Increase our index

    // If our current index is greater or equal than the length of the questions
    if (_currentQuestion == length)

        // Create our dialog
        var dialog = _dialogFactory.CreateSecondStepDialog(_dialogFactory, _groupProvider, _questionProvider, _productProvider, await GetCurrentProducts());

        // Otherwise, got to the next step
        await context.Forward(dialog, ResumeAfter, new Activity { }, CancellationToken.None);

    // Ask our next question
    await AskQuestion(context, null);

So when this dialog starts, it posts the question introduction to the client. I then invoke context.Wait and ask the question. The question is a choice. I believe that this is where the issue is, because it always throws that message as soon as the question appears.

Can anyone spot anything glaringly obvious with the code?

1 Answer: 

The error message you have cited, is given when your bot throws a 500. Looking at your code, my guess is that you have a null ref exception. In the section under "// Get our question and answers", try checking that group.Questions isn't null and that _currentQuestion is a valid index into that array.


More Articles

templates - symfony - Call an action from view?

I know it's not good to try to do this, but i would like to call an action in my view/template on symfony framework.Is it possible ? I don't find anything about this on the web.Thanks you, and sorry for my bad english!!

botframework - Few question about Microsoft Teams using bot

It is possible to force a bot to join (and listen) all teams, meetings, chats conversation in my tenant without being invited or beginning the conversation?When a member was added to a team, my bot received a "conversationUpdate" message with the member that was added in the "memberAdded" field. I w

How To Get Alexa Ranking In Java

I tried to use Java and DOM XML parser to get the Alexa ranking from below :http://data.alexa.com/data?cli=10&url=domainNameIs there any API for Alexa ranking and other useful for particular URL ?

Magento EBS payment gateway - upon redirection shows 404 page

I have developed a store and using EBS payment gateway for netbanking. It was working fine but suddenly it started showing a 404 page not found error upon redirection. After clicking confirm order the customer is never directed to the EBS page but remains on the site with the page not found message!

facebook - Unable to publish an action

I'm attempting to create a Facebook Open Graph App similar to the Washington Post Social Reader, which will announce in a person's news feed when they read an article on my website, www.zeitlife.co.uk.I have followed the Open Graph tutorial closely, identifying an action and an object, and creating

java - How to integrate KNET payment gateway with php

How can I integrate the KNET payment gateway with PHP? The gateway id only works with Java and .NET.

android - Google Actions does not work from OK Google. my app is not recognised

I have downloaded this basic example from google: https://github.com/actions-on-google/appactions-fitness-kotlinNow if I do: adb shell am start -a android.intent.action.VIEW -d "https://fit-actions.firebaseapp.com/start"It will start my app. And the deeplink is being recognized.The example shows tha

payflowpro - How to use paypal payflow api to charge sale in canadian dollars

I have a custom application that is integrated with the paypal payflow API. We are expanding to Canada and would like to charge in the Canadian dollar for our Canadian customers but it keeps defaulting to the US Dollar.I'm trying to pass 'CURRENCY'=> 'CAD' in the REST call via curl. I can't find a

botframework - Ms Teams Bot Icon is not displayed

I've used app studio from MS Teams to creat a manifest for a Bot App. I've uploaded the full color picture as well as trasparent outlone. However the icon is not displaying at the chat window. Only the default icon is visivle. Any ideas, how can I solve the issue? Thanks a lot!

react native - Cannot read property 'reload' of null using firebase.auth().currentUser.reload()

I need to reload current user to update emailVerfied status. However At first login or signup of user. The app return an error that Cannot read property 'reload' of null when A user press triggers firebase.auth().currentUser.reload(). However If I refresh the reload the app the reload function wor