I have the following code but from the Microsoft bot creation tutorial https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-quickstart
When I copy and paste it my using statements don't seem to be being used when they should be in the example? I've tried adding the using statements it suggest but I don't think that is required. I have errors on [BotAuthentication]
and Activity
"Type or namespace name 'Activity' could not be found' etc
I have the nugget packages installed as well.
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System;
using System.Linq;
using System.Configuration;
using Microsoft.Bot.Builder.CognitiveServices.QnAMaker;
using System.Web.Services.Description;
using Microsoft.Bot.Builder.PersonalityChat;
using Microsoft.Bot.Builder.PersonalityChat.Core;
namespace BenTestBot
{
[BotAuthentication]
public class MessagesController : ApiController
{
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.GetActivityType() == ActivityTypes.Message)
{
//await Conversation.SendAsync(activity, () => new Qna_Rich_Cards.Dialogs.QnaDialog().DefaultIfException());
await Conversation.SendAsync(activity, () => new Dialogs.BasicPersonalityChatBotDialog().DefaultIfException());
}
else
{
await HandleSystemMessageAsync(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
If you have already installed the nuget packages then this should not be there. Maybe you should check the version of the packages and try updating the packages.
For [BotAuthentication] and activity to work you need Microsoft.Bot.Connector; that is already there in your case so just try updating.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.