CoreBot class
Implements an instance of CoreBot.
- Extends
-
ActivityHandler
Inherited Methods
on |
Registers an activity event handler for the command activity. |
on |
Registers an activity event handler for the CommandResult activity. |
on |
Registers an activity event handler for the conversation update event, emitted for every incoming conversation update activity. |
on |
Registers an activity event handler for the dialog event, emitted as the last event for an incoming activity. |
on |
Registers an activity event handler for the end of conversation activity. |
on |
Registers an activity event handler for the event event, emitted for every incoming event activity. |
on |
Registers an activity event handler for the installationupdate activity. |
on |
Registers an activity event handler for the installationupdate add activity. |
on |
Registers an activity event handler for the installationupdate remove activity. |
on |
Registers an activity event handler for the members added event, emitted for any incoming conversation update activity that includes members added to the conversation. |
on |
Registers an activity event handler for the members removed event, emitted for any incoming conversation update activity that includes members removed from the conversation. |
on |
Registers an activity event handler for the message event, emitted for every incoming message activity. |
on |
Registers an activity event handler for the message reaction event, emitted for every incoming message reaction activity. |
on |
Registers an activity event handler for the reactions added event, emitted for any incoming message reaction activity that describes reactions added to a message. |
on |
Registers an activity event handler for the reactions removed event, emitted for any incoming message reaction activity that describes reactions removed from a message. |
on |
Registers an activity event handler for the tokens-response event, emitted for any incoming
|
on |
Registers an activity event handler for the turn event, emitted for every incoming activity, regardless of type. |
on |
Registers an activity event handler for the typing activity. |
on |
Registers an activity event handler for the unrecognized activity type event, emitted for an incoming activity with a type for which the ActivityHandler doesn't provide an event handler. |
run(Turn |
Called to initiate the event emission process. |
Constructor Details
CoreBot(ResourceExplorer, UserState, ConversationState, BotFrameworkAuthentication, SkillConversationIdFactoryBase, BotTelemetryClient, string, string, MemoryScope[], PathResolver[])
new CoreBot(resourceExplorer: ResourceExplorer, userState: UserState, conversationState: ConversationState, botFrameworkAuthentication: BotFrameworkAuthentication, skillConversationIdFactory: SkillConversationIdFactoryBase, botTelemetryClient: BotTelemetryClient, defaultLocale: string, defaultRootDialog: string, memoryScopes: MemoryScope[], pathResolvers: PathResolver[])
Parameters
- resourceExplorer
-
ResourceExplorer
Services to access resources.
- userState
-
UserState
Stored user state.
- conversationState
-
ConversationState
Stored conversation state.
- botFrameworkAuthentication
-
BotFrameworkAuthentication
Cloud environment to authenticate Bot Framework Protocol network calls within this environment.
- skillConversationIdFactory
-
SkillConversationIdFactoryBase
Methods to create unique conversation IDs for skill conversations.
- botTelemetryClient
-
BotTelemetryClient
Bot client to telemetry.
- defaultLocale
-
string
The default locale used to determine language-specific behavior.
- defaultRootDialog
-
string
Default bot root dialog.
- memoryScopes
-
MemoryScope[]
Named root-level objects, which can exist in the dialog context or outside the turn state.
- pathResolvers
-
PathResolver[]
Shortcut behavior for transform paths.
Inherited Method Details
onCommand(BotHandler)
Registers an activity event handler for the command activity.
function onCommand(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
To handle a Command event, use the onCommand type-specific event handler.
Inherited From ActivityHandler.onCommand
onCommandResult(BotHandler)
Registers an activity event handler for the CommandResult activity.
function onCommandResult(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
To handle a CommandResult event, use the onCommandResult type-specific event handler.
Inherited From ActivityHandler.onCommandResult
onConversationUpdate(BotHandler)
Registers an activity event handler for the conversation update event, emitted for every incoming conversation update activity.
function onConversationUpdate(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
Conversation update activities describe a changes to a conversation's metadata, such as title, participants, or other channel-specific information.
To handle when members are added to or removed from the conversation, use the onMembersAdded and onMembersRemoved sub-type event handlers.
Inherited From ActivityHandler.onConversationUpdate
onDialog(BotHandler)
Registers an activity event handler for the dialog event, emitted as the last event for an incoming activity.
function onDialog(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Inherited From ActivityHandler.onDialog
onEndOfConversation(BotHandler)
Registers an activity event handler for the end of conversation activity.
function onEndOfConversation(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
This activity is typically send from a Skill to a Skill caller indicating the end of that particular child conversation.
To handle an End of Conversation, use the onEndOfConversation type-specific event handler.
Inherited From ActivityHandler.onEndOfConversation
onEvent(BotHandler)
Registers an activity event handler for the event event, emitted for every incoming event activity.
function onEvent(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
Event activities communicate programmatic information from a client or channel to a bot. The meaning of an event activity is defined by the activity's name property, which is meaningful within the scope of a channel. Event activities are designed to carry both interactive information (such as button clicks) and non-interactive information (such as a notification of a client automatically updating an embedded speech model).
To handle a tokens/response
event event, use the
onTokenResponseEvent sub-type
event handler. To handle other named events, add logic to this handler.
Inherited From ActivityHandler.onEvent
onInstallationUpdate(BotHandler)
Registers an activity event handler for the installationupdate activity.
function onInstallationUpdate(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
To handle a InstallationUpdate event, use the onInstallationUpdate type-specific event handler.
Inherited From ActivityHandler.onInstallationUpdate
onInstallationUpdateAdd(BotHandler)
Registers an activity event handler for the installationupdate add activity.
function onInstallationUpdateAdd(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object. To handle a InstallationUpdateAdd event, use the onInstallationUpdateAdd type-specific event handler.
Inherited From ActivityHandler.onInstallationUpdateAdd
onInstallationUpdateRemove(BotHandler)
Registers an activity event handler for the installationupdate remove activity.
function onInstallationUpdateRemove(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
To handle a InstallationUpdateRemove event, use the onInstallationUpdateRemove type-specific event handler.
Inherited From ActivityHandler.onInstallationUpdateRemove
onMembersAdded(BotHandler)
Registers an activity event handler for the members added event, emitted for any incoming conversation update activity that includes members added to the conversation.
function onMembersAdded(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The activity's membersAdded property contains the members added to the conversation, which can include the bot.
To handle conversation update events in general, use the onConversationUpdate type-specific event handler.
Inherited From ActivityHandler.onMembersAdded
onMembersRemoved(BotHandler)
Registers an activity event handler for the members removed event, emitted for any incoming conversation update activity that includes members removed from the conversation.
function onMembersRemoved(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The activity's membersRemoved property contains the members removed from the conversation, which can include the bot.
To handle conversation update events in general, use the onConversationUpdate type-specific event handler.
Inherited From ActivityHandler.onMembersRemoved
onMessage(BotHandler)
Registers an activity event handler for the message event, emitted for every incoming message activity.
function onMessage(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
Message activities represent content intended to be shown within a conversational interface
and can contain text, speech, interactive cards, and binary or unknown attachments.
Not all message activities contain text, the activity's text
property can be null
or undefined
.
Inherited From ActivityHandler.onMessage
onMessageReaction(BotHandler)
Registers an activity event handler for the message reaction event, emitted for every incoming message reaction activity.
function onMessageReaction(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
Message reaction activities represent a social interaction on an existing message activity within a conversation. The original activity is referred to by the message reaction activity's replyToId property. The from property represents the source of the reaction, such as the user that reacted to the message.
To handle when reactions are added to or removed from messages in the conversation, use the onReactionsAdded and onReactionsRemoved sub-type event handlers.
Inherited From ActivityHandler.onMessageReaction
onReactionsAdded(BotHandler)
Registers an activity event handler for the reactions added event, emitted for any incoming message reaction activity that describes reactions added to a message.
function onReactionsAdded(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The activity's reactionsAdded property includes one or more reactions that were added.
To handle message reaction events in general, use the onMessageReaction type-specific event handler.
Inherited From ActivityHandler.onReactionsAdded
onReactionsRemoved(BotHandler)
Registers an activity event handler for the reactions removed event, emitted for any incoming message reaction activity that describes reactions removed from a message.
function onReactionsRemoved(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The activity's reactionsRemoved property includes one or more reactions that were removed.
To handle message reaction events in general, use the onMessageReaction type-specific event handler.
Inherited From ActivityHandler.onReactionsRemoved
onTokenResponseEvent(BotHandler)
Registers an activity event handler for the tokens-response event, emitted for any incoming
tokens/response
event activity. These are generated as part of the OAuth authentication flow.
function onTokenResponseEvent(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The activity's value property contains the user token.
If your bot handles authentication using an OAuthPrompt within a dialog, then the dialog will need to receive this activity to complete the authentication flow.
To handle other named events and event events in general, use the onEvent type-specific event handler.
Inherited From ActivityHandler.onTokenResponseEvent
onTurn(BotHandler)
Registers an activity event handler for the turn event, emitted for every incoming activity, regardless of type.
function onTurn(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Inherited From ActivityHandler.onTurn
onTyping(BotHandler)
Registers an activity event handler for the typing activity.
function onTyping(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
To handle a Typing event, use the onTyping type-specific event handler.
Inherited From ActivityHandler.onTyping
onUnrecognizedActivityType(BotHandler)
Registers an activity event handler for the unrecognized activity type event, emitted for an incoming activity with a type for which the ActivityHandler doesn't provide an event handler.
function onUnrecognizedActivityType(handler: BotHandler): this
Parameters
- handler
-
BotHandler
The event handler.
Returns
this
A reference to the ActivityHandler object.
Remarks
The ActivityHandler
does not define events for all activity types defined in the
Bot Framework Activity schema. In addition,
channels and custom adapters can create Activities with
types not in the schema. When the activity handler receives such an event, it emits an unrecognized activity type event.
The activity's type property contains the activity type.
Inherited From ActivityHandler.onUnrecognizedActivityType
run(TurnContext)
Called to initiate the event emission process.
function run(context: TurnContext): Promise<void>
Parameters
- context
-
TurnContext
The context object for the current turn.
Returns
Promise<void>
Remarks
Typically, you would provide this method as the function handler that the adapter calls to perform the bot's logic after the received activity has been pre-processed by the adapter and routed through any middleware.
For example:
server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Route to bot's activity logic.
await bot.run(context);
});
});
See also
Inherited From ActivityHandler.run