microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/samples/AllFeatures/Program.cs
28lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Bot.Apps; |
| 5 | using Microsoft.Teams.Bot.Apps.Schema; |
| 6 | using Microsoft.Teams.Bot.Apps.Schema.Entities; |
| 7 | |
| 8 | var builder = TeamsBotApplication.CreateBuilder(); |
| 9 | var teamsApp = builder.Build(); |
| 10 | |
| 11 | teamsApp.OnMessage = async (messageArgs, context, cancellationToken) => |
| 12 | { |
| 13 | string replyText = $"You sent: `{messageArgs.Text}` in activity of type `{context.Activity.Type}`."; |
| 14 | |
| 15 | await context.SendTypingActivityAsync(cancellationToken); |
| 16 | |
| 17 | TeamsActivity reply = TeamsActivity.CreateBuilder() |
| 18 | .WithType(TeamsActivityType.Message) |
| 19 | .WithConversationReference(context.Activity) |
| 20 | .WithText(replyText) |
| 21 | .Build(); |
| 22 | |
| 23 | reply.AddMention(context.Activity.From!, "ridobotlocal", true); |
| 24 | |
| 25 | await context.TeamsBotApplication.SendActivityAsync(reply, cancellationToken); |
| 26 | }; |
| 27 | |
| 28 | teamsApp.Run(); |
| 29 | |