public Customer DoAction(StateActionDto dto) { var message = _messageService.GetRandomTypedMessage(MessageType.IntroGreetingReturning).Text; var customer = dto.Customer; customer.Session.AwaitState = SessionState.Listening; if (string.IsNullOrEmpty(customer.Name)) { message += System.Environment.NewLine + System.Environment.NewLine + _messageService.GetRandomTypedMessage(MessageType.RequestName).Text; customer.Session.AwaitState = SessionState.AwaitName; } _twilioService.SendMessage(new SendMessageDto { FromNumber = dto.MyNumber, ToNumber = customer.PhoneNumber }, new MessageBuilderContext { Customer = customer, InputText = dto.InputText, SendText = message }); return(customer); }
public Customer DoAction(StateActionDto dto) { var customer = dto.Customer; string message = ""; var response = _googleAnalyticsService.Analyze(dto.InputText); var person = response.Entities.FirstOrDefault(e => e.Type == Type.Person); if (person != null) { customer.Name = person.Name; message = _messageService.GetRandomTypedMessage(MessageType.RequestNameResponseSuccess).Text; customer.Session.AwaitState = SessionState.Listening; } else { message = _messageService.GetRandomTypedMessage(MessageType.RequestNameResponseFail).Text; customer.Session.AwaitState = SessionState.AwaitName; } _twilioService.SendMessage(new SendMessageDto { FromNumber = dto.MyNumber, ToNumber = customer.PhoneNumber }, new MessageBuilderContext { Customer = customer, InputText = dto.InputText, SendText = message });; return(customer); }
public Customer DoAction(StateActionDto dto) { var customer = dto.Customer; var listeningActions = _listeningActionService.GetListeningActionsByMatch(dto.InputText); var priorities = new List <Func <MessageBuilderContext> > { () => NoMatch(customer, listeningActions), () => UniqueTypedMatch(customer, listeningActions), () => MultipleTypedMatches(customer, listeningActions), () => GeneralMatch(customer, listeningActions) }; var mbContext = new MessageBuilderContext(); foreach (var func in priorities) { mbContext = func(); if (mbContext == null) { continue; } else { break; } } mbContext.InputText = dto.InputText; _twilioService.SendMessage(new SendMessageDto { FromNumber = dto.MyNumber, ToNumber = customer.PhoneNumber }, mbContext); return(customer); }
public Customer DoAction(StateActionDto dto) { var response = _googleAnalyticsService.Analyze(dto.InputText); throw new System.NotImplementedException(); }
public Customer DoAction(StateActionDto dto) { return(_stateDictionary[dto.Customer.Session.AwaitState].DoAction(dto)); }