1

我正在尝试让我的聊天机器人显示初始欢迎消息,而无需用户先键入以在网络聊天中发起对话。

我找到了使用反向通道的解决方案:这里

但由于 ApiController 类已被弃用,.NET core 2.2因此我无法使用此解决方案。

消息控制器.cs

[BotAuthentication]
public class MessagesController : ApiController

{ 

    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
    {
        . . .
        if (activity.Type == ActivityTypes.Message)
        {
            await Conversation.SendAsync(activity, () => new  Dialogs.RootDialog());
        }
        . . .
        var response = Request.CreateResponse(HttpStatusCode.OK);
        return response;
}

因此,在解决方案中提供的上述示例代码中,当前上下文中不存在“对话”和“请求”。我正在寻找适用于.NET core 2.2.

4

1 回答 1

1

尝试从 ControllerBase 继承并使用 ApiController 声明。

[ApiController]
    public class BotController : ControllerBase
于 2019-07-04T23:17:45.510 回答