我创建了一个单租户 Azure Bot 并设置端点以连接 AppService。当它使用网络聊天进行测试时,似乎调用没有从机器人控制器转移到 dialog.cs。日志中也没有错误。但是多租户机器人在使用相同的代码时运行良好。单租户有什么可做的吗?请指教。
using Microsoft.AspNetCore.Mvc;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Integration.AspNet.Core;
namespace botservices.controllers
{
[Route("api/messages")]
[ApiController]
public class BotController : ControllerBase
{
private readonly IBotFrameworkHttpAdapter _adapter;
private readonly IBot _bot;
protected CustomLog _customLogs;
public BotController(IBotFrameworkHttpAdapter adapter, IBot bot, IBotTelemetryClient telemetryClient)
{
_adapter = adapter;
_bot = bot;
_customLogs = new CustomLog(telemetryClient);
}
[HttpPost]
public async Task PostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot.
await _adapter.ProcessAsync(Request, Response, _bot);
_customLogs.log(Response.StatusCode.ToString(), "Bot Error");
}
}
}
Bot.cs 是
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Schema;
namespace botservices.bot
{
public class Bot<T> : RootBot<T> where T : Dialog
{
protected readonly ConversationState _conversationStates;
protected readonly Dialog _dialogs;
protected CustomLog _customLogs;
public Bot(ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, T dialog) : base(conversationState, userState, telemetryClient, dialog)
{
_conversationStates = conversationState;
_dialogs = dialog;
_customLogs = new CustomLog(telemetryClient);
}
protected override async Task OnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
await _dialogs.RunAsync(turnContext, _conversationStates.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
_customLogs.log("OnMembersAddedAsync ended", "Bot Events");
}
protected override async Task OnTokenResponseEventAsync(ITurnContext<IEventActivity> turnContext, CancellationToken cancellationToken)
{
await _dialogs.RunAsync(turnContext, _conversationStates.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
_customLogs.log("OnTokenResponseEventAsync ended", "Bot Events");
}
}
}