用户每次都必须登录?

Users have to sign in every time?

现在,我们的用户每次想与我们的机器人聊天时都会登录。这对他们来说可能非常烦人。以下是有关该机器人的一些信息:

这是验证用户的代码:

public GreetingDialog(IConfiguration configuration, IBotTelemetryClient telemetryClient)
    : base(INTENTS.GREETING, configuration["ConnectionName"])
{
    TelemetryClient = telemetryClient;

    AddDialog(new OAuthPrompt(
        nameof(OAuthPrompt),
        new OAuthPromptSettings
        {
            ConnectionName = ConnectionName,
            Text = " Welcome! Please Sign In.",
            Title = "Sign In",
            Timeout = 30000,
        })
    {
        TelemetryClient = telemetryClient
    });

    AddDialog(new WaterfallDialog(INTENTS.GREETING, new WaterfallStep[] {
        PromptStepAsync,
        GreetStepAsync,
        })
    {
        TelemetryClient = telemetryClient
    });
    InitialDialogId = INTENTS.GREETING;
}

private async Task<DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
    return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
}

private async Task<DialogTurnResult> GreetStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
{ 
    // ...
}

问题是每次随机生成用户 ID 时,都会创建一个新对话。作为新会话,机器人无法找到之前的会话。

如果您想进行测试,您可以分配一个静态 ID 用户:

var userId = "dl_123456789";

它不应该让你重新登录。

要获得完整的解决方案,userId 应与您的应用程序中的某些独特凭证相关联(例如:username/password)