Created
March 3, 2022 00:05
-
-
Save sunnyy02/f97a3060f0d701323c955e681990648c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Bot.Builder; | |
using Microsoft.Bot.Builder.Adapters.Twilio; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace AppointmentBot.Controllers | |
{ | |
[Route("api/twilio")] | |
[ApiController] | |
public class TwilioController : ControllerBase | |
{ | |
private readonly TwilioAdapter _adapter; | |
private readonly IBot _bot; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="BotController"/> class. | |
/// </summary> | |
/// <param name="adapter">adapter for the BotController.</param> | |
/// <param name="bot">bot for the BotController.</param> | |
public TwilioController(TwilioAdapter adapter, IBot bot) | |
{ | |
_adapter = adapter; | |
_bot = bot; | |
} | |
/// <summary> | |
/// PostAsync method that returns an async Task. | |
/// </summary> | |
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns> | |
[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, default(CancellationToken)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment