如何在 Bot Framework 中将 activity 传递给 formbuilder class
How to pass activity to formbuilder class in Bot Framework
我有下面的 LUIS 对话框 class,我从中将它重定向到 formbuilder class,我想将一个 context.Activity 传递给我的 formbuilder 方法,它驻留在另一个 class 是在 code.How 之后给出的吗?
public class LUISManager : LuisDialog<object>
{
[LuisIntent("BookFlight")]
public async Task BookFlight(IDialogContext context, LuisResult result)
{
//context.Activity
FlightBooking cb = new FlightBooking();
BuildFormDelegate<FlightBooking> MakeFlightBookingForm = FlightBooking.BuildForm;
var flightBooking = new FormDialog<FlightBooking>(cb, MakeFlightBookingForm, FormOptions.PromptInStart, null);
context.Call<FlightBooking>(flightBooking, FlightBookingComplete);
}
}
[Serializable]
public class FlightBooking
{
public static IForm<FlightBooking> BuildForm()
{
return new FormBuilder<FlightBooking>().Message("Tell me meeting details!")
.Field(nameof(title))
.Field(nameof(StartDate))//, validate: ValidateStartDate
.Field(nameof(EntryTime), validate:ValidateCallTime)
.Build();
}
},
我知道我们可以在 BuildForm 方法中传递 "IDialogContext context" 参数,但如何从 BuildFormDelegate
传递它
将构造函数更改为:
public static IForm<FlightBooking> BuildForm(IDialogContext context)
{}
然后你可以使用lambda表达式:
BuildFormDelegate<FlightBooking> MakeFlightBookingForm = ()=>FlightBooking.BuildForm(context);
我有下面的 LUIS 对话框 class,我从中将它重定向到 formbuilder class,我想将一个 context.Activity 传递给我的 formbuilder 方法,它驻留在另一个 class 是在 code.How 之后给出的吗?
public class LUISManager : LuisDialog<object>
{
[LuisIntent("BookFlight")]
public async Task BookFlight(IDialogContext context, LuisResult result)
{
//context.Activity
FlightBooking cb = new FlightBooking();
BuildFormDelegate<FlightBooking> MakeFlightBookingForm = FlightBooking.BuildForm;
var flightBooking = new FormDialog<FlightBooking>(cb, MakeFlightBookingForm, FormOptions.PromptInStart, null);
context.Call<FlightBooking>(flightBooking, FlightBookingComplete);
}
}
[Serializable]
public class FlightBooking
{
public static IForm<FlightBooking> BuildForm()
{
return new FormBuilder<FlightBooking>().Message("Tell me meeting details!")
.Field(nameof(title))
.Field(nameof(StartDate))//, validate: ValidateStartDate
.Field(nameof(EntryTime), validate:ValidateCallTime)
.Build();
}
},
我知道我们可以在 BuildForm 方法中传递 "IDialogContext context" 参数,但如何从 BuildFormDelegate
传递它将构造函数更改为:
public static IForm<FlightBooking> BuildForm(IDialogContext context)
{}
然后你可以使用lambda表达式:
BuildFormDelegate<FlightBooking> MakeFlightBookingForm = ()=>FlightBooking.BuildForm(context);