ActivityHandler Class
- java.
lang. Object - com.
microsoft. bot. builder. ActivityHandler
- com.
Implements
public class ActivityHandler
implements Bot
Constructor Summary
| Constructor | Description | |
|---|---|---|
| ActivityHandler() | ||
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
protected
Invoke |
createInvokeResponse(Object body)
Creates a success Invoke |
|
protected
java.util.concurrent.CompletableFuture<Adaptive |
onAdaptiveCardInvoke(TurnContext turnContext, AdaptiveCardInvokeValue invokeValue)
Invoked when the bot is sent an Adaptive Card Action Execute. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onCommandActivity(TurnContext turnContext)
Invoked when a command activity is received when the base behavior of onTurn(TurnContext turnContext) is used. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onCommandResultActivity(TurnContext turnContext)
Invoked when a Command |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onConversationUpdateActivity(TurnContext turnContext)
Invoked when a conversation update activity is received from the channel when the base behavior of onTurn(TurnContext turnContext) is used. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onEndOfConversationActivity(TurnContext turnContext)
Override this in a derived class to provide logic specific to Activity |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onEvent(TurnContext turnContext)
Invoked when an event other than tokens/response is received when the base behavior of onEventActivity(TurnContext turnContext) is used. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onEventActivity(TurnContext turnContext)
Invoked when an event activity is received from the connector when the base behavior of onTurn(TurnContext turnContext) is used. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onInstallationUpdate(TurnContext turnContext)
Override this in a derived class to provide logic specific to Activity |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onInstallationUpdateAdd(TurnContext turnContext)
Override this in a derived class to provide logic specific to Activity |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onInstallationUpdateRemove(TurnContext turnContext)
Override this in a derived class to provide logic specific to Activity |
|
protected
java.util.concurrent.CompletableFuture<Invoke |
onInvokeActivity(TurnContext turnContext)
Invoked when an invoke activity is received from the connector when the base behavior of on |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onMembersAdded(List<ChannelAccount> membersAdded, TurnContext turnContext)
Override this in a derived class to provide logic for when members other than the bot join the conversation, such as your bot's welcome logic. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onMembersRemoved(List<ChannelAccount> membersRemoved, TurnContext turnContext)
Override this in a derived class to provide logic for when members other than the bot leave the conversation, such as your bot's good-bye logic. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onMessageActivity(TurnContext turnContext)
Override this in a derived class to provide logic specific to ActivityTypes#MESSAGE activities, such as the conversational logic. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onMessageReactionActivity(TurnContext turnContext)
Invoked when an event activity is received from the connector when the base behavior of onTurn(TurnContext turnContext) is used. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onReactionsAdded(List<MessageReaction> messageReactions, TurnContext turnContext)
Override this in a derived class to provide logic for when reactions to a previous activity are added to the conversation. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onReactionsRemoved(List<MessageReaction> messageReactions, TurnContext turnContext)
Override this in a derived class to provide logic for when reactions to a previous activity are removed from the conversation. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onSignInInvoke(TurnContext turnContext)
Invoked when a 'signin/verify |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onTokenResponseEvent(TurnContext turnContext)
Invoked when a "tokens/response" event is received when the base behavior of onEventActivity(TurnContext turnContext) is used. |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
onTurn(TurnContext turnContext)
Called by the adapter (for example, a BotFrameworkAdapter) at runtime in order to process an inbound Activity. |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onTypingActivity(TurnContext turnContext)
Override this in a derived class to provide logic specific to Activity |
| protected java.util.concurrent.CompletableFuture<java.lang.Void> |
onUnrecognizedActivityType(TurnContext turnContext)
Invoked when an activity other than a message, conversation update, or event is received when the base behavior of onTurn(TurnContext turnContext) is used. |
Methods inherited from java.lang.Object
Constructor Details
ActivityHandler
public ActivityHandler()
Method Details
createInvokeResponse
protected InvokeResponse createInvokeResponse(Object body)
Creates a success InvokeResponse with the specified body.
Parameters:
Returns:
onAdaptiveCardInvoke
protected CompletableFuture
Invoked when the bot is sent an Adaptive Card Action Execute.
Parameters:
Returns:
adaptiveCard/action, it calls this method.onCommandActivity
protected CompletableFuture
Invoked when a command activity is received when the base behavior of onTurn(TurnContext turnContext) is used. Commands are requests to perform an action and receivers typically respond with one or more commandResult activities. Receivers are also expected to explicitly reject unsupported command activities.
Parameters:
Returns:
onCommandResultActivity
protected CompletableFuture
Invoked when a CommandResult activity is received when the base behavior of onTurn(TurnContext turnContext) is used. CommandResult activities can be used to communicate the result of a command execution.
Parameters:
Returns:
onConversationUpdateActivity
protected CompletableFuture
Invoked when a conversation update activity is received from the channel when the base behavior of onTurn(TurnContext turnContext) 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 onMembersAdded(List<ChannelAccount> membersAdded, TurnContext turnContext) if any users have been added or onMembersRemoved(List<ChannelAccount> membersRemoved, TurnContext turnContext) 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.
Parameters:
Returns:
onEndOfConversationActivity
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes.END_OF_CONVERSATION activities.
Parameters:
Returns:
onEvent
protected CompletableFuture
Invoked when an event other than tokens/response is received when the base behavior of onEventActivity(TurnContext turnContext) is used.
This method could optionally be overridden if the bot is meant to handle miscellaneous events.
By default, this method does nothing.
When the onEventActivity(TurnContext turnContext) method receives an event with a Activity#getName() other than `tokens/response`, it calls this method.
Parameters:
Returns:
onEventActivity
protected CompletableFuture
Invoked when an event activity is received from the connector when the base behavior of onTurn(TurnContext turnContext) is used.
Event activities can be used to communicate many different things.
By default, this method will call onTokenResponseEvent(TurnContext turnContext) if the activity's name is "tokens/response" or onEvent(TurnContext turnContext) otherwise. "tokens/response" event can be triggered by an com.microsoft.bot.schema.OAuthCard.
When the onTurn(TurnContext turnContext) method receives an event activity, it calls this method.
If the event Activity#getName is `tokens/response`, it calls onTokenResponseEvent(TurnContext turnContext) otherwise, it calls onEvent(TurnContext turnContext).
In a derived class, override this method to add logic that applies to all event activities. Add logic to apply before the specific event-handling logic before the call to the base class method. Add logic to apply after the specific event-handling logic after the call to the base class method.
Event activities communicate programmatic information from a client or channel to a bot. The meaning of an event activity is defined by the Activity#getName property, which is meaningful within the scope of a channel. A `tokens/response` event can be triggered by an com.microsoft.bot.schema.OAuthCard or an OAuth prompt.
Parameters:
Returns:
onInstallationUpdate
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes.InstallationUpdate activities.
Parameters:
Returns:
onInstallationUpdateAdd
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes.InstallationUpdate activities with 'action' set to 'add'.
Parameters:
Returns:
onInstallationUpdateRemove
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes.InstallationUpdate activities with 'action' set to 'remove'.
Parameters:
Returns:
onInvokeActivity
protected CompletableFuture
Invoked when an invoke activity is received from the connector when the base behavior of onTurn is used.
Invoke activities can be used to communicate many different things. By default, this method will call onSignInInvokeAsync if the activity's name is 'signin/verifyState' or 'signin/tokenExchange'.
A 'signin/verifyState' or 'signin/tokenExchange' invoke can be triggered by an OAuthCard.
Parameters:
Returns:
onMembersAdded
protected CompletableFuture
Override this in a derived class to provide logic for when members other than the bot join the conversation, such as your bot's welcome logic.
When the onConversationUpdateActivity(TurnContext turnContext) method receives a conversation update activity that indicates one or more users other than the bo are joining the conversation, it calls this method.
Parameters:
Returns:
onMembersRemoved
protected CompletableFuture
Override this in a derived class to provide logic for when members other than the bot leave the conversation, such as your bot's good-bye logic.
When the onConversationUpdateActivity(TurnContext turnContext) method receives a conversation update activity that indicates one or more users other than the bot are leaving the conversation, it calls this method.
Parameters:
Returns:
onMessageActivity
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes#MESSAGE activities, such as the conversational logic.
When the onTurn(TurnContext turnContext) method receives a message activity, it calls this method.
Parameters:
Returns:
onMessageReactionActivity
protected CompletableFuture
Invoked when an event activity is received from the connector when the base behavior of onTurn(TurnContext turnContext) is used.
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent activity. Message reactions are only supported by a few channels.
The activity that the message reaction corresponds to is indicated in the replyToId property. The value of this property is the activity id of a previously sent activity given back to the bot as the response from a send call.
When the onTurn(TurnContext turnContext) method receives a message reaction activity, it calls this method. If the message reaction indicates that reactions were added to a message, it calls onReactionsAdded(List<MessageReaction> messageReactions, TurnContext turnContext). If the message reaction indicates that reactions were removed from a message, it calls onReactionsRemoved(List<MessageReaction> messageReactions, TurnContext turnContext).
In a derived class, override this method to add logic that applies to all message reaction activities. Add logic to apply before the reactions added or removed logic before the call to the base class method. Add logic to apply after the reactions added or removed logic after the call to the base class.
Parameters:
Returns:
onReactionsAdded
protected CompletableFuture
Override this in a derived class to provide logic for when reactions to a previous activity are added to the conversation.
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent message on the conversation. Message reactions are supported by only a few channels. The activity that the message is in reaction to is identified by the activity's Activity#getReplyToId() property. The value of this property is the activity ID of a previously sent activity. When the bot sends an activity, the channel assigns an ID to it, which is available in the com.microsoft.bot.schema.ResourceResponse#getId of the result.
Parameters:
Returns:
onReactionsRemoved
protected CompletableFuture
Override this in a derived class to provide logic for when reactions to a previous activity are removed from the conversation.
Message reactions correspond to the user adding a 'like' or 'sad' etc. (often an emoji) to a previously sent message on the conversation. Message reactions are supported by only a few channels. The activity that the message is in reaction to is identified by the activity's Activity#getReplyToId() property. The value of this property is the activity ID of a previously sent activity. When the bot sends an activity, the channel assigns an ID to it, which is available in the com.microsoft.bot.schema.ResourceResponse#getId of the result.
Parameters:
Returns:
onSignInInvoke
protected CompletableFuture
Invoked when a 'signin/verifyState' or 'signin/tokenExchange' event is received when the base behavior of onInvokeActivity is used.
If using an OAuthPrompt, override this method to forward this Activity to the current dialog. By default, this method does nothing.
When the onInvokeActivity method receives an Invoke with a name of `tokens/response`, it calls this method.
If your bot uses the OAuthPrompt, forward the incoming Activity to the current dialog.
Parameters:
Returns:
onTokenResponseEvent
protected CompletableFuture
Invoked when a "tokens/response" event is received when the base behavior of onEventActivity(TurnContext turnContext) is used.
If using an OAuthPrompt, override this method to forward this Activity to the current dialog.
By default, this method does nothing.
When the onEventActivity(TurnContext turnContext) method receives an event with a Activity#getName() of `tokens/response`, it calls this method.
Parameters:
Returns:
onTurn
public CompletableFuture
Called by the adapter (for example, a BotFrameworkAdapter) at runtime in order to process an inbound Activity.
This method calls other methods in this class based on the type of the activity to process, which allows a derived class to provide type-specific logic in a controlled way.
In a derived class, override this method to add logic that applies to all activity types. Add logic to apply before the type-specific logic before the call to the base class onTurn(TurnContext turnContext) method. Add logic to apply after the type-specific logic after the call to the base class onTurn(TurnContext turnContext) method.
Parameters:
Returns:
onTypingActivity
protected CompletableFuture
Override this in a derived class to provide logic specific to ActivityTypes.Typing activities.
Parameters:
Returns:
onUnrecognizedActivityType
protected CompletableFuture
Invoked when an activity other than a message, conversation update, or event is received when the base behavior of onTurn(TurnContext turnContext) is used.
If overridden, this could potentially respond to any of the other activity types like com.microsoft.bot.schema.ActivityTypes#CONTACT_RELATION_UPDATE or com.microsoft.bot.schema.ActivityTypes#END_OF_CONVERSATION.
By default, this method does nothing.
When the onTurn(TurnContext turnContext) method receives an activity that is not a message, conversation update, message reaction, or event activity, it calls this method.
Parameters:
Returns: