问题
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