private async Task <IActionResult> ContinueConversation(string answer, string conversationId, string userId) { await _mapContext.LoadFromChacheAsync(conversationId); if (_mapContext.HasNext()) { var questions = new List <string>(); ContinueResult result; do { result = await _mapContext.ContinueAsync(answer, conversationId); if (result != null) { questions.Add(result.Question); } } while (result?.IsQuestion == false); return(Ok(new MessageResponse(true, string.Join(',', questions), true, new { end = false, conversationId, userId }))); //return Ok(new { success = true, message = result.Question, data = new { result.IsQuestion, end = false, conversationId, userId } }); } var values = await _mapContext.GetStateAsync(conversationId); await _mapContext.DestroyAsync(conversationId); return(Ok(new MessageResponse(true, "ok", true, new { end = true, conversationId, userId, values }))); //return Ok(new { success = true, message = JsonConvert.SerializeObject(values), data = }); }
public async Task <IActionResult> Map(string answer, [FromHeader(Name = "x-yc-conversationId")] string conversationId) { await _knowledgeMap.StartAsync("travel_application_test", conversationId); if (_knowledgeMap.HasNext()) { var step = await _knowledgeMap.ContinueAsync(answer, conversationId); return(Ok(new { _knowledgeMap.Next, step.Question })); } var state = await _knowledgeMap.GetStateAsync(conversationId); await _knowledgeMap.DestroyAsync(conversationId); return(Ok(state)); }