ActivityHandler.OnConversationUpdateActivityAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Invoked when a conversation update activity is received from the channel when the base behavior of OnTurnAsync(ITurnContext, CancellationToken) is used. Conversation update activities are useful when it comes to responding to users being added to or removed from the conversation. For example, a bot could respond to a user being added by greeting the user. By default, this method will call OnMembersAddedAsync(IList<ChannelAccount>, ITurnContext<IConversationUpdateActivity>, CancellationToken) if any users have been added or OnMembersRemovedAsync(IList<ChannelAccount>, ITurnContext<IConversationUpdateActivity>, CancellationToken) if any users have been removed. The method checks the member ID so that it only responds to updates regarding members other than the bot itself.
protected virtual System.Threading.Tasks.Task OnConversationUpdateActivityAsync (Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IConversationUpdateActivity> turnContext, System.Threading.CancellationToken cancellationToken);
abstract member OnConversationUpdateActivityAsync : Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IConversationUpdateActivity> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.OnConversationUpdateActivityAsync : Microsoft.Bot.Builder.ITurnContext<Microsoft.Bot.Schema.IConversationUpdateActivity> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Protected Overridable Function OnConversationUpdateActivityAsync (turnContext As ITurnContext(Of IConversationUpdateActivity), cancellationToken As CancellationToken) As Task
Parameters
- turnContext
- ITurnContext<IConversationUpdateActivity>
A strongly-typed context object for this turn.
- cancellationToken
- CancellationToken
A cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
A task that represents the work queued to execute.
Remarks
When the OnTurnAsync(ITurnContext, CancellationToken) method receives a conversation update activity, it calls this method. If the conversation update activity indicates that members other than the bot joined the conversation, it calls OnMembersAddedAsync(IList<ChannelAccount>, ITurnContext<IConversationUpdateActivity>, CancellationToken). If the conversation update activity indicates that members other than the bot left the conversation, it calls OnMembersRemovedAsync(IList<ChannelAccount>, ITurnContext<IConversationUpdateActivity>, CancellationToken).
In a derived class, override this method to add logic that applies to all conversation update activities. Add logic to apply before the member added or removed logic before the call to the base class OnConversationUpdateActivityAsync(ITurnContext<IConversationUpdateActivity>, CancellationToken) method. Add logic to apply after the member added or removed logic after the call to the base class OnConversationUpdateActivityAsync(ITurnContext<IConversationUpdateActivity>, CancellationToken) method.