- Notifications
You must be signed in to change notification settings - Fork 843
/
Copy pathBotController.cs
41 lines (37 loc) · 1.62 KB
/
BotController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.6.2
usingMicrosoft.AspNetCore.Mvc;
usingMicrosoft.Bot.Builder;
usingMicrosoft.Bot.Builder.Integration.AspNet.Core;
usingSystem.Threading.Tasks;
namespaceCommandsMenu.Controllers
{
// BotController handles incoming HTTP POST requests and delegates them to the Bot Framework's adapter.
// It acts as an interface between incoming requests and the bot's processing logic.
[Route("api/messages")]
[ApiController]
publicclassBotController:ControllerBase
{
privatereadonlyIBotFrameworkHttpAdapteradapter;// Renamed Adapter to adapter (camelCase)
privatereadonlyIBotbot;// Renamed Bot to bot (camelCase)
// Initializes a new instance of the BotController.
// adapter: The bot framework HTTP adapter used to process requests.
// bot: The bot implementation that processes the incoming messages.
publicBotController(IBotFrameworkHttpAdapteradapter,IBotbot)
{
this.adapter=adapter;
this.bot=bot;
}
// Handles HTTP POST requests to process incoming bot messages.
// The method delegates the request processing to the bot framework's adapter.
[HttpPost]
publicasyncTaskPostAsync()
{
// Delegate the processing of the HTTP POST to the adapter.
// The adapter will invoke the bot and handle the response.
awaitadapter.ProcessAsync(Request,Response,bot);
}
}
}