private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var cli = new ConnectorClient(new Uri(activity.ServiceUrl));
var activity = await result as IMessageActivity;
await context.PostAsync($"{activity.Text}");
activity.SuggestedActions = new SuggestedActions()
{
Actions = new List<CardAction>()
{
new CardAction(){ Title = "Blue", Type=ActionTypes.ImBack, Value="Blue" },
new CardAction(){ Title = "Red", Type=ActionTypes.ImBack, Value="Red" },
new CardAction(){ Title = "Green", Type=ActionTypes.ImBack, Value="Green" }
}
};
await context.PostAsync(activity);
context.Wait(MessageReceivedAsync);
}
我想让机器人向用户建议操作,我需要在对话框中执行此操作,有时还需要在表单流程中执行此操作。我还没弄清楚。当我在消息控制器中尝试时,它实际上起作用了。
答案 0 :(得分:1)
尝试创建如下答复:
var activity = await result as Activity;
var reply = activity.CreateReply("I have colors in mind, but need your help to choose the best one.");
reply.SuggestedActions = new SuggestedActions()
{
Actions = new List<CardAction>()
{
new CardAction(){ Title = "Blue", Type=ActionTypes.ImBack, Value="Blue" },
new CardAction(){ Title = "Red", Type=ActionTypes.ImBack, Value="Red" },
new CardAction(){ Title = "Green", Type=ActionTypes.ImBack, Value="Green" }
}
};
await context.PostAsync(reply);
context.Wait(MessageReceivedAsync);
您应该可以将此方法粘贴到您的MessageReceivedAsync
方法中,并且应该可以使用。您也不需要创建ClientConnector。