コード例 #1
0
        private async Task <DialogTurnResult> ProcessActionAsync <T>(ITSMLuis.Intent intent, string dialogId, WaterfallStepContext stepContext, CancellationToken cancellationToken)
            where T : IActionInput
        {
            ITSMLuis result     = null;
            T        actionData = null;

            var ev = stepContext.Context.Activity.AsEventActivity();

            if (ev.Value is JObject eventValue)
            {
                actionData = eventValue.ToObject <T>();
                result     = actionData.CreateLuis();
            }

            var state = await _stateAccessor.GetAsync(stepContext.Context, () => new SkillState(), cancellationToken);

            state.DigestLuisResult(result, intent);
            state.IsAction = true;

            if (actionData != null)
            {
                actionData.ProcessAfterDigest(state);
            }

            // Don't confirm if provided in action
            var option = new BaseOption
            {
                ConfirmSearch = false,
            };

            return(await stepContext.BeginDialogAsync(dialogId, option, cancellationToken));
        }
コード例 #2
0
        public void DigestLuisResult(ITSMLuis luis, ITSMLuis.Intent topIntent)
        {
            ClearLuisResult();

            if (luis.Entities.TicketDescription != null)
            {
                TicketDescription = string.Join(' ', luis.Entities.TicketDescription);
            }

            if (luis.Entities.CloseReason != null)
            {
                CloseReason = string.Join(' ', luis.Entities.CloseReason);
            }

            // TODO only the first one is considered now
            if (luis.Entities.UrgencyLevel != null)
            {
                UrgencyLevel = Enum.Parse <UrgencyLevel>(luis.Entities.UrgencyLevel[0][0], true);
            }

            if (luis.Entities.AttributeType != null)
            {
                AttributeType = Enum.Parse <AttributeType>(luis.Entities.AttributeType[0][0], true);
            }

            if (luis.Entities.TicketState != null)
            {
                TicketState = Enum.Parse <TicketState>(luis.Entities.TicketState[0][0], true);
            }

            if (luis.Entities.TicketNumber != null)
            {
                TicketNumber = luis.Entities.TicketNumber[0].ToUpper();
            }

            // TODO some special digestions
            if (topIntent == ITSMLuis.Intent.TicketUpdate)
            {
                // clear AttributeType if already set
                if (AttributeType == AttributeType.Description && !string.IsNullOrEmpty(TicketDescription))
                {
                    AttributeType = AttributeType.None;
                }
                else if (AttributeType == AttributeType.Urgency && UrgencyLevel != UrgencyLevel.None)
                {
                    AttributeType = AttributeType.None;
                }
            }
            else if (topIntent == ITSMLuis.Intent.TicketCreate)
            {
                DisplayExisting = true;
            }
            else if (topIntent == ITSMLuis.Intent.TicketShow)
            {
                AttributeType = AttributeType.None;
            }
        }