I have a ASP.NET Core project with only Controllers (WebAPI). I realized that Microsoft Bot is only a middleware for an ASP.NET server, it is even defined in the WebHost startup methods.
Can I take an existing project and add to it the middleware of the bot? Will it retain the ability to access endpoints directly using REST?
Absolutely, this is 100% possible and was one of the goals of the integration layer from day one.
The one thing you want to make sure is that you place your .UseBotFramework()
call before the .UseMvc()
call so that it takes priority on processing the request and so that the default MVC routes don't take over and swallow the request.
I would suggest the following order for a basic web app that has static files, a bot and MVC controllers:
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles()
.UseStaticFiles()
.UseBotFramework()
.UseMvc();
}