ошибка в ответе dialog.elicitslot () - PullRequest
0 голосов
/ 07 июня 2018

Я пытаюсь сделать простую игру-викторину для Alexa, в которой пользователь представлен двумя событиями и пытается угадать, наступило ли первое второе событие до или после второго события.

игре требуется слотназывается «ответ» для заполнения.Моя проблема в том, что мой метод DialogElicitSlot () вызывает ошибку, и Alexa не может прочитать ответ.

Любая помощь приветствуется, и если у кого-то есть рабочий пример (с использованием C #) чего-то подобного, чтотакже было бы здорово:)

[assembly: 
LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]

namespace Timeline
{
 public class Function
 {

    /// <summary>       
    /// </summary>
    /// <param name="input"></param>
    /// <param name="context"></param>
    /// <returns></returns>
    private SkillResponse MakeResponse(string outputSpeech, bool shouldEndSession, string repromptSpeech)
    {
        var response = new ResponseBody
        {
            ShouldEndSession = shouldEndSession,
            OutputSpeech = new PlainTextOutputSpeech { Text = outputSpeech }
        };

        var skillResponse = new SkillResponse
        {
            Response = response,
            Version = "1.0"
        };

        return skillResponse;
    }

    public IOutputSpeech GetOutputSpeech(string response)
    {
        return new PlainTextOutputSpeech()
        {
            Text = response
        };
    }



    public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
    {
        var requestType = input.GetRequestType();
        if (requestType == typeof(IntentRequest))
        {

            var intentRequest = input.Request as IntentRequest;

            if (intentRequest != null)
            {

                switch (intentRequest.Intent.Name)
                {
                    case "nextEvent":
                        {
                            string lastEventName = QuestionController.getPreviousEventName();
                            DateTime lastEventDate = QuestionController.getPreviousEventDate();

                            string nextEventName = QuestionController.getNextEventName();
                            DateTime nextEventDate = QuestionController.getNextEventDate();

                            if (intentRequest.DialogState == DialogState.Started)
                            {
                                return ResponseBuilder.DialogElicitSlot(GetOutputSpeech($"did the {lastEventName} happen before, or after {nextEventName} ?"), intentRequest.Intent.Slots["answer"].Name, intentRequest.Intent);

                            }
                            else if (intentRequest.DialogState != DialogState.Completed)
                            {
                                return ResponseBuilder.DialogElicitSlot(GetOutputSpeech($"did the {lastEventName} happen before, or after {nextEventName} ?"), intentRequest.Intent.Slots["answer"].Name, intentRequest.Intent);
                            }
                            else
                            {
                                var questionEvaluation = intentRequest.Intent.Slots["answer"].Value;

                                if (QuestionController.evaluateAnswer() == true)
                                {
                                    return MakeResponse($"That is correct! The {nextEventName} was {questionEvaluation} the {lastEventName}. The {nextEventName} was in {nextEventDate} while the {lastEventName} was in {lastEventDate}", true, "");
                                }
                                else
                                {
                                    return MakeResponse($"That is wrong! The {nextEventName} was not {questionEvaluation} the {lastEventName}. The {nextEventName} was in {nextEventDate} while the {lastEventName} was in {lastEventDate}", true, "");
                                }

                            }
                        }
                    default:
                        return MakeResponse("hmm. i dont think i understand what you are asking of me", false, "");
                }
            }
            return MakeResponse("",false,"");

        }
        else
        {
            return MakeResponse("Welcome", false, "");

        }
    }
}
}

`

Ответ, который я получаю, когда проверяю свой навык:

{
"body": {
    "version": "1.0",
    "response": {
        "outputSpeech": {
            "type": "PlainText",
            "text": "did the previous event happen before, or after next event ?"
        },
        "directives": [
            {
                "type": "Dialog.ElicitSlot",
                "updatedIntent": {
                    "name": "nextEvent",
                    "confirmationStatus": "NONE",
                    "slots": {
                        "answer": {
                            "name": "answer",
                            "confirmationStatus": "NONE"
                        }
                    }
                },
                "slotToElicit": "answer"
            }
        ],
        "shouldEndSession": false
    }
}

}

Кроме того - если бы кто-нибудь мог сказать мне, как я могу сделать слот необходимым значением из кода, я был бы благодарен.

...