public IntroDialogSaudacao(ISaudacaoService saudacaoService, StateClient stateClient, List <FluxoMensagemDTO> fluxosMensagens) { _saudacaoService = saudacaoService; _fluxosMensagens = fluxosMensagens; _stateClient = stateClient; }
public IStateClient MakeStateClient() { if (this.StateClient == null) { this.StateClient = MockIBots(this).Object; } return(this.StateClient); }
/// <summary> /// Responds to user if this is a new conversation. /// - Says "Hi" if new user. /// - Says "Welcome back" if known user. /// </summary> /// <param name="activity">Information on who joined conversation.</param> /// <returns>"Activity with response or null to not respond.</returns> async Task <Activity> ReactToConversationUpdateAsync(Activity activity) { StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); UserInfo user; if (userData.Data != null) { user = userData.GetProperty <UserInfo>(UserInfoProperty); } else { user = new UserInfo { UserName = activity.From.Name, Joined = DateTime.Now }; } // if no record of previous visit, treat it as the first time. bool IsFirstVisit(UserInfo usr) => usr.LastVisit == default(DateTime); // is the message addressed to the chatbot? bool IsChatbot(ChannelAccount channelAcct) => channelAcct.Id == activity.Recipient.Id; string response; if (activity.MembersAdded?.Any(IsChatbot) ?? false) { response = IsFirstVisit(user) ? "Hi, welcome to PC Bot." : "Welcome back."; } else { return(null); } Activity returnActivity = activity.CreateReply(response); user.LastVisit = DateTime.Now; userData.SetProperty <UserInfo>(UserInfoProperty, user); try { await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); } catch (HttpOperationException) { userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); user = userData.GetProperty <UserInfo>(UserInfoProperty); user.LastVisit = DateTime.Now; userData.SetProperty <UserInfo>(UserInfoProperty, user); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); } return(returnActivity); }
public async Task DeleteAsync(Activity activity) { using (StateClient stateClient = activity.GetStateClient()) { IBotState chatbotState = stateClient.BotState; await chatbotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id); } }
protected override IReadOnlyList <object> MakeServices() { var credentials = new MicrosoftAppCredentials(); var connector = new ConnectorClient(new Uri(activity.ServiceUrl), credentials); // TODO: different state storage for emulator var storage = new StateClient(credentials); return(new object[] { this.controller, this.activity, this.response, connector, storage }); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; List <FoodModel> foodList = FoodModel.GetFoodList(); //Get state StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); var sentGreeting = userData.GetProperty <bool>("SentGreeting"); if (activity.Text.Contains(MoreOption)) { //More of the same food //await DisplayFoodCard(context, result); if (currentFood == null) { //No current food - generate random currentFood = getRandomFood(foodList); } else { currentFood.IncrementIndex(); } } else if (activity.Text == NextOption) { //Next food type currentFood = getRandomFood(foodList); } else if (activity.Text.Contains(FindOption)) { //Find restaurant closest return; } else { if (!sentGreeting) { WelcomePrompt(context); //Save state var data = context.UserData; data.SetValue("SentGreeting", true); } else { //Unknown - unrecognized message UnrecognisedPrompt(context); } return; } ShowFoodCard(currentFood, context); }
async Task <Activity> ReactToDeleteUserAsync(Activity activity) { StateClient stateClient = activity.GetStateClient(); string[] response = await stateClient.BotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id); return(activity.CreateReply( $"User Deleted From - ID: {activity.From.Id}, Name: {activity.From.Name}")); }
public async Task <string> DeleteScoreAsync(Activity activity) { using (StateClient stateClient = activity.GetStateClient()) { IBotState chatbotState = stateClient.BotState; await chatbotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id); return("All Scores Deleted."); } }
public IStateClient MakeStateClient() { if (this.stateClient == null) { var mockStateClient = MockIBots(this); this.stateClient = mockStateClient.Object; } return(this.stateClient); }
public async Task GetStatePlayer_NoExistingData_ShouldReturnEmptyState() { var questEngineStateClient = new StateClient(TestHttpClient); var result = await questEngineStateClient.GetStatePlayerAsync("playerGetDataNoExisting"); result.Should().NotBeNull(); result.LastMilestoneIndexCompleted.Should().BeNull(); result.TotalQuestPercentCompleted.Should().Be(0); }
private string ProcessAndSetRegion(Activity msg) { StateClient stateClient = msg.GetStateClient(); //BotData userData = stateClient.BotState.GetPrivateConversationData(msg.ChannelId, msg.Conversation.Id, msg.From.Id); //TODO: Move to user level? string par = GetParameter(msg.Text); userData.SetProperty <string>("Region", par); stateClient.BotState.SetPrivateConversationData(msg.ChannelId, msg.Conversation.Id, msg.From.Id, userData); return(String.IsNullOrEmpty(par) ? "любой." : par + " \r\nВернуться к поиску без учета региона можно с помощью команды /регион без параметра."); }
public void UpdateUnitProperty(StateClient state) { int i = 0; foreach (var unit in state.Units) { Players[i].GetComponent <UnitController>().UnitProperty.Init(unit); i++; } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); try { if (activity.GetActivityType() == ActivityTypes.Message) { if (!string.IsNullOrEmpty(activity.Text) && !m_doNotProcess.Contains(activity.Text.Trim().ToLower())) { LanguageManager lang; if (IsLanguageCommand(activity.Text, out lang)) { StateClient state = activity.GetStateClient(); BotData data = state.BotState.GetUserData(activity.ChannelId, activity.From.Id); data.SetProperty <string>(LanguageManager.QUERY_LANGUAGE, lang.Language); state.BotState.SetUserData(activity.ChannelId, activity.From.Id, data); await connector.Conversations.ReplyToActivityAsync(activity.CreateReply(lang.LangChange)); } else { await Conversation.SendAsync(activity, MakeRoot); } } else // is it an emoji or attachment? { await connector.Conversations.ReplyToActivityAsync(activity.CreateReply(":)")); } } else { await connector.Conversations.ReplyToActivityAsync(HandleSystemMessage(activity)); } } catch (Exception ex) { try { StorageLogger.LogError(new ErrorLog(ex) { Question = activity.Text, User = activity.From.Name }); } catch { } Activity msg = activity.CreateReply("BOT ERROR! Nooooooooooooooo"); msg.Attachments = new List <Attachment>(); msg.Attachments.Add(new Attachment { ContentType = "image/png", ContentUrl = ImageHelper.GetVader() }); await connector.Conversations.ReplyToActivityAsync(msg); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); if (activity.Type == ActivityTypes.ConversationUpdate) { // mensagem para retornar string messageToReply = "Benvindo a Porto Seguro, como podemos te ajudar?"; StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); Usuario user = userData.GetProperty <Usuario>("UserData"); // se o usuário existir, recupera if (user != null) { string UserFirstName = Formatters.Capitalize(user.Nome).Split( )[0]; messageToReply = $"Benvindo a Porto Seguro {UserFirstName}, como podemos te ajudar?"; } log.Info("[BOT][" + activity.ChannelId + "][" + activity.From.Id + "]: " + messageToReply); await connector.Conversations.ReplyToActivityAsync(activity.CreateReply(messageToReply)); } else if (activity.Type == ActivityTypes.Message) { try { if (activity.Attachments.Any()) { foreach (Attachment at in activity.Attachments) { try { log.Info("UsuárioAtt [" + activity.From.Id + "] Name:" + at.Name + " ThumbnailUrl:" + at.ThumbnailUrl + " ContentUrl:" + at.ContentUrl + " ContentType:" + at.ContentType); await connector.Conversations.ReplyToActivityAsync(activity.CreateReply("Desculpe, no momento eu não consigo entender emoticons e anexos, por favor, use apenas texto.")); } catch (Exception e) { log.Error("Erro: " + e.ToString(), e); } } } } catch (Exception e) { log.Error("Erro: " + e.ToString(), e); } await Conversation.SendAsync(activity, () => new RootLuisDialog()); log.Info("Usuário [" + activity.ChannelId + "][" + activity.From.Id + "]: " + activity.Text); } else { HandleSystemMessage(activity); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public static async Task <Activity> HandleTransaction(Activity message, LUISQueryResult LUISResult) { StateClient stateClient = message.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(message.ChannelId, message.From.Id); //check query included required paramaters if (!(LUISResult.parameters.ContainsKey("AccountNumber") && VerifyAccountNumber(LUISResult.parameters["AccountNumber"]))) { return(message.CreateReply("To make a transaction, you must include a valid account number")); } if (!LUISResult.parameters.ContainsKey("Money")) { return(message.CreateReply("To make a transaction, you must include an amount to send")); } Account From = await AzureManager.AzureManagerInstance.GetAccountByNumber(userData.GetProperty <string>("AccountNumber")); Account To = await AzureManager.AzureManagerInstance.GetAccountByNumber(AccountNumberStrip(LUISResult.parameters["AccountNumber"])); double amount = double.TryParse(ExtractNum.Replace(FindNum.Match(LUISResult.parameters["Money"]).Value, ""), out amount) ? amount : 0.0; //check particulars are valid if (amount <= 0) { return(message.CreateReply("Cannot send a non-positive amount of money")); } if (To == null) { return(message.CreateReply("Recipient account not found")); } if (amount > From.Balance) { return(message.CreateReply(string.Format("Insufficient funds $ {0:F2}, to pay $ {1:F2}", From.Balance, amount))); } //setup transaction, pending confirmation PendingTransaction transaction = new PendingTransaction { From = From, To = To, amount = amount }; userData.SetProperty("Pending", "Transaction"); userData.SetProperty("PendingTransaction", transaction); await stateClient.BotState.SetUserDataAsync(message.ChannelId, message.From.Id, userData); Activity response = message.CreateReply("Please confirm or cancel transaction:"); response.Attachments = new List <Attachment> { TransactionConfirmationCard(transaction) }; return(response); }
public async Task <MeetingData> GetAsync(IActivity activity) { using (StateClient stateClient = activity.GetStateClient()) { IBotState chatbotState = stateClient.BotState; BotData chatbotData = await chatbotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); return(chatbotData.GetProperty <MeetingData>(MeetingDataProperty)); } }
private async Task stateSentGreeting(Activity activity, StateClient stateClient, BotData userData) { //最初の一度だけこのダイアログがでるようにするため、UserDataに挨拶したことを保存しておく userData.SetProperty <bool>("SentGreeting", true); DateTime nowtime = DateTime.Now; userData.SetProperty <string>("SentGreetingTime", nowtime.ToString()); //初期はメニュー階層を1にする userData.SetProperty <int>("MenuState", 1); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); }
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> argument) { var activity = await argument as Activity; StateClient state = activity.GetStateClient(); BotData userData = await state.BotState.GetPrivateConversationDataAsync(activity.ChannelId, activity.Conversation.Id, activity.From.Id); string selectedOption = userData.GetProperty <string>("SelectedOption"); context.Done($"Selection: {selectedOption}"); }
private async Task HandleSystemMessage(Activity message) { await Task.CompletedTask; if (message.Type == ActivityTypes.DeleteUserData) { // Implement user deletion here // If we handle user deletion, return a real message } else if (message.Type == ActivityTypes.ConversationUpdate) { StateClient stateClient = message.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(message.ChannelId, message.From.Id); var greeting = userData.GetProperty <bool>("SentGreeting"); // We already sent a greeting message. // if (greeting) // return; var context = new ConnectorClient(new Uri(message.ServiceUrl)); var reply = message.CreateReply(); var options = new List <KeyValuePair <string, string> >(); options.Add(new KeyValuePair <string, string>(Resources.RootDialog_Welcome_SeeMenu, Resources.RootDialog_Welcome_SeeMenu)); options.Add(new KeyValuePair <string, string>(Resources.RootDialog_Welcome_Hours, Resources.RootDialog_Welcome_Hours)); options.Add(new KeyValuePair <string, string>(Resources.RootDialog_Welcome_Directions, Resources.RootDialog_Welcome_Directions)); reply.AddHeroCard( Resources.RootDialog_Welcome_Title, Resources.RootDialog_Welcome_Subtitle, options, new[] { "http://www.redlandstacoshack.com/images/TACO_LOGO.png" }); context.Conversations.ReplyToActivity(reply); // Set flag to turn off duplicate greeting messages. userData.SetProperty <bool>("SentGreeting", true); await stateClient.BotState.SetUserDataAsync(message.ChannelId, message.From.Id, userData); } else if (message.Type == ActivityTypes.ContactRelationUpdate) { // Handle add/remove from contact lists // Activity.From + Activity.Action represent what happened } else if (message.Type == ActivityTypes.Typing) { // Handle knowing tha the user is typing } else if (message.Type == ActivityTypes.Ping) { } }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { // Detect if this is a Message activity if (activity.Type == ActivityTypes.Message) { // Get any saved values StateClient sc = activity.GetStateClient(); BotData userData = sc.BotState.GetPrivateConversationData( activity.ChannelId, activity.Conversation.Id, activity.From.Id); var boolProfileComplete = userData.GetProperty <bool>("ProfileComplete"); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); if (!boolProfileComplete) { // Call our FormFlow by calling MakeRootDialog await Conversation.SendAsync(activity, MakeRootDialog); } else { var Name = userData.GetProperty <string>("Name"); var Email = userData.GetProperty <string>("Email"); var Gender = userData.GetProperty <string>("Sexe"); var Choice = userData.GetProperty <string>("Choice"); var Studie = userData.GetProperty <string>("Studie"); var Motivation = userData.GetProperty <string>("Motivation"); var WhatWeEarn = userData.GetProperty <string>("WhatWeEarn"); var centreInteret = userData.GetProperty <string>("centreInteret"); // Tell the user their profile is complete System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Votre Reponse est enregistré\n\n"); // Create final reply Activity replyMessage = activity.CreateReply(sb.ToString()); var conn = new DBConnect(); var insert = "INSERT INTO members VALUES (11, '" + Name + "', '" + Email + "', '" + WhatWeEarn + "', '" + Motivation + "',' " + centreInteret + "',' " + Gender + "',' " + Choice + "',' " + Studie + "', NULL, NULL)"; conn.Insert(insert); await connector.Conversations.ReplyToActivityAsync(replyMessage); } } else { // This was not a Message activity HandleSystemMessage(activity); } // Send response var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public async Task <string> CreateCardAsync([FromBody] CardDetails details, [FromServices] StateClient state) { string id = Guid.NewGuid().ToString(); await this.SetCardAsync(id, details, state); var user = UserActorProxy.CreateProxy(details.UserId); await user.AddCardAsync(id); return(id); }
public async Task GreetFarewell(IDialogContext context, LuisResult luisResult) { StateClient stateClient = new StateClient(new MicrosoftAppCredentials("xxxxxxxxxx-4d43-4131-be5b-xxxxxxxxxxx", "jkmbt39>:xxxxxxxxxxxx!~")); //BotData userData = stateClient.BotState.GetUserData(context.Activity.ChannelId, context.Activity.From.Id); BotData userData = stateClient.BotState.GetUserData("skype", context.Activity.From.Id); userData.RemoveProperty("AccessToken"); stateClient.BotState.SetUserData(context.Activity.ChannelId, context.Activity.From.Id, userData); await context.PostAsync("b'bye \U0001F44B Take care"); context.Wait(this.MessageReceived); }
public FccBotState(Activity activity) { // Get any saved values _activity = activity; _sc = activity.GetStateClient(); _botData = _sc.BotState.GetPrivateConversationData ( activity.ChannelId, activity.Conversation.Id, activity.From.Id ); }
void Update() { if (Input.GetMouseButtonDown(1)) { reqState = CollectState(); HitTarget(Players); StartCoroutine(Request.GetNextState(reqState, UpdateUnitProperty)); reqState.Units.Clear(); } }
//public async Task<Message> Post([FromBody]Message message) //{ // string messagetext = (message.Text).ToLower(); // await NearByPlaces(messagetext, 2 * 1000); // if (rootObject != null) // { // if (rootObject.results.Count > 0) // { // foreach (var item2 in rootObject.results) // { // // return our reply to the user // //item= item1.Title; // list += item2.name + "," + "\r \n"; // } // } // else // { // return message.CreateReplyMessage("Sorry we are unable to find the results for " +"''"+messagetext+"''"+ "Please make sure that you have typed correct phrase..." + "\r \n" + " some examples are..." + "\r \n" + "''" + "Restaurants in Albany" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "show me book stores in Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "Parking near Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "atms surrounding Norwich" + "''" + "''"); // } // } // else // { // return message.CreateReplyMessage("Oops.... Something went wrong please try again." ); // } // //} // return message.CreateReplyMessage(list); // //} // //else // //{ // // return message.CreateReplyMessage("Oops.... Something went wrong. Please make sure that you have type praser..." + "\r \n" + " some examples are..." + "\r \n" + "''" + "show me nearby atm" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "show me nearby hospital" + "''"); // //} // // } //} public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { string messagetext = (activity.Text).ToLower(); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); var data = userData.GetProperty <string>("searchedText"); if (data != null) { Activity reply = activity.CreateReply($"you previous searched phrase is" + "\r \n" + $"**{data}**" + "\r \n"); await connector.Conversations.ReplyToActivityAsync(reply); } userData.SetProperty <string>("searchedText", activity.Text); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); await NearByPlaces(messagetext, 2 * 1000); if (rootObject != null) { if (rootObject.results.Count > 0) { foreach (var item2 in rootObject.results) { // return our reply to the user //item= item1.Title; list += item2.name + "," + "\r \n"; } Activity reply1 = activity.CreateReply(list); await connector.Conversations.ReplyToActivityAsync(reply1); } else { Activity errorreply = activity.CreateReply("Sorry we are unable to find the results for " + "''" + messagetext + "''" + "Please make sure that you have typed correct phrase..." + "\r \n" + " some examples are..." + "\r \n" + "''" + "Restaurants in Albany" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "show me book stores in Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "Parking near Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "atms surrounding Norwich" + "''" + "''"); await connector.Conversations.ReplyToActivityAsync(errorreply); // return Request.CreateResponse("Sorry we are unable to find the results for " + "''" + messagetext + "''" + "Please make sure that you have typed correct phrase..." + "\r \n" + " some examples are..." + "\r \n" + "''" + "Restaurants in Albany" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "show me book stores in Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "Parking near Norwich" + "''" + "''" + "\r \n" + "(or)" + "\r \n" + "''" + "atms surrounding Norwich" + "''" + "''"); } } else { Activity errorreply = activity.CreateReply($"**Oops.... Something went wrong please try again.**"); await connector.Conversations.ReplyToActivityAsync(errorreply); // return Request.CreateResponse("Oops.... Something went wrong please try again."); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { bool askedForUserName = false; string userName = ""; StringBuilder replyMessage = new StringBuilder(); if (activity.Type == ActivityTypes.Message) { StateClient sc = activity.GetStateClient(); BotData userData = await sc.BotState.GetPrivateConversationDataAsync(activity.ChannelId, activity.Conversation.Id, activity.From.Id); askedForUserName = userData.GetProperty <bool>("AskedForUserName"); userName = userData.GetProperty <string>("UserName") ?? ""; if (!askedForUserName) { replyMessage.Append($"Hi ! I am your friend Pluto. What's your name? "); userData.SetProperty <bool>("AskedForUserName", true); } else { if (userName == "") { replyMessage.Append($"Hello {activity.Text}. How can I help you?"); userData.SetProperty <string>("UserName", activity.Text); } else { var model = await manager.GetModelFromLuis(activity.Text); var answer = await manager.ProcessResponse(model); replyMessage.Append(answer); } } await sc.BotState.SetPrivateConversationDataAsync(activity.ChannelId, activity.Conversation.Id, activity.From.Id, userData); //var model = await manager.GetModelFromLuis(activity.Text); ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); // return our reply to the user // var answer =await manager.ProcessResponse(model); // replyMessage.Append(answer); Activity reply = activity.CreateReply(replyMessage.ToString()); await connector.Conversations.ReplyToActivityAsync(reply); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { var mbld = new Dialogs.MeBotLuisDialog(); StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); mbld.rating = userData.GetProperty <int>("rating"); mbld.flagGreetingDone = userData.GetProperty <int>("flagGreetingDone"); mbld.flagCityInformed = userData.GetProperty <int>("flagCityInformed"); mbld.flagAgeInformed = userData.GetProperty <int>("flagAgeInformed"); mbld.flagStateInformed = userData.GetProperty <int>("flagStateInformed"); mbld.flagCityObtained = userData.GetProperty <int>("flagCityObtained"); mbld.flagAgeObtained = userData.GetProperty <int>("flagAgeObtained"); mbld.flagStateObtained = userData.GetProperty <int>("flagStateObtained"); mbld.flagSexualLevel = userData.GetProperty <int>("flagSexualLevel"); mbld.flagInformalLevel = userData.GetProperty <int>("flagInformalLevel"); mbld.flagMispellingLevel = userData.GetProperty <int>("flagMispellingLevel"); mbld.flagEmotionalLevel = userData.GetProperty <int>("flagEmotionalLevel"); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); await Conversation.SendAsync(activity, () => mbld); stateClient = activity.GetStateClient(); userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); userData.SetProperty <int>("flagGreetingDone", mbld.flagGreetingDone); userData.SetProperty <int>("flagCityInformed", mbld.flagCityInformed); userData.SetProperty <int>("flagAgeInformed", mbld.flagAgeInformed); userData.SetProperty <int>("flagStateInformed", mbld.flagStateInformed); userData.SetProperty <int>("flagCityObtained", mbld.flagCityObtained); userData.SetProperty <int>("flagAgeObtained", mbld.flagAgeObtained); userData.SetProperty <int>("flagStateObtained", mbld.flagStateObtained); userData.SetProperty <int>("flagSexualLevel", mbld.flagSexualLevel); userData.SetProperty <int>("flagInformalLevel", mbld.flagInformalLevel); userData.SetProperty <int>("flagMispellingLevel", mbld.flagMispellingLevel); userData.SetProperty <int>("flagEmotionalLevel", mbld.flagMispellingLevel); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public async Task <ActionResult <Account> > Deposit(Transaction transaction, [FromServices] StateClient stateClient) { var state = await stateClient.GetStateEntryAsync <Account>(StoreName, transaction.Id); state.Value ??= new Account() { Id = transaction.Id, }; state.Value.Balance += transaction.Amount; await state.SaveAsync(); return(state.Value); }
public async Task SetCardAsync(string id, [FromBody] CardDetails details, [FromServices] StateClient state) { var proxy = CardActorProxy.CreateProxy(id); await proxy.SetDetailsAsync(details); var cards = await state.GetStateAsync <HashSet <string> >("cards"); cards ??= new HashSet <string>(); cards.Add(id); await state.SaveStateAsync("cards", cards); }
public async Task SetDeckAsync(string id, [FromBody] DeckDetails details, [FromServices] StateClient state) { var deck = DeckActorProxy.CreateProxy(id); await deck.SetDetailsAsync(details); var decks = await state.GetStateAsync <HashSet <string> >("decks"); decks ??= new HashSet <string>(); decks.Add(id); await state.SaveStateAsync("decks", decks); }