Exemplo n.º 1
0
        public void StartConversation(ConversationStarter conversationStarter) // TODO put this here?
        {
            Person       person       = PersonService.GetPersonByPhoneNumber(conversationStarter.PhoneNumber);
            Conversation conversation = ConversationService.CreateConversation(conversationStarter, person);

            DataClasses.Message firstMessage = ScriptService.GetFirstMessageFromScript(conversation.Script);

            conversation.CurrentMessage = firstMessage;

            Communication text = CommunicationService.CreateOutgoingCommunication(conversation, firstMessage);

            conversation.Communications.Add(text);
            Context.SaveChanges();

            MessagingService.SendMessage(person.PhoneNumber, firstMessage.Body);
        }
Exemplo n.º 2
0
        public Conversation CreateConversation(ConversationStarter conversationStarter, Person person)
        {
            Conversation conversation = GetActiveConversationForPerson(person);

            if (conversation != null)
            {
                throw new OmniBotException(person + " already has an active conversation and cannot be started on a new one.");
            }

            DataClasses.Script script = ScriptService.GetScriptByConversationStarter(conversationStarter);

            conversation = new Conversation()
            {
                Id       = -1,
                Person   = person,
                Script   = script,
                StatusId = StatusService.getInstance().conversationStatuses[StatusType.STARTED.ToString()].Id,
                Active   = true
            };

            Context.Conversations.Add(conversation);

            return(conversation);
        }