I'm working on a V4 MS Bot framework, I want to build a functionality such as, when user starts typing the question, the bot should populate and give the exact question phrases, so that the user can click on the suggestions given by the bot. Hence the user's effort is reduced and chances of errors is reduced.
So I'm writing a function in client side (using plain JavaScript), which get called on key press.
I used the following code to build that function.
$( "[aria-label='Sendbox']" ).keypress(function() {
if($( "[aria-label='Sendbox']" )[0].defaultValue.length >3){
getquestion(this.value);
}
});
Inside the function i want to create a REST API call and get the questions related to the keyword entered by the user.
function getquestion(value)
{
var params = value;
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/create?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","<key>");
},
type: "GET",
// Request body
//data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function(data) {
alert("error");
});
}
Using this function i can only reach to my Knowledgebase, but unable to narrow to query the questions related to the keywords.
can anyone please help me to achieve my requirement.