Microsoft Botframework V4虚拟助手Azure AD身份验证

时间:2019-01-27 18:20:42

标签: azure-active-directory botframework

我已从GitHub https://github.com/Microsoft/AI

下载并配置了Microsoft Virtual Assistant开源项目。

我想从日历技能入手,并配置了所有内容。 当我请求当前的日历条目时,身份验证提示会显示在botframework模拟器中,并且我可以使用我的Azure AD帐户进行身份验证。

在那之后,寂静无声...

在CalendarSkill中的SummaryDialog.cs中,有一个WaterfallStep的定义,如下所示:

    var showSummary = new WaterfallStep[]
    {
        GetAuthToken,
        AfterGetAuthToken,
        ShowEventsSummary,
        CallReadEventDialog,
        AskForShowOverview,
        AfterAskForShowOverview
    };

执行GetAuthToken步骤,但随后执行停止。完全不调用AfterGetAuthToken。

这是项目内的GetAuthToken函数:

protected async Task<DialogTurnResult> GetAuthToken(WaterfallStepContext sc, CancellationToken cancellationToken)
{
    try
    {
       var skillOptions = (CalendarSkillDialogOptions)sc.Options;

        // If in Skill mode we ask the calling Bot for the token
       if (skillOptions != null && skillOptions.SkillMode)
        {
            // We trigger a Token Request from the Parent Bot by sending a "TokenRequest" event back and then waiting for a "TokenResponse"
            // TODO Error handling - if we get a new activity that isn't an event
            var response = sc.Context.Activity.CreateReply();
            response.Type = ActivityTypes.Event;
            response.Name = "tokens/request";

            // Send the tokens/request Event
            await sc.Context.SendActivityAsync(response);

            // Wait for the tokens/response event
            return await sc.PromptAsync(SkillModeAuth, new PromptOptions());
        }
        else
        {
            return await sc.PromptAsync(nameof(MultiProviderAuthDialog), new PromptOptions());
        }
    }
    catch (SkillException ex)
    {
        await HandleDialogExceptions(sc, ex);
        return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
    }
    catch (Exception ex)
    {
        await HandleDialogExceptions(sc, ex);
        return new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs);
    }
}

我在代码中做错了什么吗?还是我的配置中缺少了什么?

1 个答案:

答案 0 :(得分:1)

我发现,如果ngrok不在PC上并且没有配置,则虚拟Assistatn无法正常工作。