0

I'm trying to save the JSON content in the answer.

For example, the QnA pair is like

  • Question: where is the repair center.
  • Answer: { "text" : "the repair center locates ...", "next": "would you like to know the phone number of the repair center" }

My chatbot will do some particular things when receiving this kind of answer from QnA service.

dynamic answser = JObject.parse(qnaResponse.answer);
if (answer.next == string.Empty){
   //End conversation
}else{
   await context.PostAsync(answer.next);
}

But I always got the gibberish string in response answer that I can't parse to JSON object and do rest of conversations.

{ "text":" the repair center locates ... " ,"next": "would you like to know the phone number of the repair center" }

Is it possible that stores JSON content as an answer? Or did I miss something?

Andy Lai
  • 1,714
  • 1
  • 14
  • 17
  • Can you add more details about how you are querying QnAMaker please? The string you are quoting is not gibberish, just Url encoded value.. – Nicolas R Mar 02 '18 at 15:02
  • I created a [sample + blog post](https://blog.botframework.com/2017/08/25/qna-maker-rich-card-attachments-net/) which include an example storing a QnA answer as JSON however it is in .NET, hopefully it'll provide you with enough hints. Otherwise it looks like you just need to sanitize your response in the bot code before you use it – Matthew S Mar 09 '18 at 00:02

0 Answers0