Beispiel #1
0
        private static void SetData(ITurnContext turnContext)
        {
            var setData = turnContext.Activity.Text.ToUpper().Split(':');

            if (setData[0].StartsWith("USER"))
            {
                turnContext.UserData().SetValue("UserDataValue", setData[1]);
            }
            else if (setData[0].StartsWith("PRIVATE"))
            {
                turnContext.PrivateConversationData().SetValue("PrivateConversationDataValue", setData[1]);
            }
            else
            {
                turnContext.ConversationData().SetValue("ConversationDataValue", setData[1]);
            }
        }
Beispiel #2
0
        private static async Task ShowData(ITurnContext turnContext)
        {
            IBotDataBag userData = turnContext.UserData();
            string      userName = string.Empty;

            userData.TryGetValue("UserDataValue", out userName);

            IBotDataBag conversationData      = turnContext.ConversationData();
            string      conversationDataValue = string.Empty;

            conversationData.TryGetValue("ConversationDataValue", out conversationDataValue);

            IBotDataBag privateConversationData      = turnContext.PrivateConversationData();
            string      privateConversationDataValue = string.Empty;

            privateConversationData.TryGetValue("PrivateConversationDataValue", out privateConversationDataValue);

            await turnContext.SendActivityAsync($"UserData.UserName={userName}");

            await turnContext.SendActivityAsync($"ConversationData.ConversationDataValue={conversationDataValue}");

            await turnContext.SendActivityAsync($"PrivateConversationData.PrivateConversationDataValue={privateConversationDataValue}");
        }