Reputation: 2063
I’m using the Microsoft Bot framework ( 4.x) and we have the virtual assistant set up along with a few skills. We are currently trying to have a user interrupt their current dialog in a particular skill and jump to a new one. We want to add functionality that would then enable us to jump back to where the user left off the in previous exited skill.
The question I have is if it’s possible to pass information from skill to Virtual assistant that is persistent throughout the whole conversation ? The information would be a list of strings or something of that nature
Upvotes: 5
Views: 191
Reputation: 5294
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
See if it helps.
Upvotes: 1