Example #1
0
    public override void Enter()
    {
        base.Enter ();
        if (IsBattleOver ()) {
            if(DidPlayerWin())
                data = Resources.Load<ConversationData>("Conversations/OutroSceneWin");
            else
                data = Resources.Load<ConversationData>("Conversations/OutroSceneLose");
        } else {
            data = Resources.Load<ConversationData> ("Conversations/IntroScene");
        }

        conversationController.Show (data);
    }
Example #2
0
    IEnumerator Sequence(ConversationData data)
    {
        for (int i = 0; i < data.list.Count; ++i)
        {
            SpeakerData sd = data.list[i];

            ConversationPanel currentPanel = (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.MiddleLeft || sd.anchor == TextAnchor.LowerLeft) ? leftPanel : rightPanel;
            IEnumerator presenter = currentPanel.Display(sd);
            presenter.MoveNext();

            string show, hide;
            if (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.UpperCenter || sd.anchor == TextAnchor.UpperRight)
            {
                show = ShowTop;
                hide = HideTop;
            }
            else
            {
                show = ShowBottom;
                hide = HideBottom;
            }

            currentPanel.panel.SetPosition(hide, false);
            MovePanel(currentPanel, show);

            yield return null;
            while (presenter.MoveNext())
                yield return null;

            MovePanel(currentPanel, hide);
            transition.easingControl.completedEvent += delegate(object sender, EventArgs e) {
                conversation.MoveNext();
            };

            yield return null;
        }

        canvas.gameObject.SetActive(false);
        if (completeEvent != null)
            completeEvent(this, EventArgs.Empty);
    }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     ConversationData.Load();
     ConversationUI.Open(1, true);
 }
Example #4
0
        private async Task ValidateQnA(ConversationData conversation, string answer)
        {
            switch (conversation.LastQuestionAsked)
            {
            case (int)Question.CompanyName:
                // Validate message (reported issue) e.g. min length
                if (!string.IsNullOrEmpty(answer))
                {
                    // Search company from Jira (Get company code)
                    var clientResultList = await _caseMgmtService.GetClientCompanies(_company, answer);

                    // Search clients databases
                    // var clientList = _clientService.Get();
                    // var clientResult = clientList.Where(x => x.ClientCompanyName.ToLower() == answer.ToLower()).FirstOrDefault();

                    if (clientResultList.Count == 1)
                    {
                        var clientResult = clientResultList.FirstOrDefault();

                        if (clientResult.ClientCompanyName.ToLower().Equals(answer.ToLower()))
                        {
                            // Check client company exist, if yes update, else insert.
                            var createdClientCompany = _clientService.Create(clientResult);

                            //generate OTP and send to ticketsys user company's email
                            Random generator        = new Random();
                            var    verificationCode = generator.Next(0, 9999).ToString("D4");
                            // Add user
                            TicketSysUser user = new TicketSysUser {
                                UserFbId        = _senderInfo.id,
                                ClientCompanyId = createdClientCompany.Id,
                                CompanyId       = _company.Id, UserNickname = $"{_senderInfo.last_name} {_senderInfo.first_name}", Active = false, VerificationCode = verificationCode
                            };

                            _jiraUserMgmtService.Create(user);


                            conversation.Answered       = true;
                            conversation.AnswerFreeText = createdClientCompany.Id.ToString();
                            conversation.CreatedOn      = DateTime.Now;
                            _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                            // Ask for verification code
                            var testOTP = string.Empty;
                            if (answer == "ZTEST COMPANY")
                            {
                                testOTP = verificationCode;
                            }

                            await ConstructAndSendMessage(ConstructType.RequestVerificationCode, messageInfo : testOTP);

                            break;
                        }
                    }
                    conversation.CreatedOn = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    var comNotFoundMsg = JObject.FromObject(new
                    {
                        recipient = new { id = _senderInfo.senderConversationId },
                        message   = new { text = $"I'm sorry :( , we can't find your company in our system. Please enter the correct name or you may also contact {_company.contactEmail} for the company name." }
                    });

                    // Invalid input / no company found, please try again
                    await ConstructAndSendMessage(ConstructType.Retry, null, comNotFoundMsg);
                }
                else
                {
                    conversation.CreatedOn = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    // Invalid input / no company found, please try again
                    await ConstructAndSendMessage(ConstructType.Retry);
                }
                break;

            case (int)Question.VerificationCode:
                // Validate message (reported issue) e.g. min length
                if (!string.IsNullOrEmpty(answer))
                {
                    // Check previous conversation, get ClientCompanyGuid
                    List <ConversationData> qaConv = _conversationService.GetConversationList($"{_senderInfo.senderConversationId}~{_company.FbPageId}");
                    if (qaConv != null)
                    {
                        ConversationData verifyConv = qaConv.Where(x => x.LastQuestionAsked == (int)Question.CompanyName).FirstOrDefault();

                        // Check verification code
                        var TicketSysUser = _jiraUserMgmtService.Get(_senderInfo.id);

                        if (TicketSysUser.VerificationCode == answer)
                        {
                            // Check & Update ClientCompany to true
                            if (!TicketSysUser.Active)
                            {
                                TicketSysUser.Active = true;
                                _jiraUserMgmtService.Update(TicketSysUser.Id, TicketSysUser);
                            }


                            // Begin create ticket
                            await ConstructAndSendMessage(ConstructType.CreateTicket);
                        }
                        else
                        {
                            // Incorrect verification code. Try again or end conversation
                            conversation.CreatedOn = DateTime.Now;
                            _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                            var jObj = JObject.FromObject(new
                            {
                                recipient = new { id = _senderInfo.senderConversationId },
                                message   = new { text = $"Sorry, I didn't quite catch that. It seems like invalid option/answer." }
                            });

                            // Invalid input / no company found, please try again
                            await ConstructAndSendMessage(ConstructType.Retry, additionalMessage : jObj);
                        }
                    }
                    else
                    {
                        conversation.CreatedOn = DateTime.Now;
                        _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                        // Invalid input / no company found, please try again
                        await ConstructAndSendMessage(ConstructType.Retry);
                    }
                }
                else
                {
                    await ConstructAndSendMessage(ConstructType.NotImplemented);
                }
                break;

            case (int)Question.IssueApplicationName:
                // Validate message (reported issue) e.g. min length
                if (!string.IsNullOrEmpty(answer))
                {
                    conversation.Answered       = true;
                    conversation.AnswerFreeText = answer;
                    conversation.CreatedOn      = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    // Ask for description
                    await ConstructAndSendMessage(ConstructType.TicketDescription);
                }
                else
                {
                    conversation.CreatedOn = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    // Invalid input / no company found, please try again
                    await ConstructAndSendMessage(ConstructType.Retry);
                }
                break;

            case (int)Question.IssueDescription:
                // Validate message (reported issue) e.g. min length
                if (!string.IsNullOrEmpty(answer))
                {
                    conversation.Answered       = true;
                    conversation.AnswerFreeText = answer;
                    conversation.CreatedOn      = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    var conversationList = _conversationService.GetConversationList($"{_senderInfo.senderConversationId}~{_company.FbPageId}");

                    string jiraSummary     = conversationList.FirstOrDefault(x => x.LastQuestionAsked == (int)Question.IssueApplicationName).AnswerFreeText;
                    string jiraDescription = conversationList.FirstOrDefault(x => x.LastQuestionAsked == (int)Question.IssueDescription).AnswerFreeText;

                    // Show case summary & ask for creation confirmation
                    await ConstructAndSendMessage(ConstructType.TicketCreationConfirmation, new CaseDetail { Subject = $"Issue in {jiraSummary}", Detail = jiraDescription });
                }
                else
                {
                    conversation.CreatedOn = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    // Invalid input / no company found, please try again
                    await ConstructAndSendMessage(ConstructType.Retry);
                }
                break;

            case (int)Question.TicketCode:
                // Validate message (reported issue) e.g. min length
                if (!string.IsNullOrEmpty(answer))
                {
                    // Jira integration here
                    // Search ticket status

                    CaseDetail caseDetail = null;
                    try
                    {
                        List <TicketSysUser> ticketSysUserList = _jiraUserMgmtService.Get();
                        var ticketSysUser = ticketSysUserList.Where(x => x.UserFbId == _senderInfo.senderConversationId).FirstOrDefault();

                        var clientCompany = _clientService.GetById(ticketSysUser.ClientCompanyId);

                        caseDetail = await _caseMgmtService.GetCaseStatusAsync(_company, clientCompany.TicketSysCompanyCode, answer);
                    }
                    catch { }

                    if (caseDetail != null)
                    {
                        conversation.Answered       = true;
                        conversation.AnswerFreeText = answer;
                        conversation.CreatedOn      = DateTime.Now;
                        _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                        await ConstructAndSendMessage(ConstructType.TicketFound, caseDetail);
                    }
                    else
                    {
                        conversation.CreatedOn = DateTime.Now;
                        _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                        var reply = JObject.FromObject(new
                        {
                            recipient = new { id = _senderInfo.senderConversationId },
                            message   = new { text = $"Looks like you have entered a wrong ticket code 😟" }
                        });
                        // Invalid input / no company found, please try again
                        await ConstructAndSendMessage(ConstructType.Retry, additionalMessage : reply);
                    }
                }
                else
                {
                    conversation.CreatedOn = DateTime.Now;
                    _conversationService.UpsertActiveConversation($"{_senderInfo.senderConversationId}~{_company.FbPageId}", conversation);

                    // Invalid input / no company found, please try again
                    await ConstructAndSendMessage(ConstructType.Retry);
                }
                break;

            default:
                break;
            }
        }
Example #5
0
        private Statement ParseLuisResult(ComplexModel luisResult, ConversationData conversationData)
        {
            string    addedStatementMessageText = "";
            string    text     = "";
            _Entities Entities = luisResult.Entities;

            _Entities.ClauseClass firstClause = Entities?.clause?.FirstOrDefault();
            _Entities.ValueClass  firstValue  = firstClause?.value?.FirstOrDefault();
            string referral = firstClause?.referral?.FirstOrDefault();
            string property = firstClause?.property?.FirstOrDefault();

            string[] values         = { firstValue?.date?.FirstOrDefault()?.Expressions?.FirstOrDefault()?.ToString() ?? firstValue?.geography?.FirstOrDefault()?.ToString() ?? firstValue?.number?.FirstOrDefault().ToString() ?? firstValue?.personName?.FirstOrDefault() ?? firstValue?.text?.FirstOrDefault() };
            string   objectType     = firstClause?.subject?.FirstOrDefault();
            bool     negated        = firstClause?.negated?.FirstOrDefault() != null;
            bool     bigger         = firstClause?.bigger?.FirstOrDefault() != null;
            bool     smaller        = firstClause?.smaller?.FirstOrDefault() != null;
            bool     multipleValues = false;
            bool     dateValues     = false;

            if (firstValue != null && (firstValue?.date != null || firstValue?.daterange != null) || Entities?.datetime != null && firstValue.isEmpty())
            {
                dateValues = true;
            }

            if (dateValues)
            {
                List <string> vals = new List <string>();
                if (firstValue?.date != null)
                {
                    var dateString = firstValue.date?.FirstOrDefault()?.Expressions?.FirstOrDefault();
                    if (!DateTime.TryParse(dateString, out DateTime date))
                    {
                        var    resolution = TimexResolver.Resolve(new[] { dateString });
                        string dateStart  = resolution.Values[0].Start;
                        string dateEnd    = resolution.Values[0].End;
                        if (!DateTime.TryParse(dateStart, out DateTime date1))
                        {
                            throw new Exception("Can't convert the given string to DateTime!");
                        }
                        if (!DateTime.TryParse(dateEnd, out DateTime date2))
                        {
                            throw new Exception("Can't convert the given string to DateTime!");
                        }
                        vals.Add(date1.ToShortDateString());
                        vals.Add(date2.ToShortDateString());
                        multipleValues = true;
                    }
                    else
                    {
                        vals.Add(date.ToShortDateString());
                    }

                    values = vals.ToArray();
                }
                else if (firstValue?.daterange != null)
                {
                    var    dateRangeString = firstValue.daterange?.FirstOrDefault()?.Expressions?.FirstOrDefault();
                    var    resolution      = TimexResolver.Resolve(new[] { dateRangeString });
                    string dateStart       = resolution.Values[0].Start;
                    string dateEnd         = resolution.Values[0].End;
                    if (!DateTime.TryParse(dateStart, out DateTime date1))
                    {
                        throw new Exception("Can't convert the given string to DateTime!");
                    }
                    if (!DateTime.TryParse(dateEnd, out DateTime date2))
                    {
                        throw new Exception("Can't convert the given string to DateTime!");
                    }
                    vals.Add(date1.ToShortDateString());
                    vals.Add(date2.ToShortDateString());

                    values         = vals.ToArray();
                    multipleValues = true;
                }
            }

            if (firstClause?.around?.FirstOrDefault() != null && !dateValues)
            {
                List <string> vals = new List <string>();
                vals.Add((firstValue?.number?.First() * 0.8).ToString());
                vals.Add((firstValue?.number?.First() * 1.2).ToString());

                values         = vals.ToArray();
                multipleValues = true;
            }
            else if (firstClause?.between?.FirstOrDefault() != null && !dateValues)
            {
                List <string> vals = new List <string>();
                vals.Add((firstValue?.number?.First()).ToString());
                vals.Add((firstValue?.number?.Last()).ToString());

                if (vals.Count > 1)
                {
                    multipleValues = true;
                }

                values = vals.ToArray();
            }

            if (!string.IsNullOrEmpty(property) && string.IsNullOrEmpty(values.FirstOrDefault()))
            {
                Statement s = new Statement();
                s.ResponseText = "I didn't understand the value, please give me the whole sentence again, but try putting the value between quotation marks!";
                s.ParseError   = true;
                return(s);
            }

            if (string.IsNullOrEmpty(property))
            {
                Statement s = new Statement();
                s.ResponseText = "I didn't understand the property, please enter another constraint!";
                s.ParseError   = true;
                return(s);
            }

            string optionalNegate        = negated ? "not " : "";
            string optionalSmallerBigger = smaller ? "smaller than " : (bigger ? "bigger than " : "");
            string optionalBetween       = multipleValues ? "between " : "";
            string optionalSecondValue   = multipleValues ? " and " + values.LastOrDefault() : "";

            if (string.IsNullOrEmpty(conversationData.SpecifiedObjectType) && objectType == null)
            {
                Statement s = new Statement();
                if (string.IsNullOrEmpty(objectType))
                {
                    s.ResponseText = "The type of the object was not specified, please enter another constraint containing it!";
                    s.ParseError   = true;
                    return(s);
                }
                else if (objectType.Equals("he") || objectType.Equals("she") || objectType.Equals("his") || objectType.Equals("her") || objectType.Equals("its") || objectType.Equals("it"))
                {
                    s.ResponseText = $"I don't know what you are referring to by \"{objectType}\", please enter another contstraint containing the type of the object you are looking for!";
                    s.ParseError   = true;
                    return(s);
                }
                else
                {
                    //query.ObjectType = objectType;
                    addedStatementMessageText = $"A {objectType}, got it!" + Environment.NewLine +
                                                $"Recognised {property}: {optionalNegate}{optionalSmallerBigger}{optionalBetween}{values.FirstOrDefault()}{optionalSecondValue}." + Environment.NewLine +
                                                $"You can give me more sentences, with additional constraints.";
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(objectType) && !objectType.Equals(conversationData.SpecifiedObjectType))
                {
                    Statement s = new Statement();
                    s.ResponseText = $"You already specified the object type: \"{conversationData.SpecifiedObjectType}\", please enter another constraint and refer to the object by the given type!";
                    s.ParseError   = true;
                    return(s);
                }
                else
                {
                    addedStatementMessageText = $"Recognised {property}: {optionalNegate}{optionalSmallerBigger}{optionalBetween}{values.FirstOrDefault()}{optionalSecondValue}." + Environment.NewLine +
                                                $"You can continue adding constraints, or try executing the query!";
                }
            }

            Statement stmnt = new Statement
            {
                Property       = property,
                Value          = values,
                Text           = $"{ property }:  { optionalNegate }{ optionalSmallerBigger }{ optionalBetween }{ values.FirstOrDefault() }{ optionalSecondValue }",
                ResponseText   = addedStatementMessageText,
                Bigger         = bigger,
                Smaller        = smaller,
                Negated        = negated,
                MultipleValues = multipleValues,
                DateValues     = dateValues,
                Subject        = objectType,
                ParseError     = false
            };

            return(stmnt);
        }
    IEnumerator Sequence(ConversationData data)
    {
        // 해당 대화 이벤트에서 서로 주고받는
        // 대화 수 만큼 반복문을 돌림.
        for (int i = 0; i < data.list.Count; ++i)
        {
            // 대사마다 필요한 정보를 차례대로 불러온다.
            SpeakerData sd = data.list[i];

            // 대화상자의 위치를 지정한다. (왼쪽대화상자? 오른쪽 대화상자?)
            // 오른쪽은 Player, 왼쪽은 상대방
            ConversationPanel currentPanel
                = (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.MiddleLeft || sd.anchor == TextAnchor.LowerLeft) ? leftPanel : rightPanel;

            // ConversationPanel.Display 는
            // 대사 내용, 아바타 이미지, 화살표 연출 여부 등을
            // 처리한다.
            IEnumerator presenter = currentPanel.Display(sd);

            // Display 코루틴 재생
            // MoveNext() 는  yield return 을 받기 전까지만 재생시킨다.
            presenter.MoveNext();

            string show, hide;

            // 어떤 키값으로 UI 연출을 할 것인지 체크
            if (sd.anchor == TextAnchor.UpperLeft || sd.anchor == TextAnchor.UpperCenter || sd.anchor == TextAnchor.UpperRight)
            {
                show = ShowTop;
                hide = HideTop;
            }
            else
            {
                show = ShowBottom;
                hide = HideBottom;
            }

            // 처음 대화 상자가 나오면 아래에서 위로 올라오는 연출이
            // 진행된다.
            currentPanel.panel.SetPosition(hide, false);
            MovePanel(currentPanel, show);

            // MoveNext(); 를 다시 전달 받기 전에는
            // 아래 코드를 진행하지 않는다.
            yield return(null);

            // currentPanel.Display(sd);
            // 전달받은 SpeakerData의 모든 대화 내용을
            // 하나씩 출력하고 멈추고
            // 다시 MoveNext()가 호출될때까지 기다리는 것을
            // 반복한다.
            while (presenter.MoveNext())
            {
                yield return(null);
            }


            // 대사 내용이 종료되면
            // 해당 대화 상자를 아래로 내리는 연출을 진행한다.
            MovePanel(currentPanel, hide);

            // EasingControl의 completedEvent 이벤트에 델리게이트를 등록시킨다.
            transition.completedEvent += delegate(object sender, EventArgs e) {
                conversation.MoveNext();
            };


            yield return(null);
        }

        // 모든 대사가 종료되면 canvas를 비활성화
        canvas.gameObject.SetActive(false);

        // completedEvent 에 등록된
        // 델리게이트를 호출한다. (*씬을 바꾸는 함수가 등록될 예정)
        if (completeEvent != null)
        {
            completeEvent(this, EventArgs.Empty);
        }
    }
Example #7
0
 private void StartInteraction()
 {
     currConversation = nearbyNpcs[0].GetComponent <ConversationData>();
     dialog.StartDialog(currConversation);
     inConversation = true;
 }
 public GettingRequiredServiceDeliveryTimeDialog(ConversationData conversationData, UserData userProfile)
     : base(conversationData, userProfile)
 {
 }
Example #9
0
 public void Setup()
 {
     ApiRequestHandler = new ApiRequestHandler(new Mock <IRequestManager>().Object);
     OpenApiDocument   = new OpenApiDocument();
     UserConversation  = new ConversationData();
 }
 public ConfirmingServiceInfoDialog(ConversationData conversationData, UserData userProfile)
     : base(conversationData, userProfile)
 {
 }
 private void ReloadData()
 {
     Conversation_Data = DataMart.GetConversation(ConversationID);
     conversation      = ConversationManager.instance.CreateConversation(Conversation_Data);
 }
 private void Start()
 {
     Conversation_Data = DataMart.GetConversation(ConversationID);
 }
Example #13
0
    public void SaveConversation(ConversationData conversationData)
    {
        //Exit if no steps
        if (StepContainer.childCount <= 0)
        {
            return;
        }

        //Get Conversations NPCID
        conversationData.NPCID = int.Parse(NPCID.text);

        for (int stepObjectID = 0; stepObjectID < StepContainer.childCount; stepObjectID++)
        {
            //Step Data (for easy reference)
            StepData stepData = conversationData.StepData[stepObjectID];

            //Get Step Text
            conversationData.StepData[stepObjectID].Text = StepContainer.GetChild(stepObjectID).GetChild(2).GetComponent <TMP_InputField>().text;

            //Option Container
            Transform optionContainer = StepContainer.GetChild(stepObjectID).GetChild(3).GetChild(0).GetChild(0).transform;

            for (int option = 0; option < optionContainer.childCount; option++)
            {
                //Option Data (for easy reference)
                OptionData optionData = stepData.OptionData[option];

                //Get Option ID
                optionData.DestinationID = int.Parse(optionContainer.GetChild(option).GetChild(5).GetComponent <TMP_InputField>().text);

                //Get Option Text
                optionData.Text = optionContainer.GetChild(option).GetChild(4).GetComponent <TMP_InputField>().text;

                //Get Option Trigger
                if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 0)
                {
                    //Acceptance Trigger
                    optionData.Trigger = OptionTrigger.QuestAcceptance;
                }
                else if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 1)
                {
                    //Reward Trigger
                    optionData.Trigger = OptionTrigger.ObtainQuestReward;
                }
                else if (optionContainer.GetChild(option).GetChild(0).GetComponent <TMP_Dropdown>().value == 2)
                {
                    //No Trigger
                    optionData.Trigger = OptionTrigger.None;
                }

                //Get Option Value
                if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 0)
                {
                    //Value 1
                    optionData.ValueCheck       = CompanyValue.ValueOne;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 1)
                {
                    //Value 2
                    optionData.ValueCheck       = CompanyValue.ValueTwo;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 2)
                {
                    //Value 3
                    optionData.ValueCheck       = CompanyValue.ValueThree;
                    optionData.ValueCheckAmount = int.Parse(optionContainer.GetChild(option).GetChild(6).GetComponent <TMP_InputField>().text);
                }
                else if (optionContainer.GetChild(option).GetChild(2).GetComponent <TMP_Dropdown>().value == 3)
                {
                    //No Value
                    optionData.ValueCheck       = CompanyValue.NULL;
                    optionData.ValueCheckAmount = -1;
                }
            }
        }

        if (DataMart.CheckConversationDataBase(conversationData.ID))
        {
            DataMart.RemoveConversation(conversationData.ID);
        }
        DataMart.AddConversation(conversationData);
        SaveButton.GetComponent <Image>().color = Color.green;
    }
Example #14
0
    private void RefreshConversationUI(ConversationData _conversation)
    {
        //Destroy existing UI Elements
        DestroyAllChildUIElements();

        //Clear all UI event listeners
        CreateStep.onClick.RemoveAllListeners();
        SaveButton.onClick.RemoveAllListeners();
        DeleteButton.onClick.RemoveAllListeners();

        //Add event to Create Step Button
        CreateStep.onClick.AddListener(delegate { CreateNewStep(_conversation); });

        //Add event to Save Conversation Button
        SaveButton.onClick.AddListener(delegate { SaveConversation(_conversation); });

        //Delete button
        DeleteButton.onClick.AddListener(delegate { DeleteConversation(_conversation); });

        //Set conversation IDs from data
        ID.text    = _conversation.ID.ToString();
        NPCID.text = _conversation.NPCID.ToString();

        foreach (StepData _step in _conversation.StepData)
        {
            //Create new Step UI Object
            GameObject stepPrefab = Instantiate(StepPrefab, StepContainer);

            //Step Conponent Transforms (for easy reference)
            Transform optionContainer            = stepPrefab.transform.GetChild(3).GetChild(0).GetChild(0).transform;
            Transform fieldStepText              = stepPrefab.transform.GetChild(2);
            Transform fieldStepID                = stepPrefab.transform.GetChild(0);
            Transform fieldStepDeleteButton      = stepPrefab.transform.GetChild(4);
            Transform fieldStepCreatOptionButton = stepPrefab.transform.GetChild(1);

            //Set the UI Step ID
            fieldStepID.GetComponent <TextMeshProUGUI>().text = "ID: " + stepPrefab.transform.GetSiblingIndex();

            //Set the UI Step Text
            fieldStepText.GetComponent <TMP_InputField>().text = _step.Text;

            //Setup Delete Step button
            fieldStepDeleteButton.GetComponent <Button>().onClick.AddListener(delegate { DeleteStep(stepPrefab.gameObject, _conversation, _step); });

            //Setup Create Option button
            fieldStepCreatOptionButton.GetComponent <Button>().onClick.AddListener(delegate { CreateNewOption(_conversation, _step, optionContainer); });

            foreach (OptionData _option in _step.OptionData)
            {
                //Create new Step UI Object
                GameObject optionPrefab = Instantiate(OptionPrefab, optionContainer);

                //Option Component Transforms (for easy reference)
                Transform fieldDestinationInput = optionPrefab.transform.GetChild(5);
                Transform fieldTextInput        = optionPrefab.transform.GetChild(4);
                Transform fieldValueDropdown    = optionPrefab.transform.GetChild(2);
                Transform fieldValueInput       = optionPrefab.transform.GetChild(6);
                Transform fieldTriggerDropdown  = optionPrefab.transform.GetChild(0);
                Transform fieldDeleteButton     = optionPrefab.transform.GetChild(7);

                //Set the UI Option Text
                fieldTextInput.GetComponent <TMP_InputField>().text = _option.Text;

                //Set the UI Option Destination ID
                fieldDestinationInput.GetComponent <TMP_InputField>().text = _option.DestinationID.ToString();

                //Set the UI Option Value Check Amount
                fieldValueInput.GetComponent <TMP_InputField>().text = _option.ValueCheckAmount.ToString();

                //Setup Delete Option button
                fieldDeleteButton.GetComponent <Button>().onClick.AddListener(delegate { DeleteOption(optionPrefab.gameObject, _step, _option); });

                //Set the UI Option Tigger
                switch (_option.Trigger)
                {
                case OptionTrigger.None:
                    fieldTriggerDropdown.GetComponent <TMP_Dropdown>().value = 2;
                    break;

                case OptionTrigger.ObtainQuestReward:
                    fieldTriggerDropdown.GetComponent <TMP_Dropdown>().value = 1;
                    break;

                case OptionTrigger.QuestAcceptance:
                    fieldTriggerDropdown.GetComponent <TMP_Dropdown>().value = 0;
                    break;
                }

                //Set the UI Option Check
                switch (_option.ValueCheck)
                {
                case CompanyValue.NULL:
                    fieldValueDropdown.GetComponent <TMP_Dropdown>().value = 3;
                    break;

                case CompanyValue.ValueOne:
                    fieldValueDropdown.GetComponent <TMP_Dropdown>().value = 0;
                    break;

                case CompanyValue.ValueTwo:
                    fieldValueDropdown.GetComponent <TMP_Dropdown>().value = 1;
                    break;

                case CompanyValue.ValueThree:
                    fieldValueDropdown.GetComponent <TMP_Dropdown>().value = 2;
                    break;
                }
            }
        }
    }
Example #15
0
        public void RetrieveInteractions()
        {
            try
            {
                string strFilePath = "C:\\temp\\retrieve_interactions7.csv";

                DateTime fromForAggregates = new DateTime(2019, 10, 16, 01, 00, 00);
                DateTime toForAggregates   = fromForAggregates.AddDays(7);

                var interval = new Interval(fromForAggregates, toForAggregates);

                var result = GetConversationData(interval);

                var listConversation = new List <ConversationData>();

                foreach (var res in result)
                {
                    var conversation = new ConversationData();
                    conversation.ConversationId    = res.ConversationId;
                    conversation.ConversationStart = (DateTime)res.ConversationStart;
                    if (res.ConversationEnd != null)
                    {
                        conversation.ConversationEnd = (DateTime)res.ConversationEnd;
                    }

                    foreach (var div in res.DivisionIds)
                    {
                        conversation.DivisionIds = conversation.DivisionIds += div.ToString();
                    }


                    foreach (var participants in res.Participants)
                    {
                        foreach (var session in participants.Sessions)
                        {
                            conversation.Media = session.MediaType.Value.ToString();

                            if (session.Ani != null)
                            {
                                conversation.Ani = session.Ani;
                            }
                            if (session.Dnis != null)
                            {
                                conversation.Dnis = session.Dnis;
                            }

                            if (session.Metrics != null)
                            {
                                foreach (var metric in session.Metrics)
                                {
                                    conversation = UpdateConversationMetric(conversation, metric);
                                }
                            }
                        }
                        if (participants.Purpose.Equals("acd"))
                        {
                            conversation.Queue.Add(participants.ParticipantName);
                        }
                    }
                    listConversation.Add(conversation);
                }



                foreach (var listconv in listConversation)
                {
                    File.AppendAllText(strFilePath, listconv.ConversationId + ";" + listconv.ConversationStart + ";" + listconv.ConversationEnd + ";" + listconv.Ani + ";" + listconv.Media + ";" +
                                       listconv.Dnis + ";" + listconv.nConnected + ";" + listconv.tNotResponding + ";" + listconv.Rona + ";" + listconv.tIvr + ";" + listconv.DivisionIds + "\n");
                }
            }
            catch (Exception ex)
            {
                AddLog($"Error in RetrieveInteractions: {ex.Message}");
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #16
0
        public ConversationData UpdateConversationMetric(ConversationData conversation, AnalyticsSessionMetric metric)
        {
            //ConversationData conv = null;
            try
            {
                switch (metric.Name)
                {
                case "nConnected":
                    conversation.nConnected = (long)metric.Value;
                    break;

                case "nBlindTransferred":
                    conversation.nBlindTransferred = (long)metric.Value;
                    break;

                case "nConsult":
                    conversation.nConsult = (long)metric.Value;
                    break;

                case "nConsultTransferred":
                    conversation.nConsultTransferred = (long)metric.Value;
                    break;

                case "nError":
                    conversation.nError = (long)metric.Value;
                    break;

                case "nFlow":
                    conversation.nFlow = (long)metric.Value;
                    break;

                case "nFlowOutcome":
                    conversation.nFlowOutcome = (long)metric.Value;
                    break;

                case "nFlowOutcomeFailed":
                    conversation.nFlowOutcomeFailed = (long)metric.Value;
                    break;

                case "nOffered":
                    conversation.nOffered = (long)metric.Value;
                    break;

                case "nOutbound":
                    conversation.nOutbound = (long)metric.Value;
                    break;

                case "nOutboundAbandoned":
                    conversation.nOutboundAbandoned = (long)metric.Value;
                    break;

                case "nOutboundAttempted":
                    conversation.nOutboundAttempted = (long)metric.Value;
                    break;

                case "nOutboundConnected":
                    conversation.nOutboundConnected = (long)metric.Value;
                    break;

                case "nOverSla":
                    conversation.nOverSla = (long)metric.Value;
                    break;

                case "nStateTransitionError":
                    conversation.nStateTransitionError = (long)metric.Value;
                    break;

                case "nTransferred":
                    conversation.nTransferred = (long)metric.Value;
                    break;

                case "oSurveyQuestionGroupScore":
                    conversation.oSurveyQuestionGroupScore = (long)metric.Value;
                    break;

                case "oSurveyQuestionScore":
                    conversation.oSurveyQuestionScore = (long)metric.Value;
                    break;

                case "oSurveyTotalScore":
                    conversation.oSurveyTotalScore = (long)metric.Value;
                    break;

                case "oTotalCriticalScore":
                    conversation.oTotalCriticalScore = (long)metric.Value;
                    break;

                case "oTotalScore":
                    conversation.oTotalScore = (long)metric.Value;
                    break;

                case "tAbandon":
                    conversation.tAbandon = (long)metric.Value;
                    break;

                case "tAcd":
                    conversation.tAcd = (long)metric.Value;
                    break;

                case "tAcw":
                    conversation.tAcw = (long)metric.Value;
                    break;

                case "tAgentResponseTime":
                    conversation.tAgentResponseTime = (long)metric.Value;
                    break;

                case "tAgentRoutingStatus":
                    conversation.tAgentRoutingStatus = (long)metric.Value;
                    break;

                case "tAlert":
                    conversation.tAlert = (long)metric.Value;
                    break;

                case "tAnswered":
                    conversation.tAnswered = (long)metric.Value;
                    break;

                case "tContacting":
                    conversation.tContacting = (long)metric.Value;
                    break;

                case "tDialing":
                    conversation.tDialing = (long)metric.Value;
                    break;

                case "tFlow":
                    conversation.tFlow = (long)metric.Value;
                    break;

                case "tFlowDisconnect":
                    conversation.tFlowDisconnect = (long)metric.Value;
                    break;

                case "tFlowExit":
                    conversation.tFlowExit = (long)metric.Value;
                    break;

                case "tFlowOut":
                    conversation.tFlowOut = (long)metric.Value;
                    break;

                case "tFlowOutcome":
                    conversation.tFlowOutcome = (long)metric.Value;
                    break;

                case "tHandle":
                    conversation.tHandle = (long)metric.Value;
                    break;

                case "tHeld":
                    conversation.tHeld = (long)metric.Value;
                    break;

                case "tHeldComplete":
                    conversation.tHeldComplete = (long)metric.Value;
                    break;

                case "tOrganizationPresence":
                    conversation.tOrganizationPresence = (long)metric.Value;
                    break;

                case "tIvr":
                    conversation.tIvr = conversation.tIvr += (long)metric.Value;
                    break;

                case "tTalk":
                    conversation.tTalk = (long)metric.Value;
                    break;

                case "tSystemPresence":
                    conversation.tSystemPresence = (long)metric.Value;
                    break;

                case "tTalkComplete":
                    conversation.tTalkComplete = (long)metric.Value;
                    break;

                case "tUserResponseTime":
                    conversation.tUserResponseTime = (long)metric.Value;
                    break;

                case "tWait":
                    conversation.tWait = conversation.tWait += (long)metric.Value;
                    break;

                case "tNotResponding":
                    conversation.tNotResponding = (long)metric.Value;
                    conversation.Rona           = 1;
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                AddLog($"Error in RetrieveInteractions: {ex.Message}");
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(conversation);
        }
 public void Show(ConversationData data)
 {
     canvas.gameObject.SetActive (true);
     conversation = Sequence (data);
     conversation.MoveNext ();
 }
 public override Task HandleIncomingUserResponseAsync(ITurnContext turnContext, CancellationToken cancellationToken)
 {
     ConversationData.ServiceBookingForm.RequiredServiceDescription = ConversationUtils.GetUserReply(turnContext);
     ConversationData.SetWaitingForUserInputFlag(false);
     return(Task.FromResult(0));
 }
Example #19
0
 public override void Enter()
 {
     base.Enter();
     data = Resources.Load <ConversationData>("Conversations/Test");
     conversationController.Show(data);
 }
        private object OnNpcConversationRespond(VehicleVendor vendor, BasePlayer player, ConversationData conversationData, ResponseNode responseNode)
        {
            CostLabelUI.Destroy(player);

            foreach (var intercepter in _responseIntercepters)
            {
                var forceNextSpeechNode = intercepter.Intercept(vendor, player, conversationData, responseNode);
                if (forceNextSpeechNode != string.Empty)
                {
                    ConversationUtils.ForceSpeechNode(vendor, player, forceNextSpeechNode);
                    return(false);
                }
            }

            return(null);
        }
        public async Task <ResponseModel> SendApiRequest(OpenApiDocument openApiDocument, ConversationData userConversation)
        {
            var requestModel = new RequestModel(openApiDocument.Servers[0].Url, userConversation.ApiPath, userConversation.OperationType);

            requestModel.RequestParamInPath  = userConversation.ParamsInfo.Where((parameter) => parameter.Value.ParamIn.Equals("path")).ToDictionary(key => key.Value.ParamName, value => value.Value.ParamValue);
            requestModel.RequestParamInQuery = userConversation.ParamsInfo.Where((parameter) => parameter.Value.ParamIn.Equals("query")).ToDictionary(key => key.Value.ParamName, value => value.Value.ParamValue);
            if (userConversation.OperationType == OperationType.Post && userConversation.RequestBody.Count > 0)
            {
                requestModel.ContentType = "application/json";
                requestModel.RequestBody = userConversation.RequestBody["userBody"];
            }
            // For testing SendAPIRequest
            //UpdateRequestModelForDummyAPITest(requestModel);

            return(await RequestManager.SendRequestAsync(requestModel));
        }
 public abstract string Intercept(NPCTalking npcTalking, BasePlayer player, ConversationData conversationData, ResponseNode responseNode);
Example #23
0
 public GetMonthDialog(ConversationData conversationData, UserData userProfile)
     : base(conversationData, userProfile)
 {
 }
            public override string Intercept(NPCTalking npcTalking, BasePlayer player, ConversationData conversationData, ResponseNode responseNode)
            {
                int vanillaPrice;

                if (!ConversationUtils.PrecedesPaymentOption(conversationData, responseNode, _matchResponseAction, out vanillaPrice))
                {
                    return(string.Empty);
                }

                var priceConfig = _getVehicleConfig().GetPriceForPlayer(player.IPlayer, _freePermission);

                if (priceConfig == null || priceConfig.MatchesVanillaPrice(vanillaPrice))
                {
                    return(string.Empty);
                }

                var neededScrap           = PlayerInventoryUtils.GetPlayerNeededScrap(player, vanillaPrice);
                var canAffordVanillaPrice = neededScrap <= 0;
                var canAffordCustomPrice  = priceConfig.CanPlayerAfford(player);

                CostLabelUI.Create(player, priceConfig);

                if (canAffordCustomPrice == canAffordVanillaPrice)
                {
                    return(string.Empty);
                }

                if (!canAffordCustomPrice)
                {
                    // Reduce scrap that will be removed to just below the amount they need for vanilla.
                    neededScrap--;
                }

                // Add or remove scrap so the vanilla logic for showing the payment option will match the custom payment logic.
                PlayerInventoryUtils.UpdateWithFakeScrap(player, neededScrap);

                // This delay needs to be long enough for the text to print out, which could vary by language.
                player.Invoke(() => PlayerInventoryUtils.Refresh(player), 3f);

                return(string.Empty);
            }
        private async Task <DialogTurnResult> StartAsync(DialogContext innerDc)
        {
            string response        = string.Empty;
            string botResponseType = string.Empty;
            string activityText    = string.Empty;
            string message         = innerDc.Context.Activity.Text;
            bool   isIntentFound   = false;

            message   = message.ToLower().Replace("bang", "bdc");
            userQuery = await _accessors.UserQueryAccessor.GetAsync(innerDc.Context, () => new UserQuery());

            ConversationData conversationData =
                await _accessors.ConversationDataAccessor.GetAsync(innerDc.Context, () => new ConversationData());

            // Get the LuisModel
            LuisResult luisResult = await LuisHelper.GetLuisResult(message, _config);

            // Making userquery to be null If user moves from one Module to another
            if (string.IsNullOrEmpty(userQuery.LuisIntent))
            {
                userQuery.LuisIntent = luisResult.TopScoringIntent.Intent;
            }
            if (!(luisResult.TopScoringIntent.Intent == userQuery.LuisIntent))
            {
                string eid = userQuery.EnterpriseId;
                userQuery = new UserQuery();
                userQuery.EnterpriseId = eid; eid = null;
                await _accessors.UserQueryAccessor.SetAsync(innerDc.Context, userQuery);

                await _accessors.UserState.SaveChangesAsync(innerDc.Context);

                luisResult = await LuisHelper.GetLuisResult(message, _config);
            }


            // Get the Entities and its values.
            GetUserData(luisResult, userQuery);
            await _accessors.UserQueryAccessor.SetAsync(innerDc.Context, userQuery);

            await _accessors.UserState.SaveChangesAsync(innerDc.Context);

            // Log LUIS Logs
            await _sqlLoggerRepository.InsertLuisLogs(innerDc.Context, luisResult, userQuery.EnterpriseId);

            //await innerDc.Context.GetUserQuery
            if ((luisResult.TopScoringIntent.Score > Convert.ToDouble(_config["Luis:Threshold"])) &&
                (luisResult.TopScoringIntent.Intent != null) &&
                (luisResult.TopScoringIntent.Intent != LuisConstants.NoneIntent))
            {
                //_ApiInput = new ApiInputDetails() { Input = Utilities.GetCorpusInput(innerDc.Context, luisResult), ApiIdentifier = "Luis" };
                //var res = LuisHelper.GetApiResponseAsync(_config, _ApiInput);
                switch (luisResult.TopScoringIntent.Intent)
                {
                case "GetAdhocRequestDetails":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(GetAdhocRequestDetails), luisResult);

                    break;

                case "ViewRoute":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(ViewRoute), luisResult);

                    break;

                case "GetScheduleDetails":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(ViewSchedule), luisResult);

                    break;

                case "ViewOTP":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(ViewOTP), luisResult);

                    break;

                case "CancelTrip":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(CancelTrip), luisResult);

                    break;

                case "GetAdhocStatus":
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(AdhocStatus), luisResult);

                    break;

                default:
                    isIntentFound = true;
                    await innerDc.BeginDialogAsync(nameof(NoneHandle), luisResult);

                    break;
                }
            }
            else
            {
                isIntentFound = true;
                await innerDc.BeginDialogAsync(nameof(NoneHandle), luisResult);
            }
            //await _sqlLoggerRepository.InsertBotLogAsync(innerDc.Context.Activity, taskResultNonLuis);

            return(await innerDc.EndDialogAsync(result : isIntentFound));
        }
            public override string Intercept(NPCTalking npcTalking, BasePlayer player, ConversationData conversationData, ResponseNode responseNode)
            {
                if (responseNode.actionString != _matchResponseAction)
                {
                    return(string.Empty);
                }

                int vanillaPrice;

                if (!ConversationUtils.ResponseHasScrapPrice(responseNode, out vanillaPrice))
                {
                    return(string.Empty);
                }

                var priceConfig = _getVehicleConfig().GetPriceForPlayer(player.IPlayer, _freePermission);

                if (priceConfig == null || priceConfig.MatchesVanillaPrice(vanillaPrice))
                {
                    return(string.Empty);
                }

                var neededScrap           = PlayerInventoryUtils.GetPlayerNeededScrap(player, vanillaPrice);
                var canAffordVanillaPrice = neededScrap <= 0;
                var canAffordCustomPrice  = priceConfig.CanPlayerAfford(player);

                if (!canAffordCustomPrice)
                {
                    return(ConversationUtils.SpeechNodes.Goodbye);
                }

                // Add scrap so the vanilla checks will pass. Add full amount for simplicity.
                player.inventory.containerMain.AddItem(ItemManager.itemDictionary[ScrapItemId], vanillaPrice);

                // Check conditions just in case, to make sure we don't give free scrap.
                if (!responseNode.PassesConditions(player, npcTalking))
                {
                    _pluginInstance.LogError($"Price adjustment unexpectedly failed for price config (response: '{_matchResponseAction}', player: {player.userID}).");
                    player.inventory.containerMain.AddItem(ItemManager.itemDictionary[ScrapItemId], -vanillaPrice);
                    return(string.Empty);
                }

                priceConfig.TryChargePlayer(player, vanillaPrice);

                return(string.Empty);
            }
 protected override void Awake()
 {
     base.Awake();
     conversationController = owner.GetComponentInChildren <ConversationController>();
     data = Resources.Load <ConversationData>("Conversations/IntroScene");
 }
            public override string Intercept(NPCTalking npcTalking, BasePlayer player, ConversationData conversationData, ResponseNode responseNode)
            {
                int vanillaPrice;

                if (!ConversationUtils.PrecedesPaymentOption(conversationData, responseNode, _matchResponseAction, out vanillaPrice))
                {
                    return(string.Empty);
                }

                if (!_getVehicleConfig().RequiresPermission)
                {
                    return(string.Empty);
                }

                if (_pluginInstance.HasPermissionAny(player.UserIDString, Permission_Allow_All, _allowPermission))
                {
                    return(string.Empty);
                }

                _pluginInstance.ChatMessage(player, "Error.Vehicle.NoPermission");
                return(ConversationUtils.SpeechNodes.Goodbye);
            }
 void OnClickSelection(ConversationData conversationData)
 {
     conversationInfo.conversationData = conversationData;
     conversationInfo.dialoguOpened    = false;
     SubDialogueClose();
 }
Example #30
0
 partial void initData()
 {
     ProfileData.init();
     ConversationData.init();
 }
 public void Show(ConversationData data)
 {
     canvas.gameObject.SetActive(true);
     conversation = Sequence(data);
     conversation.MoveNext();
 }
Example #32
0
 public GreetingAndLanguageSelectionDialog(ConversationData conversationData, UserData userProfile)
     : base(conversationData, userProfile)
 {
 }
Example #33
0
 protected override void Awake()
 {
     base.Awake ();
     conversationController = owner.GetComponentInChildren<ConversationController>();
     data = Resources.Load<ConversationData>("Conversations/IntroScene");
 }
Example #34
0
 public SelectingUserIntentDialog(ConversationData conversationData, UserData userProfile)
     : base(conversationData, userProfile)
 {
 }