I'm using QNA maker in my chatbot project using Bot Framework and I want to take the question from the adaptive card and send it to the QNA maker but I'm getting an error says: Argument 1: cannot convert from 'string' to 'Microsoft.Bot.Builder.ITurnContext'
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default)
{
var value = turnContext.Activity.Value;
if (value != null)
{
var val = value.ToString();
var relationsJSON = JToken.Parse(val);
var text = relationsJSON["text"].ToString();
if (text == "car model")
{
var result = await QnAMaker.GetAnswersAsync(text);
await turnContext.SendActivityAsync(result[0].Answer, cancellationToken: cancellationToken);
}
}
}
the error message on: var result = await QnAMaker.GetAnswerAsnyc(text);
The
QnAMaker.GetAnswerAsnycmethod is always expecting theITurnContextas a mandatory parameter. So you can't inject any other parameter in the respective method.So try the below code here JSON text is assigned to
turnContext.Activity.Textobject. Because as per your codeOnTurnAsyncmethod is always validatingturnContext.Activity.Valueobject.