.NET Core 2.2-如何使用反向通道在用户在 Webchat 中键入之前显示 bot 欢迎消息
.NET Core 2.2-How to use backchannel to display bot welcome message before user types in Webchat
我正在尝试让我的聊天机器人显示初始欢迎消息,而无需用户先键入以在网络聊天中发起对话。
我找到了这个使用反向通道的解决方案:
但由于 ApiController class 在 .NET core 2.2
中已弃用,我无法使用此解决方案。
MessagesController.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;
}
因此,在解决方案中提供的上述示例代码中,'Conversation'和'Request'在当前上下文中不存在。
我正在寻找适用于 .NET core 2.2
.
的上述解决方案的版本
尝试从 ControllerBase 继承并使用 ApiController 声明。
[ApiController]
public class BotController : ControllerBase
我正在尝试让我的聊天机器人显示初始欢迎消息,而无需用户先键入以在网络聊天中发起对话。
我找到了这个使用反向通道的解决方案:
但由于 ApiController class 在 .NET core 2.2
中已弃用,我无法使用此解决方案。
MessagesController.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;
}
因此,在解决方案中提供的上述示例代码中,'Conversation'和'Request'在当前上下文中不存在。
我正在寻找适用于 .NET core 2.2
.
尝试从 ControllerBase 继承并使用 ApiController 声明。
[ApiController]
public class BotController : ControllerBase