botframework确认对话框,以用户

时间:2018-03-20 16:33:44

标签: c# dialog botframework

我创建了一个确认对话框,用户可以选择是/否

 private async Task Confirm(IDialogContext context, IAwaitable<bool> result)
        {
            var res= await result;
            await context.PostAsync(res? "Proceed" : "Ok then");
            if (res) {
                ......
            }
        }

如果用户选择是,他将收到消息&#34;继续&#34; 同时(如果&#34; res&#34;为真),我想发送一个 没有出现在对话中的特定消息到机器人。 有没有办法在用户时将自定义消息发送回bot 按是?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用此方法中有权访问的context中存储的数据构建新活动。我不完全了解你的情况,但似乎这可能适用于你需要的东西。

var a = new Activity();
a.Conversation = context.Activity.Conversation;
a.Recipient = context.Activity.Recipient;
a.From = context.Activity.From;
a.Id = context.Activity.Id;
...    //set whatever else you need set
a.Text = "Whatever you need the text to be";

//send or process the activity do what it is you are trying to accomplish

编辑:我认为您实际需要的是Prompt.Confirm()