简体   繁体   中英

Skill manifest endpoint missing while converting v4 bot to a custom skill

I'm trying to convert a v4 bot to custom skill. The bot with all the files is working as expected. But it is missing an /api/skill/manifest endpoint which is needed for connecting the skill to a virtual assistant.

updating the question

After making changes in the BotController.cs file my bot is throwing post 500 directline.PostACtivity error

Before editting BotControler.cs file was like this

[Route("api/messages")]
    [ApiController]
    public class BotController : ControllerBase
    {
        private readonly IBotFrameworkHttpAdapter Adapter;
        private readonly IBot Bot;

        public BotController(IBotFrameworkHttpAdapter adapter, IBot bot)
        {
            Adapter = adapter;
            Bot = bot;
        }

        [HttpPost]
        public async Task PostAsync()
        {
            // Delegate the processing of the HTTP POST to the adapter.
            // The adapter will invoke the bot.
            await Adapter.ProcessAsync(Request, Response, Bot);
        }
    } 

After changing it like this, bot is not responding

 [ApiController]
public class BotController : SkillController
{
    public BotController(IServiceProvider serviceProvider, BotSettingsBase botSettings)
        : base(serviceProvider, botSettings)
    { }
}

Also found an error here BotController.cs

在此处输入图像描述

Add packages

AddMicrosoft.Bot.Builder.Solutions and Microsoft.Bot.Builder.Skills NuGet packages.

Create a SkillAdapter

public class MySkillAdapter : SkillAdapter
{
    public MySkillAdapter(
        BotSettings settings,
        ICredentialProvider credentialProvider,
        BotStateSet botStateSet,
        ResponseManager responseManager,
        IBotTelemetryClient telemetryClient,
        UserState userState) : base(credentialProvider)
    {
        //
        Use(new SkillMiddleware(userState));
    }
}

Add transients to Startup.cs

services.AddTransient<IBotFrameworkHttpAdapter, DefaultAdapter>();
services.AddTransient<SkillAdapter, MySkillAdapter>();

Update BotController.cs

Now you can update your controller to derive from SkillController which contains api/skill/messages and api/skill/manifest endpoints.

[ApiController]
public class BotController : SkillController
{
  public BotController(IServiceProvider serviceProvider, BotSettingsBase botSettings)
      : base(serviceProvider, botSettings)
  { }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM