DEV Community

Kenichiro Nakamura
Kenichiro Nakamura

Posted on

How to debug Bot Framework Skill locally or via Power Virtual Agent

Microsoft announced Bot Framework Skill (still in preview) last year, and now you can also call skills from Power Virtual Agent. It's straight forward to build the skill by following information here, but I couldn't find how to debug. So I share what I found so far.

Debug message type action

The message type action is exactly same as normal bot, so I simply use Bot Framework Emulator to debug it. No issues.

Debug event type action

There are two types of debug I want to try.

  • Local debug
  • Remote debug

Local debug

Let's start from local debug first. Currently I cannot create and send event type activity for action via Bot Framework emulator, but when I read about event here and looking at EventDebuggerMiddleware.cs, I realize I can simply send text message with following format.

/event:{name:"<ActionName>",value:"<Input parameter as json>"}

I also update IsSkill method in ITurnContextEx.cs to hack the function to return true when it comes via emulator and the activity type is event.

public static class ITurnContextEx
{
    public static bool IsSkill(this ITurnContext turnContext)
    {
        if (turnContext.Activity.Type == ActivityTypes.Event && turnContext.Activity.ChannelId == "emulator")
            return true;

        return turnContext.TurnState.Get<ClaimsIdentity>("BotIdentity") is ClaimsIdentity botIdentity && SkillValidation.IsSkillClaim(botIdentity.Claims) ? true : false;
    }
}

That's it. The following screens are taken when I debug out of box sample action. I specify "SampleAction" as action name, and input by following input type.

image.png

Remote debug

I also want to debug the skill when it's called via assistant bot or Power Virtual Agent. As PVA has a bit more steps, I share the step to debug via PVA.

1. Run ngrok to create public host.

ngrok http --host-header=localhost:3987 3978

2. Update manifest-1.0.json and enter ngrok https address.
image.png

3. Update "homepage" information of Azure AD application which I registered for the skill bot.
image.png

4. Remove existing skill and re-add the skill to PVA.
image.png

5. Place the breakpoint and test.
image.png

Happy debugging!

Top comments (0)