在表单构建器对话框后,是否可以在DeleteStateForUser
中使用resumAfter
来保留当前对话框?
context.Call(searchFormDialog, this.ResumeAfterBuildSatisfactionForm);
private IForm<SatisfactionQuery> BuildSatisfactionForm()
{
OnCompletionAsyncDelegate<SatisfactionQuery> processSearch = async (context, state) =>
{
await context.PostAsync($"Thx");
};
return new FormBuilder<SatisfactionQuery>()
//.Message("")
.AddRemainingFields()
.OnCompletion(processSearch)
.Build();
}
private async Task ResumeAfterBuildSatisfactionForm(IDialogContext context, IAwaitable<SatisfactionQuery> result)
{
//but i don't have Activity here :-(
activity.GetStateClient().BotState.DeleteStateForUser(activity.ChannelId,activity.From.Id);
}
答案 0 :(得分:1)
您可以使用ServiceUrl创建StateClient:
private async Task ResumeAfterBuildSatisfactionForm(IDialogContext context, IAwaitable<SatisfactionQuery> result)
{
var msg = context.MakeMessage();
var stateClient = new StateClient(new Uri(msg.ServiceUrl));
stateClient.BotState.DeleteStateForUser(msg.ChannelId, msg.From.Id);
}