用户每次都必须登录?
Users have to sign in every time?
现在,我们的用户每次想与我们的机器人聊天时都会登录。这对他们来说可能非常烦人。以下是有关该机器人的一些信息:
- 使用 Direct Line 渠道访问机器人。
- 当我在 Azure 中使用 "Test in Web Chat" 功能时,我每次都保持登录状态。所以在那里工作得很好。
- 我们正在为 UI 使用 BotFramework-WebChat 组件。
- 我按照 this tutorial 生成了一个用户令牌。我生成了这样的用户 ID:
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)
{
// ...
}
问题是每次随机生成用户 ID 时,都会创建一个新对话。作为新会话,机器人无法找到之前的会话。
如果您想进行测试,您可以分配一个静态 ID 用户:
var userId = "dl_123456789";
它不应该让你重新登录。
要获得完整的解决方案,userId
应与您的应用程序中的某些独特凭证相关联(例如:username/password)
现在,我们的用户每次想与我们的机器人聊天时都会登录。这对他们来说可能非常烦人。以下是有关该机器人的一些信息:
- 使用 Direct Line 渠道访问机器人。
- 当我在 Azure 中使用 "Test in Web Chat" 功能时,我每次都保持登录状态。所以在那里工作得很好。
- 我们正在为 UI 使用 BotFramework-WebChat 组件。
- 我按照 this tutorial 生成了一个用户令牌。我生成了这样的用户 ID:
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)
{
// ...
}
问题是每次随机生成用户 ID 时,都会创建一个新对话。作为新会话,机器人无法找到之前的会话。
如果您想进行测试,您可以分配一个静态 ID 用户:
var userId = "dl_123456789";
它不应该让你重新登录。
要获得完整的解决方案,userId
应与您的应用程序中的某些独特凭证相关联(例如:username/password)