microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/samples/PABot/Bots/EchoBot.cs
25lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | // Copyright (c) Microsoft Corporation. |
| 5 | // Licensed under the MIT License. |
| 6 | |
| 7 | using Microsoft.Bot.Builder; |
| 8 | using Microsoft.Bot.Connector; |
| 9 | using Microsoft.Bot.Schema; |
| 10 | |
| 11 | namespace PABot.Bots |
| 12 | { |
| 13 | public class EchoBot : ActivityHandler |
| 14 | { |
| 15 | protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken) |
| 16 | { |
| 17 | await turnContext.SendActivityAsync(MessageFactory.Text($"Echo from TurnContext.SendActivityAsync: {turnContext.Activity.Text}"), cancellationToken); |
| 18 | |
| 19 | IConnectorClient connectorClient = turnContext.TurnState.Get<IConnectorClient>(); |
| 20 | Activity activity = MessageFactory.Text($"Echo from IConversations.SendToConversationAsync: {turnContext.Activity.Text}"); |
| 21 | activity.Conversation = new ConversationAccount { Id = turnContext.Activity.Conversation.Id }; |
| 22 | await connectorClient.Conversations.SendToConversationAsync(activity); |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |