At the start I'm asking the user to choose his/her preferred language and then saving it in a database. On every dialog I'm switching the saved value with an if-else. It's a big project and I plan to do this with every dialog.
My question is: Is this optimal or is there a better way to do this?
private static async Task<DialogTurnResult> FirstStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var userstate = await (stepContext.Context.TurnState["BasicAccessors"] as BasicAccessors).BasicUserStateAccessor.GetAsync(stepContext.Context);
if (userstate.IsLanguageTagalog)
{
await stepContext.Context.SendActivityAsync(
MessageFactory.Text(
$"Kumusta {userstate.FirstName}."), cancellationToken);
}
else
{
await stepContext.Context.SendActivityAsync(
MessageFactory.Text(
$"Hi how are you {userstate.FirstName}."), cancellationToken);
}
return await stepContext.EndDialogAsync();
}