Skip to content

Instantly share code, notes, and snippets.

@anuraj
Created June 5, 2020 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuraj/41c8a6428fa7e2ce189cb69ae902e42d to your computer and use it in GitHub Desktop.
Save anuraj/41c8a6428fa7e2ce189cb69ae902e42d to your computer and use it in GitHub Desktop.
QnA Maker Zoom Integration code.
var kbServiceUrl = "https://appservice.azurewebsites.net/qnamaker/knowledgebases/id/generateAnswer";
var kbAuthKey = "authkey";
var answer = string.Empty;
using (var httpClient = httpClientFactory.CreateClient())
{
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("EndpointKey", kbAuthKey);
var question = new JObject();
question["question"] = cmd;
var questionContent = new StringContent(question.ToString(), Encoding.UTF8, "application/json");
var questionResponse = await httpClient.PostAsync(kbServiceUrl, questionContent);
var answers = await questionResponse.Content.ReadAsStringAsync();
var answersObject = JObject.Parse(answers);
answer = answersObject["answers"][0]["answer"].Value<string>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment