从主动对话框返回值

时间:2018-10-19 00:41:49

标签: botframework

我的情况是这样的,有2个用户-> U1和U2。

U1希望漫游器ping U2并获取一些信息

这是我使用基于对话框的主动消息的地方。

我当前正在使用v3 Bot Builder SDK sample

using (var scope = DialogModule.BeginLifetimeScope(Microsoft.Bot.Builder.Dialogs.Conversation.Container, message))
{
    var botData = scope.Resolve<IBotData>();
    await botData.LoadAsync(CancellationToken.None);

    //This is our dialog stack
    var task = scope.Resolve<IDialogTask>();

    // Interrupt the stack. This means that we're stopping whatever conversation that is currently happening with the user
    // Then adding this stack to run and once it's finished, we will be back to the original conversation

    var dialog = new GetFeedbackDialog(this.UserData);

    task.Call(dialog.Void<object, IMessageActivity>(), null);

    await task.PollAsync(CancellationToken.None);

    // Flush the dialog stack back to its state store.
    await botData.FlushAsync(CancellationToken.None);

}

class GetFeedbackDialog : IDialog<object>
{
    private RequestFeedbackData userData;

    public GetFeedbackDialog()
    {
    }

    public GetFeedbackDialog(RequestFeedbackData userData)
    {
        this.userData = userData;
    }

    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync($"Hello, Please provide feedback for "+ userData.OrganizerName+" on "+userData.FeedbackSubject);

        context.Wait(this.MessageReceivedAsync);
    }

    public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
        var message = await result;
        if (message.Text.ToLower().Equals("quit"))
        {
            await context.PostAsync("Quitting.. Thank you for using FeedbackBot!");
            context.Done(String.Empty); // Finish this dialog.
        }

        await context.PostAsync("Thank you for your feedback!");
        context.Done(message.Text);
    }
}

如何从启动主动消息的位置访问GetFeedbackDialog中U2键入的响应?

预先感谢您的帮助

0 个答案:

没有答案