Skip to content

BotBuilder .NET SDK example of overriding the activity Locale with user choice

License

Notifications You must be signed in to change notification settings

EricDahlvang/ChooseLanguageBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChooseLanguageBot

Emulator Example

Once the user has chosen a language, the Locale is stored in PrivateConversationData and the activity locale is modified accordingly in the MessagesController before message processing:

if (activity.Type == ActivityTypes.Message)
{
    using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, activity))
    {
        var botData = scope.Resolve<IBotData>();
        await botData.LoadAsync(CancellationToken.None);
                    
        var lcid = botData.PrivateConversationData.GetValueOrDefault<string>("LCID");
        if (!string.IsNullOrEmpty(lcid))                    
            activity.Locale = lcid;
                    
        await botData.FlushAsync(CancellationToken.None);
    }

    await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
}

About

BotBuilder .NET SDK example of overriding the activity Locale with user choice

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published