If the dialog you are trying to retrieve the options in is a WaterfallDialog you can retrieve the options using the Options property, pass the options in using the options parameter.
Something like below:
// Call the dialog and pass through options
await dc.BeginDialogAsync(nameof(MyDialog), new { MyProperty1 = "MyProperty1Value", MyProperty2 = "MyProperty2Value" });
// Retrieve the options
public async Task<DialogTurnResult> MyWaterfallStepAsync(WaterfallStepContext waterfallStepContext, CancellationToken cancellationToken)
{
var passedInOptions = waterfallStepContext.Options;
...
}
Use strongly typed class for passing in and retrieving the options, so you could create something which looks like the following:
// Concrete class definition
public class MyOptions
{
public string OptionA{ get; set; }
public string OptionB{ get; set; }
}
// Passing options to Dialog
await dc.BeginDialogAsync(nameof(MyDialog), new MyOptions{ OptionA= "MyOptionOneValue", OptionB= "MyOptionTwo" });
// Retrieving options in child Dialog
using Newtonsoft.Json;
public async Task<DialogTurnResult> MyWaterfallStepAsync(WaterfallStepContext waterfallStepContext, CancellationToken cancellationToken)
{
var passedInOptions = waterfallStepContext.Options;
// Get passed in options, need to serialise the object before we deserialise because calling .ToString on the object is unreliable
MyOptions passedInMyOptions = JsonConvert.DeserializeObject<MyOptions>(JsonConvert.SerializeObject(waterfallStepContext.Options));
...
// Use retrieved options like passedInOptions.OptionA etc
}
Read more about EndDialogAsync
https://learn.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.dialogs.dialogcontext.enddialogasync?view=botbuilder-dotnet-stable#Microsoft_Bot_Builder_Dialogs_DialogContext_EndDialogAsync_System_Object_System_Threading_CancellationToken_
See if it helps.