protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
//I have code here that works fine.
}
Second Method
public QnABot(IConfiguration configuration, ILogger<QnABot> logger, IHttpClientFactory httpClientFactory)
{
_configuration = configuration;
_logger = logger;
_httpClientFactory = httpClientFactory;
}
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var httpClient = _httpClientFactory.CreateClient();
var qnaMaker = new QnAMaker(new QnAMakerEndpoint
{
KnowledgeBaseId = _configuration["QnAKnowledgebaseId"],
EndpointKey = _configuration["QnAAuthKey"],
Host = GetHostname()
},
null,
httpClient);
_logger.LogInformation("Calling QnA Maker");
// The actual call to the QnA Maker service.
var response = await qnaMaker.GetAnswersAsync(turnContext);
if (response != null && response.Length > 0)
{
await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
}
else
{
await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
}
}
Error: 'Type QnABot' already defines a member called 'OnMessageActivityAsync' with the same parameter types.
I have used a third party API with my bot using the HTTP Client. Now, I want to add the QnA maker to my bot. The thing is i only want the user to use the API when they need to and the QnA maker for a different reason. Basically, the QnA maker has the information for specific apps that we use at my company. The API knowledge base however answers natural language questions like ‘How do I install outlook on my iPhone?’ So this is the matter for the user being able to choose if they want specific app information from the QnA maker or ask a ‘how to’ question from the API.
I already made a QnA bot as well. I have the code for the QnA maker and now I was trying to implement both my web api code and the qna maker code together. I have used my logic from the API to use it with my QnAbot.cs file but I am getting this OnMessageActivityAsync error. Obviously because I have two of those and the program doesn’t know when to access which method. So how do I set both these methods apart?
Getting "OnMessageActivityAsync" error as I have two of those methods and I don't know how to differentiate between the two. I need the bot to be able to query either the API or the QnA maker, not together.This is my first OnMessageActivityAsync second on messageactivity which gives me an error