botframework confirm dialog, send message as user

余生长醉 提交于 2020-01-06 04:33:23

问题


I have created a confirm dialog where the user can select yes/no

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

If the user selects Yes he will receive the message "Proceed" At the same time (again if "res" is true), i want to send a specific message to the bot without appearing in the conversation. Is there a way to send a custom message back to the bot when user press Yes?


回答1:


You could try constructing a new activity using data stored in the context which you have access to in this method. I don't fully understand your scenario but it seems this may work for what you need.

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

Edit: I think what you are actually looking for is Prompt.Confirm().



来源:https://stackoverflow.com/questions/49389603/botframework-confirm-dialog-send-message-as-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!