Пример #1
0
        private void CheckAllResponseRenderings(ProcessingResult result, IReadOnlyList <string> expectedRenderings)
        {
            for (var i = 0; i < expectedRenderings.Count; i++)
            {
                var textNumber   = i;
                var jsonResponse = AliceResponseRendererHelper.CreateAliceResponse(result, sessionExample, x => textNumber);

                var response = jsonResponse.Response;
                _output.WriteLine($"Text: {response.Text}\n" +
                                  $"Tts: {response.Tts}\n" +
                                  $"Buttons: {response.Buttons.Length}\n" +
                                  $"EndSession: {response.EndSession}\n");

                var session = jsonResponse.Session;
                Assert.Equal(sessionExample.UserId, session.UserId);
                Assert.Equal(sessionExample.MessageId, session.MessageId);
                Assert.Equal(sessionExample.SessionId, session.SessionId);

                Assert.Equal(expectedRenderings[textNumber], response.Text);
            }
        }
Пример #2
0
        public ActionResult <AliceResponse> Post([FromBody] AliceRequest request)
        {
            return(_tracingProvider.TryTrace(
                       "Alice::Post",
                       scope =>
            {
                var answer = _inventoryDialogService.ProcessInput(request.Session.UserId, request.ToUserInput());

                if (answer.Type == Logic.ProcessingResultType.Error || answer.Type == Logic.ProcessingResultType.Exception)
                {
                    scope?.Log($"error message:\"{answer.Error?.Message}\", "
                               + $"exception message:\"{answer.Exception?.Message}\", "
                               + $"type: \"{request.Request.Type}\", "
                               + $"payload: \"{request.Request.Payload}\", "
                               + $"command: \"{request.Request.Command}\", "
                               + $"original: \"{request.Request.OriginalUtterance}\"");
                }

                var response = AliceResponseRendererHelper.CreateAliceResponse(answer, request.Session, x => Random.Next(0, x));
                return response;
            }));
        }