30 lines
992 B
C#
30 lines
992 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Bot.Builder;
|
|
using Microsoft.Bot.Builder.Integration.AspNet.Core;
|
|
|
|
namespace IAChat.Controllers;
|
|
|
|
// This ASP Controller is created to handle a request. Dependency Injection will provide the Adapter and IBot
|
|
// implementation at runtime. Multiple different IBot implementations running at different endpoints can be
|
|
// achieved by specifying a more specific type for the bot constructor argument.
|
|
[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, HttpGet]
|
|
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);
|
|
}
|
|
} |