microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Samples/Samples.BotBuilder/Program.cs
39lines · modecode
| 1 | using Microsoft.Bot.Builder.Integration.AspNet.Core; |
| 2 | using Microsoft.Teams.Api.Activities; |
| 3 | using Microsoft.Teams.Apps; |
| 4 | using Microsoft.Teams.Apps.Activities; |
| 5 | using Microsoft.Teams.Apps.Annotations; |
| 6 | using Microsoft.Teams.Apps.Extensions; |
| 7 | using Microsoft.Teams.Plugins.AspNetCore.DevTools.Extensions; |
| 8 | using Microsoft.Teams.Plugins.AspNetCore.Extensions; |
| 9 | |
| 10 | namespace Samples.BotBuilder; |
| 11 | |
| 12 | public static partial class Program |
| 13 | { |
| 14 | public static void Main(string[] args) |
| 15 | { |
| 16 | var builder = WebApplication.CreateBuilder(args); |
| 17 | builder.Services.AddTransient<Controller>(); |
| 18 | builder |
| 19 | .AddTeams() |
| 20 | .AddTeamsDevTools() |
| 21 | .AddBotBuilder<Bot, BotBuilderAdapter, ConfigurationBotFrameworkAuthentication>(); |
| 22 | |
| 23 | var app = builder.Build(); |
| 24 | |
| 25 | app.UseTeams(); |
| 26 | app.Run(); |
| 27 | } |
| 28 | |
| 29 | [TeamsController] |
| 30 | public class Controller |
| 31 | { |
| 32 | [Message] |
| 33 | public async Task OnMessage([Context] MessageActivity activity, [Context] IContext.Client client, [Context] Microsoft.Teams.Common.Logging.ILogger log) |
| 34 | { |
| 35 | await client.Typing(); |
| 36 | await client.Send($"hi from teams..."); |
| 37 | } |
| 38 | } |
| 39 | } |