2016-12-05 5 views
2

Ich habe diesen Bot, der ziemlich kompliziert ist, aber es funktioniert lokal. Aber sobald ich es veröffentlichen, schlägt es mit dem Fehler:Microsoft Bot Framework funktioniert lokal, aber fehlschlägt remote

Sorry, my bot code is having an issue.

Ich habe versucht, Praktische Anwendung verwenden, aber es ist nicht die Fehlerdetails zeigt. Der Fehler tritt immer an der gleichen Stelle:

/// <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 
    context.Wait(AskQuestion); 
} 

/// <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 
    _currentQuestion++; 

    // 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); 
     return; 
    } 

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

Also, wenn dieser Dialog beginnt, ist es die Frage Einführung in die Client postet. Ich dann aufrufen context.Wait und stellen Sie die Frage. Die Frage ist eine Wahl. Ich glaube, dass dies der Punkt ist, an dem das Problem besteht, weil es immer diese Nachricht ausgibt, sobald die Frage erscheint.

Kann jemand etwas etwas offensichtlich mit dem Code erkennen?

+0

Welche Version des BotBuilders läuft? –

Antwort

0

Die Fehlermeldung, die Sie genannt haben, wird gegeben, wenn Ihr Bot eine 500 wirft. Wenn ich Ihren Code betrachte, bin ich der Meinung, dass Sie eine Nullref-Ausnahme haben. Überprüfen Sie im Abschnitt unter "// Fragen und Antworten erhalten", ob group.Questions nicht null ist und dass _currentQuestion ein gültiger Index für dieses Array ist.

Verwandte Themen