Пример #1
0
        public SkillService IdentifyRegisteredSkill(string skillName)
        {
            SkillService matchedSkill = null;

            // Did we find any skills?
            if (_registeredSkills != null)
            {
                // Identify a skill by taking the LUIS model name identified by the dispatcher and matching to the skill luis model name
                // Bug raised on dispatcher to move towards LuisModelId instead perhaps?
                matchedSkill = _registeredSkills.FirstOrDefault(s => s.DispatchIntent == skillName);
                return(matchedSkill);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var skillDialogOptions = (SkillDialogOptions)options;

            _skill = skillDialogOptions.MatchedSkill;

            // Set our active Skill so later methods know which Skill to use.
            dc.ActiveDialog.State[ActiveSkillStateKey] = skillDialogOptions.MatchedSkill;

            _authPrompt = new OAuthPrompt(nameof(OAuthPrompt), new OAuthPromptSettings()
            {
                ConnectionName = skillDialogOptions.MatchedSkill.AuthConnectionName,
                Title          = "Skill Authentication",
                Text           = $"Please login to access this feature.",
            });

            var parameters = new Dictionary <string, object>();

            if (skillDialogOptions.MatchedSkill.Parameters != null)
            {
                foreach (var parameter in skillDialogOptions.MatchedSkill.Parameters)
                {
                    if (skillDialogOptions.Parameters.TryGetValue(parameter, out var paramValue))
                    {
                        parameters.Add(parameter, paramValue);
                    }
                }
            }

            var skillMetadata = new SkillMetadata(
                skillDialogOptions.LuisResult,
                skillDialogOptions.LuisService,
                skillDialogOptions.MatchedSkill.Configuration,
                parameters);

            var dialogBeginEvent = new Activity(
                type: ActivityTypes.Event,
                channelId: dc.Context.Activity.ChannelId,
                from: new ChannelAccount(id: dc.Context.Activity.From.Id, name: dc.Context.Activity.From.Name),
                recipient: new ChannelAccount(id: dc.Context.Activity.Recipient.Id, name: dc.Context.Activity.Recipient.Name),
                conversation: new ConversationAccount(id: dc.Context.Activity.Conversation.Id),
                name: SkillBeginEventName,
                value: skillMetadata);

            return(await ForwardToSkill(dc, dialogBeginEvent));
        }