In my application, I am using Azure Bot Service with MS Teams.
When I send a message from Azure Bot Service- Web Chat, I am getting a message from the bot, but when I reply with a response, the bot service doesn't receive it.
I don't want to use Bot framework, instead I am trying with the agent.
Since I am using MS Teams in the bot service, should I use the code below or prefer the 365 agent SDK or Teams SDK?
In the code below I am getting all details in response, but it's not received at the bot service.
return Results.Ok(response);
In program.cs file--
app.MapBotEndpoints();
and classes below
namespace AgentApp.Services
{
public interface IMessageService
{
Task HandleMessageAsync(Activity activity);
}
public class MessageService : IMessageService
{
public Task HandleMessageAsync(Activity activity)
{
var userMessage = activity.Text?.ToLower();
string reply = "Hi! This is your bot.";
// Build response for your custom bot
return Task.FromResult(new Activity
{
Type = "message",
Text = reply,
From = activity.Recipient,
Recipient = activity.From
});
}
}
}
namespace AgentApp.Endpoints
{
public static class BotEndpoints
{
public static void MapBotEndpoints(this WebApplication app)
{
app.MapPost("/api/messages", async (HttpContext context, IMessageService service) =>
{
var activity = await context.Request.ReadFromJsonAsync();
if (activity == null || activity.Type != "message")
return Results.Ok();
var response = await service.HandleMessageAsync(activity);
return Results.Ok(response);
});
}
}
}