Search code examples
azure-active-directorybotframework

Microsoft Botframework V4 Virtual Assistant Azure AD Authentication


I have downloaded, configured and deployed the Microsoft Virtual Assistant open source project from GitHub here: https://github.com/Microsoft/AI

I want to start with the calendar skill and have configured everything. When I request my current calendar entries, the authentication prompt is shown in the botframework emulator and I am able to authenticate with my Azure AD Account.

After that, there is silence...

In SummaryDialog.cs in the CalendarSkill there is a definition for a WaterfallStep like this:

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

The step GetAuthToken is executed, but then execution stops. AfterGetAuthToken is not called at all.

This is the GetAuthToken function inside the project:

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);
    }
}

Am I doing anything wrong in the code or is there anything missing in my configuration?


Solution

  • I found out, if ngrok is not on the PC and configured, the virtual Assistatn does not work.