现在,我们的用户每次想与我们的机器人聊天时都登录。对于他们来说可能非常烦人。以下是有关该漫游器的一些信息:
var userId = "dl_" + new Random().Next() + new DateTime().Ticks;
以下是验证用户身份的代码:
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)
{
// ...
}
答案 0 :(得分:1)
问题在于,每次您随机生成用户ID时,都会创建一个新对话。该机器人是新会话,无法找到前一个会话。
如果要进行测试,可以分配一个静态ID用户:
var userId = "dl_123456789";
它不应该要求您再次登录。
要提供完整的解决方案,应将userId
绑定到应用程序中的某些独特凭据(例如:用户名/密码)