方法1:
public async Task WelcomeAsync(
IDialogContext context,
IAwaitable<Message> argument)
{
var message = await argument;
message.SetBotConversationData("DateTime", DateTime.UtcNow);
StorageAccess.StoreTemporaryLog(
StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
"user",
message.Text);
await context.PostAsync(
"Welcome to VAM Insurance Bot\n" +
"Do you already have a policy or do you want to buy a new policy?\n" +
"1.Already\n" +
"2.New\n" +
"Please enter the correct choice:");
StorageAccess.StoreTemporaryLog(
StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
"bot",
"Welcome to VAM Insurance Bot\n" +
"Do you already have a policy or do you want to buy a new policy?\n" +
"1.Already\n" +
"2.New\n" +
"Please enter the correct choice:");
context.Wait(AlreadyNewAsync);
}
方法 2:
public async Task AuthenicateClientAsync(
IDialogContext context,
IAwaitable<Message> argument)
{
var message = await argument;
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(message.GetBotConversationData<DateTime>("DateTime")),
message.GetBotUserData<string>("policyNo"),
"user",
message.Text);
if (DBAccess.AuthenticateOTP(message.Text))
{
await context.PostAsync("You have been successfully authenticated!");
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData<DateTime>("DateTime")),
message.GetBotUserData<string>("policyNo"),
"bot",
"You have been successfully authenticated!");
await context.PostAsync(
"What would you like to do?\n" +
"1. View your policy\n" +
"2. Renew you policy\n" +
"3. File an insurance claim\n" +
"Please enter the suitable options number:");
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData<DateTime>("DateTime")),
message.GetBotUserData<string>("policyNo"),
"bot",
"What would you like to do?\n" +
"1. View your policy\n" +
"2. Renew you policy\n" +
"3. File an insurance claim\n" +
"Please enter the suitable options number:");
context.Wait(ViewRenewFileClaimAsync);
}
else
{
await context.PostAsync(
"The OTP that you have entered is either incorrect or expired.\n" +
"Would you like to go over again?\n" +
"Yes\n" +
"No");
StorageAccess.StoreStructuredLog(
StorageAccess.GetDateTime(
message.GetBotConversationData<DateTime>("DateTime")),
message.GetBotUserData<string>("policyNo"),
"bot",
"The OTP that you have entered is either incorrect or expired.\n" +
"Would you like to go over again?\n" +
"Yes\n" +
"No");
context.Wait(RepeatAsync);
}
}
这是我项目中对话的两种方法。我已将它们部署在Azure上,并连接到Telegram。但"\n"似乎并不总是有效。正如您在屏幕截图中看到的,它只在某些地方起作用。如您所见,方法1的对话没有新行。但在方法2中,除了最后一个之外,它们都有新行。
访问https://storageangsu.blob.core.windows.net/policy-number-0123456789/image_damage查看图片。