Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Use this reference to find the handler registration syntax for Teams agent activities. For an introduction, see Activities and handlers.
The language-independent conversation update and installation update sections describe event scopes and payload fields. Event payload examples apply to all SDK languages.
Invoke handlers can require a response to Teams. The invoke examples throw a not-implemented exception instead of returning a success response without an implementation. Replace the exception with the appropriate response before using these handlers.
Event reference
Each table lists the activity Teams sends, the handler that receives it, and the type the handler receives. Rows under Invoke activities expect a response from the handler. Where a language has no dedicated handler for an activity, that language's section names the handler that still receives it.
The TeamsBotApplication class exposes extension methods for registering handlers. Methods return the application for fluent chaining. Each handler receives a Context<TActivity> and a CancellationToken.
teams.OnMessage(async (context, cancellationToken) =>
{
await context.SendAsync($"You said: {context.Activity.Text}", cancellationToken);
});
Message activities
| Event | Activity | Extension method | Context activity type | Description |
|---|---|---|---|---|
| Message received | message |
OnMessage(handler) |
MessageActivity |
Handle incoming messages. Also fires for messageUpdate, because MessageUpdateActivity derives from MessageActivity. |
| Message text matches a pattern | message |
OnMessage(pattern, handler), OnMessage(regex, handler) |
MessageActivity |
Handle messages whose text, with the agent's own @mention removed, matches a regular expression. Also fires for messageUpdate. |
| Message updated | messageUpdate |
OnMessageUpdate(handler) |
MessageUpdateActivity |
A message was edited or restored after deletion. |
| Message deleted | messageDelete |
OnMessageDelete(handler) |
MessageDeleteActivity |
A message was soft-deleted. |
| Reaction added or removed | messageReaction |
OnMessageReaction(handler) |
MessageReactionActivity |
One or more reactions changed. See Message reaction activities. |
| Reaction added | messageReaction with reactionsAdded |
OnMessageReactionAdded(handler) |
MessageReactionActivity |
One or more reactions were added. |
| Reaction removed | messageReaction with reactionsRemoved |
OnMessageReactionRemoved(handler) |
MessageReactionActivity |
One or more reactions were removed. |
Conversation update activities
All conversation update handlers receive ConversationUpdateActivity. For payload details, see conversationUpdate activities.
| Event | Activity | Extension method | Description |
|---|---|---|---|
| Any conversation update | conversationUpdate |
OnConversationUpdate(handler) |
Every conversation update activity. |
| Members added | membersAdded is not empty |
OnMembersAdded(handler) |
One or more members, including the agent itself, joined. |
| Members removed | membersRemoved is not empty |
OnMembersRemoved(handler) |
One or more members, including the agent itself, left. |
| Channel created | channelData.eventType: channelCreated |
OnChannelCreated(handler) |
A channel was created. |
| Channel deleted | channelData.eventType: channelDeleted |
OnChannelDeleted(handler) |
A channel was deleted. |
| Channel renamed | channelData.eventType: channelRenamed |
OnChannelRenamed(handler) |
A channel was renamed. |
| Channel restored | channelData.eventType: channelRestored |
OnChannelRestored(handler) |
A deleted channel was restored. |
| Channel shared | channelData.eventType: channelShared |
OnChannelShared(handler) |
A channel was shared with a team. |
| Channel unshared | channelData.eventType: channelUnshared |
OnChannelUnshared(handler) |
A channel was unshared from a team. |
| Channel member added | channelData.eventType: channelMemberAdded |
OnChannelMemberAdded(handler) |
A member was added to a channel. |
| Channel member removed | channelData.eventType: channelMemberRemoved |
OnChannelMemberRemoved(handler) |
A member was removed from a channel. |
| Team member added | channelData.eventType: teamMemberAdded |
OnTeamMemberAdded(handler) |
A member was added to the team. |
| Team member removed | channelData.eventType: teamMemberRemoved |
OnTeamMemberRemoved(handler) |
A member was removed from the team. |
| Team archived | channelData.eventType: teamArchived |
OnTeamArchived(handler) |
The team was archived. |
| Team unarchived | channelData.eventType: teamUnarchived |
OnTeamUnarchived(handler) |
The team was unarchived. |
| Team deleted | channelData.eventType: teamDeleted |
OnTeamDeleted(handler) |
The team was deleted. |
| Team renamed | channelData.eventType: teamRenamed |
OnTeamRenamed(handler) |
The team was renamed. |
| Team restored | channelData.eventType: teamRestored |
OnTeamRestored(handler) |
The deleted team was restored. |
Installation update activities
All installation update handlers receive InstallUpdateActivity. For details, see Installation update event details.
| Event | Activity | Extension method | Description |
|---|---|---|---|
| Any installation update | installationUpdate |
OnInstallUpdate(handler) |
Every installation update activity, including upgrades. |
| Agent installed | installationUpdate with action: add |
OnInstall(handler) |
The agent was installed. |
| Agent uninstalled | installationUpdate with action: remove |
OnUnInstall(handler) |
The agent was uninstalled. |
Event activities
| Event | Activity | Extension method | Context activity type | Description |
|---|---|---|---|---|
| Any event | event |
OnEvent(handler) |
EventActivity |
Every event activity. |
| Meeting started | event with name: application/vnd.microsoft.meetingStart |
OnMeetingStart(handler) |
EventActivity<MeetingStartValue> |
A meeting started. |
| Meeting ended | event with name: application/vnd.microsoft.meetingEnd |
OnMeetingEnd(handler) |
EventActivity<MeetingEndValue> |
A meeting ended. |
| Participant joined | event with name: application/vnd.microsoft.meetingParticipantJoin |
OnMeetingJoin(handler) |
EventActivity<MeetingParticipantJoinValue> |
A participant joined a meeting. |
| Participant left | event with name: application/vnd.microsoft.meetingParticipantLeave |
OnMeetingLeave(handler) |
EventActivity<MeetingParticipantLeaveValue> |
A participant left a meeting. |
| Agent lifecycle | event with name: agentLifecycle |
OnAgentLifecycle(handler) |
AgentLifecycleEventActivity |
Any agentic user lifecycle event. |
| Agentic user identity created | agentLifecycle with valueType: AgenticUserIdentityCreated |
OnAgenticUserIdentityCreated(handler) |
AgentLifecycleEventActivity<AgenticUserIdentityCreatedValue> |
An agentic user identity was created. |
| Agentic user identity updated | valueType: AgenticUserIdentityUpdated |
OnAgenticUserIdentityUpdated(handler) |
AgentLifecycleEventActivity<AgenticUserIdentityUpdatedValue> |
An agentic user identity was updated. |
| Agentic user manager updated | valueType: AgenticUserManagerUpdated |
OnAgenticUserManagerUpdated(handler) |
AgentLifecycleEventActivity<AgenticUserManagerUpdatedValue> |
The agentic user's manager changed. |
| Agentic user enabled | valueType: AgenticUserEnabled |
OnAgenticUserEnabled(handler) |
AgentLifecycleEventActivity<AgenticUserEnabledValue> |
The agentic user was enabled. |
| Agentic user disabled | valueType: AgenticUserDisabled |
OnAgenticUserDisabled(handler) |
AgentLifecycleEventActivity<AgenticUserDisabledValue> |
The agentic user was disabled. |
| Agentic user deleted | valueType: AgenticUserDeleted |
OnAgenticUserDeleted(handler) |
AgentLifecycleEventActivity<AgenticUserDeletedValue> |
The agentic user was deleted. |
| Agentic user restored | valueType: AgenticUserUndeleted |
OnAgenticUserUndeleted(handler) |
AgentLifecycleEventActivity<AgenticUserUndeletedValue> |
The deleted agentic user was restored. |
| Agentic user workload onboarding updated | valueType: AgenticUserWorkloadOnboardingUpdated |
OnAgenticUserWorkloadOnboardingUpdated(handler) |
AgentLifecycleEventActivity<AgenticUserWorkloadOnboardingUpdatedValue> |
The workload onboarding state changed. |
Invoke activities
Invoke handlers return an InvokeResponse. Only the first registered handler that matches an invoke runs. If no handler matches, the SDK responds with 501 Not Implemented.
Invoke name |
Extension method | Context activity type | Response type | Description |
|---|---|---|---|---|
| Any invoke | OnInvoke(handler) |
InvokeActivity |
InvokeResponse |
Every invoke activity. Can't be combined with any other invoke handler or with an OAuth flow. |
adaptiveCard/action |
OnAdaptiveCardAction(handler) |
InvokeActivity<AdaptiveCardActionValue> |
InvokeResponse |
An Adaptive Card Action.Execute action. Read Value.Action.Verb to identify the action. |
application/search |
OnSearch(handler) |
InvokeActivity<SearchValue> |
InvokeResponse<SearchResponse> |
An Adaptive Card Input.ChoiceSet dynamic search. |
task/fetch |
OnTaskFetch(handler) |
InvokeActivity<TaskModuleRequest> |
InvokeResponse<TaskModuleResponse> |
A dialog (task module) was opened. |
task/submit |
OnTaskSubmit(handler) |
InvokeActivity<TaskModuleRequest> |
InvokeResponse<TaskModuleResponse> |
A dialog (task module) was submitted. |
composeExtension/query |
OnQuery(handler) |
InvokeActivity<MessageExtensionQuery> |
InvokeResponse<MessageExtensionResponse> |
A message extension search query. |
composeExtension/selectItem |
OnSelectItem(handler) |
InvokeActivity<JsonElement> |
InvokeResponse<MessageExtensionResponse> |
A message extension search result was selected. |
composeExtension/fetchTask |
OnFetchTask(handler) |
InvokeActivity<MessageExtensionAction> |
InvokeResponse<MessageExtensionActionResponse> |
A message extension action command opened a dialog. |
composeExtension/submitAction |
OnSubmitAction(handler) |
InvokeActivity<MessageExtensionAction> |
InvokeResponse<MessageExtensionActionResponse> |
A message extension action command was submitted, including bot message preview edit and send. |
composeExtension/queryLink |
OnQueryLink(handler) |
InvokeActivity<MessageExtensionQueryLink> |
InvokeResponse<MessageExtensionResponse> |
A link was pasted for unfurling. |
composeExtension/anonymousQueryLink |
OnAnonQueryLink(handler) |
InvokeActivity<MessageExtensionQueryLink> |
InvokeResponse<MessageExtensionResponse> |
A link was pasted for zero-install unfurling. |
composeExtension/querySettingUrl |
OnQuerySettingUrl(handler) |
InvokeActivity<MessageExtensionQuery> |
InvokeResponse<MessageExtensionResponse> |
The message extension settings URL was requested. |
composeExtension/setting |
OnSetting(handler) |
InvokeActivity<MessageExtensionQuery> |
InvokeResponse |
Message extension settings were saved. |
composeExtension/onCardButtonClicked |
OnCardButtonClicked(handler) |
InvokeActivity<JsonElement> |
InvokeResponse |
A button on a card inserted by a message extension was selected. |
fileConsent/invoke |
OnFileConsent(handler) |
InvokeActivity<FileConsentValue> |
InvokeResponse<AdaptiveCardResponse> |
A file consent card was accepted or declined. Read Value.Action. |
message/fetchTask |
OnMessageFetchTask(handler) |
InvokeActivity<MessageFetchTaskInvokeValue> |
InvokeResponse<TaskModuleResponse> |
A custom feedback form was requested. |
message/submitAction |
OnMessageSubmitAction(handler) |
InvokeActivity<SubmitActionValue> |
InvokeResponse |
A message action was submitted. |
message/submitAction with value.actionName: feedback |
OnMessageSubmitFeedback(handler) |
InvokeActivity<MessageSubmitFeedbackValue> |
InvokeResponse |
Feedback was submitted on an agent message. Also matched by OnMessageSubmitAction; whichever is registered first runs. |
suggestedActions/submit |
OnSuggestedActionSubmit(handler) (experimental) |
InvokeActivity |
InvokeResponse |
A suggested action was selected. |
htmlwidget/calltool |
OnWidgetCallTool(handler) (experimental) |
InvokeActivity<CallToolRequest> |
InvokeResponse |
An HTML widget called a tool on the agent. |
signin/tokenExchange, signin/verifyState, signin/failure |
Handled by the SDK after you add an OAuth flow with AddOAuthFlow |
Not applicable | Not applicable | Use OAuthFlow.OnSignInComplete and OAuthFlow.OnSignInFailure to run code when sign-in completes or fails. |
Events without a dedicated handler
The following activities have no dedicated C# extension method. Handle them with the catch-all handler shown.
| Activity | Handler that receives it |
|---|---|
messageUpdate with channelData.eventType of editMessage or undeleteMessage |
OnMessageUpdate, which doesn't distinguish the two |
conversationUpdate with channelData.eventType: teamHardDeleted |
OnConversationUpdate |
installationUpdate with action of add-upgrade, remove-upgrade, or upgrade |
OnInstallUpdate. Read context.Activity.Action. |
event with name: application/vnd.microsoft.readReceipt |
OnEvent |
Invokes tab/fetch, tab/submit, config/fetch, config/submit, actionableMessage/executeAction, handoff/action |
OnInvoke |
typing, endOfConversation, command, commandResult |
Not routed |
Handler behavior
- For non-invoke activities, every registered handler that matches runs, in registration order. For example, a channel creation runs both
OnConversationUpdateandOnChannelCreated. - Each extension method registers a named route, and each route can be registered once. For example, calling
OnMessage(handler)twice throwsInvalidOperationException, even with different handlers.
Register handlers with app.on(name, handler). The handler receives a context whose activity property is typed for that route. Return a value from invoke handlers to send it as the invoke response.
app.on('message', async ({ activity, send }) => {
await send(`You said: ${activity.text}`);
});
Catch-all handlers
| Event | Route name | Activity type | Description |
|---|---|---|---|
| Any activity | 'activity' |
Activity |
Every activity. |
| Agent @mentioned | 'mention' |
Activity |
The agent itself was @mentioned. Mentions of other users don't match. |
| Message text matches a pattern | app.message(pattern, handler) |
IMessageActivity |
A message activity whose text matches a string or RegExp pattern. A string is treated as a regular expression. |
Message activities
| Event | Route name | Activity | Activity type | Description |
|---|---|---|---|---|
| Message received | 'message' |
message |
IMessageActivity |
Handle incoming messages. Doesn't fire for messageUpdate or messageDelete. |
| Message updated | 'messageUpdate' |
messageUpdate |
IMessageUpdateActivity |
A message was edited or restored. |
| Message edited | 'editMessage' |
messageUpdate with channelData.eventType: editMessage |
IMessageUpdateActivity |
A message was edited. |
| Message restored | 'undeleteMessage' |
messageUpdate with channelData.eventType: undeleteMessage |
IMessageUpdateActivity |
A deleted message was restored. |
| Message deleted | 'messageDelete' |
messageDelete |
IMessageDeleteActivity |
A message was deleted. |
| Message soft deleted | 'softDeleteMessage' |
messageDelete with channelData.eventType: softDeleteMessage |
IMessageDeleteActivity |
A message was soft-deleted. |
| Reaction added or removed | 'messageReaction' |
messageReaction |
IMessageReactionActivity |
One or more reactions changed. See Message reaction activities. |
| User typing | 'typing' |
typing |
ITypingActivity |
A user is typing. |
| Conversation ended | 'endOfConversation' |
endOfConversation |
IEndOfConversationActivity |
The conversation ended. |
| Command | 'command' |
command |
ICommandSendActivity |
A command activity was received. |
| Command result | 'commandResult' |
commandResult |
ICommandResultActivity |
A command result activity was received. |
| Trace | 'trace' |
trace |
ITraceActivity |
A trace activity was received. |
| Handoff | 'handoff' |
handoff |
IHandoffActivity |
A handoff activity was received. |
Conversation update activities
All conversation update routes receive IConversationUpdateActivity. There are no membersAdded or membersRemoved routes; read activity.membersAdded and activity.membersRemoved in a 'conversationUpdate' handler. For payload details, see conversationUpdate activities.
| Event | Route name | Activity | Description |
|---|---|---|---|
| Any conversation update | 'conversationUpdate' |
conversationUpdate |
Every conversation update, including member changes in chats. |
| Channel created | 'channelCreated' |
channelData.eventType: channelCreated |
A channel was created. |
| Channel deleted | 'channelDeleted' |
channelData.eventType: channelDeleted |
A channel was deleted. |
| Channel renamed | 'channelRenamed' |
channelData.eventType: channelRenamed |
A channel was renamed. |
| Channel restored | 'channelRestored' |
channelData.eventType: channelRestored |
A deleted channel was restored. |
| Channel shared | 'channelShared' |
channelData.eventType: channelShared |
A channel was shared with a team. |
| Channel unshared | 'channelUnshared' |
channelData.eventType: channelUnshared |
A channel was unshared from a team. |
| Channel member added | 'channelMemberAdded' |
channelData.eventType: channelMemberAdded |
A member was added to a channel. |
| Channel member removed | 'channelMemberRemoved' |
channelData.eventType: channelMemberRemoved |
A member was removed from a channel. |
| Team member added | 'teamMemberAdded' |
channelData.eventType: teamMemberAdded |
A member was added to the team. |
| Team member removed | 'teamMemberRemoved' |
channelData.eventType: teamMemberRemoved |
A member was removed from the team. |
| Team archived | 'teamArchived' |
channelData.eventType: teamArchived |
The team was archived. |
| Team unarchived | 'teamUnarchived' |
channelData.eventType: teamUnarchived |
The team was unarchived. |
| Team deleted | 'teamDeleted' |
channelData.eventType: teamDeleted |
The team was deleted. |
| Team permanently deleted | 'teamHardDeleted' |
channelData.eventType: teamHardDeleted |
The team was permanently deleted. |
| Team renamed | 'teamRenamed' |
channelData.eventType: teamRenamed |
The team was renamed. |
| Team restored | 'teamRestored' |
channelData.eventType: teamRestored |
The deleted team was restored. |
Installation update activities
For details, see Installation update event details.
| Event | Route name | Activity | Activity type | Description |
|---|---|---|---|---|
| Any installation update | 'installationUpdate' |
installationUpdate |
InstallUpdateActivity |
Every installation update activity. |
| Agent installed | 'install.add' |
installationUpdate with action: add |
IInstalledActivity |
The agent was installed. |
| Agent uninstalled | 'install.remove' |
installationUpdate with action: remove |
IUnInstalledActivity |
The agent was uninstalled. |
| App upgraded | 'install.upgrade' |
installationUpdate with action: upgrade |
IInstalledUpgradeActivity |
The app was upgraded without adding or removing the agent. |
Upgrades that add or remove the agent (action of add-upgrade or remove-upgrade) have no dedicated route. Handle them in 'installationUpdate' and read activity.action. The action type doesn't include these values, so compare it as a string.
Event activities
| Event | Route name | Activity | Activity type | Description |
|---|---|---|---|---|
| Any event | 'event' |
event |
EventActivity |
Every event activity. |
| Read receipt | 'readReceipt' |
event with name: application/vnd.microsoft.readReceipt |
IReadReceiptEventActivity |
A user read the agent's message in a one-on-one chat. |
| Meeting started | 'meetingStart' |
event with name: application/vnd.microsoft.meetingStart |
IMeetingStartEventActivity |
A meeting started. |
| Meeting ended | 'meetingEnd' |
event with name: application/vnd.microsoft.meetingEnd |
IMeetingEndEventActivity |
A meeting ended. |
| Participant joined | 'meetingParticipantJoin' |
event with name: application/vnd.microsoft.meetingParticipantJoin |
IMeetingParticipantJoinEventActivity |
A participant joined a meeting. |
| Participant left | 'meetingParticipantLeave' |
event with name: application/vnd.microsoft.meetingParticipantLeave |
IMeetingParticipantLeaveEventActivity |
A participant left a meeting. |
| Agent lifecycle | 'agentLifecycle' |
event with name: agentLifecycle |
AgentLifecycleEventActivity |
Any agentic user lifecycle event. |
| Agentic user identity created | 'agenticUserIdentityCreated' |
agentLifecycle with valueType: AgenticUserIdentityCreated |
IAgenticUserIdentityCreatedEventActivity |
An agentic user identity was created. |
| Agentic user identity updated | 'agenticUserIdentityUpdated' |
valueType: AgenticUserIdentityUpdated |
IAgenticUserIdentityUpdatedEventActivity |
An agentic user identity was updated. |
| Agentic user manager updated | 'agenticUserManagerUpdated' |
valueType: AgenticUserManagerUpdated |
IAgenticUserManagerUpdatedEventActivity |
The agentic user's manager changed. |
| Agentic user enabled | 'agenticUserEnabled' |
valueType: AgenticUserEnabled |
IAgenticUserEnabledEventActivity |
The agentic user was enabled. |
| Agentic user disabled | 'agenticUserDisabled' |
valueType: AgenticUserDisabled |
IAgenticUserDisabledEventActivity |
The agentic user was disabled. |
| Agentic user deleted | 'agenticUserDeleted' |
valueType: AgenticUserDeleted |
IAgenticUserDeletedEventActivity |
The agentic user was deleted. |
| Agentic user restored | 'agenticUserUndeleted' |
valueType: AgenticUserUndeleted |
IAgenticUserUndeletedEventActivity |
The deleted agentic user was restored. |
| Agentic user workload onboarding updated | 'agenticUserWorkloadOnboardingUpdated' |
valueType: AgenticUserWorkloadOnboardingUpdated |
IAgenticUserWorkloadOnboardingUpdatedEventActivity |
The workload onboarding state changed. |
Invoke activities
Return the response body, or an InvokeResponse to also set the status. If no handler returns a value, the SDK responds with 200 OK and an empty body.
Invoke name |
Route name | Activity type | Response body type | Description |
|---|---|---|---|---|
| Any invoke | 'invoke' |
InvokeActivity |
Any | Every invoke activity. |
adaptiveCard/action |
'card.action' |
IAdaptiveCardActionInvokeActivity |
AdaptiveCardActionResponse |
An Adaptive Card Action.Execute action. |
adaptiveCard/action with value.action.data.action |
`card.action.${action}` |
IAdaptiveCardActionInvokeActivity |
AdaptiveCardActionResponse |
An Action.Execute action whose data.action matches the route suffix. |
application/search |
'card.search' |
ISearchInvokeActivity |
SearchInvokeResponse |
An Adaptive Card Input.ChoiceSet dynamic search. |
task/fetch |
'dialog.open' |
ITaskFetchInvokeActivity |
TaskModuleResponse |
A dialog (task module) was opened. |
task/fetch with value.data.dialog_id |
`dialog.open.${dialogId}` |
ITaskFetchInvokeActivity |
TaskModuleResponse |
A dialog whose dialog_id matches the route suffix was opened. |
task/submit |
'dialog.submit' |
ITaskSubmitInvokeActivity |
TaskModuleResponse |
A dialog (task module) was submitted. |
task/submit with value.data.action |
`dialog.submit.${action}` |
ITaskSubmitInvokeActivity |
TaskModuleResponse |
A dialog whose submitted action matches the route suffix. |
composeExtension/query |
'message.ext.query' |
IMessageExtensionQueryInvokeActivity |
MessagingExtensionResponse |
A message extension search query. |
composeExtension/selectItem |
'message.ext.select-item' |
IMessageExtensionSelectItemInvokeActivity |
MessagingExtensionResponse |
A message extension search result was selected. |
composeExtension/fetchTask |
'message.ext.open' |
IMessageExtensionFetchTaskInvokeActivity |
MessagingExtensionActionResponse |
A message extension action command opened a dialog. |
composeExtension/submitAction |
'message.ext.submit' |
IMessageExtensionSubmitActionInvokeActivity |
MessagingExtensionActionResponse |
A message extension action command was submitted. |
composeExtension/submitAction with value.botMessagePreviewAction: edit |
'message.ext.edit' |
IMessageExtensionSubmitActionInvokeActivity |
MessagingExtensionActionResponse |
The user chose Edit on a bot message preview. |
composeExtension/submitAction with value.botMessagePreviewAction: send |
'message.ext.send' |
IMessageExtensionSubmitActionInvokeActivity |
MessagingExtensionActionResponse |
The user chose Send on a bot message preview. |
composeExtension/queryLink |
'message.ext.query-link' |
IMessageExtensionQueryLinkInvokeActivity |
MessagingExtensionResponse |
A link was pasted for unfurling. |
composeExtension/anonymousQueryLink |
'message.ext.anon-query-link' |
IMessageExtensionAnonQueryLinkInvokeActivity |
MessagingExtensionResponse |
A link was pasted for zero-install unfurling. |
composeExtension/querySettingUrl |
'message.ext.query-settings-url' |
IMessageExtensionQuerySettingUrlInvokeActivity |
MessagingExtensionResponse |
The message extension settings URL was requested. |
composeExtension/setting |
'message.ext.setting' |
IMessageExtensionSettingInvokeActivity |
MessagingExtensionResponse |
Message extension settings were saved. |
composeExtension/onCardButtonClicked |
'message.ext.card-button-clicked' |
IMessageExtensionCardButtonClickedInvokeActivity |
None | A button on a card inserted by a message extension was selected. |
tab/fetch |
'tab.open' |
ITabFetchInvokeActivity |
TabResponse |
An Adaptive Card tab was opened. |
tab/submit |
'tab.submit' |
ITabSubmitInvokeActivity |
TabResponse |
An Adaptive Card tab was submitted. |
config/fetch |
'config.open' |
IConfigFetchInvokeActivity |
ConfigResponse |
The agent's configuration was requested. |
config/submit |
'config.submit' |
IConfigSubmitInvokeActivity |
ConfigResponse |
The agent's configuration was submitted. |
fileConsent/invoke |
'file.consent' |
IFileConsentInvokeActivity |
None | A file consent card was accepted or declined. |
fileConsent/invoke with value.action: accept |
'file.consent.accept' |
IFileConsentInvokeActivity |
None | A file consent card was accepted. |
fileConsent/invoke with value.action: decline |
'file.consent.decline' |
IFileConsentInvokeActivity |
None | A file consent card was declined. |
actionableMessage/executeAction |
'message.execute' |
IExecuteActionInvokeActivity |
None | An action on an Office 365 connector card was selected. |
message/fetchTask |
'message.fetch-task' |
IMessageFetchTaskInvokeActivity |
TaskModuleResponse |
A custom feedback form was requested. |
message/submitAction |
'message.submit' |
IMessageSubmitActionInvokeActivity |
None | A message action was submitted. |
message/submitAction with value.actionName: feedback |
'message.submit.feedback' |
IMessageSubmitActionInvokeActivity |
None | Feedback was submitted on an agent message. |
handoff/action |
'handoff.action' |
IHandoffActionInvokeActivity |
None | A conversation was handed off to the agent. |
suggestedActions/submit |
'suggested-action.submit' (experimental) |
ISuggestedActionSubmitInvokeActivity |
None | A suggested action was selected. |
htmlwidget/calltool |
'widget.callTool' (experimental) |
IHtmlWidgetCallToolInvokeActivity |
IHtmlWidgetCallToolResponse |
An HTML widget called a tool on the agent. |
signin/tokenExchange |
'signin.token-exchange' |
ISignInTokenExchangeInvokeActivity |
TokenExchangeInvokeResponse |
Handled by the SDK. Registering this route replaces the SDK's handling. |
signin/verifyState |
'signin.verify-state' |
ISignInVerifyStateInvokeActivity |
None | Handled by the SDK. Registering this route replaces the SDK's handling. |
signin/failure |
'signin.failure' |
ISignInFailureInvokeActivity |
None | Handled by the SDK. Registering this route replaces the SDK's handling. |
Handler behavior
- When several routes match one activity, they run in registration order, and each later handler runs only if the previous one calls
next(). For example, a channel creation matches both'conversationUpdate'and'channelCreated', but only the first one registered runs unless it callsnext(). - Use
app.event('signin', handler)to run code after the SDK completes a sign-in, andapp.event('error', handler)to handle errors.
Register handlers with decorators on the App instance. Each handler receives an ActivityContext typed for that activity. Return a value from invoke handlers to send it as the invoke response.
@app.on_message
async def handle_message(ctx: ActivityContext[MessageActivity]):
await ctx.send(f"You said: {ctx.activity.text}")
Catch-all handlers
| Event | Decorator | Context type | Description |
|---|---|---|---|
| Any activity | @app.on_activity |
ActivityContext[Activity] |
Every activity that the SDK recognizes. See Events without a dedicated handler later in this section. |
| Message text matches | @app.on_message_pattern(pattern) |
ActivityContext[MessageActivity] |
A message whose text equals a string pattern, or matches a compiled re.Pattern from the start of the text. |
Message activities
| Event | Decorator | Activity | Context type | Description |
|---|---|---|---|---|
| Message received | @app.on_message |
message |
ActivityContext[MessageActivity] |
Handle incoming messages. Doesn't fire for messageUpdate or messageDelete. |
| Message updated | @app.on_message_update |
messageUpdate |
ActivityContext[MessageUpdateActivity] |
A message was edited or restored. |
| Message edited | @app.on_edit_message |
messageUpdate with channelData.eventType: editMessage |
ActivityContext[MessageUpdateActivity] |
A message was edited. |
| Message restored | @app.on_undelete_message |
messageUpdate with channelData.eventType: undeleteMessage |
ActivityContext[MessageUpdateActivity] |
A deleted message was restored. |
| Message deleted | @app.on_message_delete |
messageDelete |
ActivityContext[MessageDeleteActivity] |
A message was deleted. |
| Message soft deleted | @app.on_soft_delete_message |
messageDelete with channelData.eventType: softDeleteMessage |
ActivityContext[MessageDeleteActivity] |
A message was soft-deleted. |
| Reaction added or removed | @app.on_message_reaction |
messageReaction |
ActivityContext[MessageReactionActivity] |
One or more reactions changed. See Message reaction activities. |
| User typing | @app.on_typing |
typing |
ActivityContext[TypingActivity] |
A user is typing. |
| Command | @app.on_command |
command |
ActivityContext[CommandSendActivity] |
A command activity was received. |
| Command result | @app.on_command_result |
commandResult |
ActivityContext[CommandResultActivity] |
A command result activity was received. |
Conversation update activities
All conversation update handlers receive ActivityContext[ConversationUpdateActivity]. There are no members added or removed decorators; read ctx.activity.members_added and ctx.activity.members_removed in an @app.on_conversation_update handler. For payload details, see conversationUpdate activities.
| Event | Decorator | Activity | Description |
|---|---|---|---|
| Any conversation update | @app.on_conversation_update |
conversationUpdate |
Every conversation update, including member changes. |
| Channel created | @app.on_channel_created |
channelData.eventType: channelCreated |
A channel was created. |
| Channel deleted | @app.on_channel_deleted |
channelData.eventType: channelDeleted |
A channel was deleted. |
| Channel renamed | @app.on_channel_renamed |
channelData.eventType: channelRenamed |
A channel was renamed. |
| Channel restored | @app.on_channel_restored |
channelData.eventType: channelRestored |
A deleted channel was restored. |
| Team archived | @app.on_team_archived |
channelData.eventType: teamArchived |
The team was archived. |
| Team unarchived | @app.on_team_unarchived |
channelData.eventType: teamUnarchived |
The team was unarchived. |
| Team deleted | @app.on_team_deleted |
channelData.eventType: teamDeleted |
The team was deleted. |
| Team permanently deleted | @app.on_team_hard_deleted |
channelData.eventType: teamHardDeleted |
The team was permanently deleted. |
| Team renamed | @app.on_team_renamed |
channelData.eventType: teamRenamed |
The team was renamed. |
| Team restored | @app.on_team_restored |
channelData.eventType: teamRestored |
The deleted team was restored. |
Installation update activities
For details, see Installation update event details.
| Event | Decorator | Activity | Context type | Description |
|---|---|---|---|---|
| Any installation update | @app.on_installation_update |
installationUpdate |
ActivityContext[InstallUpdateActivity] |
Installation updates with action of add, remove, or upgrade. |
| Agent installed | @app.on_install_add |
installationUpdate with action: add |
ActivityContext[InstalledActivity] |
The agent was installed. |
| Agent uninstalled | @app.on_install_remove |
installationUpdate with action: remove |
ActivityContext[UninstalledActivity] |
The agent was uninstalled. |
Event activities
| Event | Decorator | Activity | Context type | Description |
|---|---|---|---|---|
| Any event | @app.on_event |
event |
ActivityContext[EventActivity] |
Event activities with a name listed in this table. |
| Read receipt | @app.on_read_receipt |
event with name: application/vnd.microsoft.readReceipt |
ActivityContext[ReadReceiptEventActivity] |
A user read the agent's message in a one-on-one chat. |
| Meeting started | @app.on_meeting_start |
event with name: application/vnd.microsoft.meetingStart |
ActivityContext[MeetingStartEventActivity] |
A meeting started. |
| Meeting ended | @app.on_meeting_end |
event with name: application/vnd.microsoft.meetingEnd |
ActivityContext[MeetingEndEventActivity] |
A meeting ended. |
| Participant joined | @app.on_meeting_participant_join |
event with name: application/vnd.microsoft.meetingParticipantJoin |
ActivityContext[MeetingParticipantJoinEventActivity] |
A participant joined a meeting. |
| Participant left | @app.on_meeting_participant_leave |
event with name: application/vnd.microsoft.meetingParticipantLeave |
ActivityContext[MeetingParticipantLeaveEventActivity] |
A participant left a meeting. |
| Agent lifecycle | @app.on_agent_lifecycle |
event with name: agentLifecycle |
ActivityContext[AgentLifecycleEventActivity] |
Any agentic user lifecycle event. |
| Agentic user identity created | @app.on_agentic_user_identity_created |
agentLifecycle with valueType: AgenticUserIdentityCreated |
ActivityContext[AgenticUserIdentityCreatedActivity] |
An agentic user identity was created. |
| Agentic user identity updated | @app.on_agentic_user_identity_updated |
valueType: AgenticUserIdentityUpdated |
ActivityContext[AgenticUserIdentityUpdatedActivity] |
An agentic user identity was updated. |
| Agentic user manager updated | @app.on_agentic_user_manager_updated |
valueType: AgenticUserManagerUpdated |
ActivityContext[AgenticUserManagerUpdatedActivity] |
The agentic user's manager changed. |
| Agentic user enabled | @app.on_agentic_user_enabled |
valueType: AgenticUserEnabled |
ActivityContext[AgenticUserEnabledActivity] |
The agentic user was enabled. |
| Agentic user disabled | @app.on_agentic_user_disabled |
valueType: AgenticUserDisabled |
ActivityContext[AgenticUserDisabledActivity] |
The agentic user was disabled. |
| Agentic user deleted | @app.on_agentic_user_deleted |
valueType: AgenticUserDeleted |
ActivityContext[AgenticUserDeletedActivity] |
The agentic user was deleted. |
| Agentic user restored | @app.on_agentic_user_undeleted |
valueType: AgenticUserUndeleted |
ActivityContext[AgenticUserUndeletedActivity] |
The deleted agentic user was restored. |
| Agentic user workload onboarding updated | @app.on_agentic_user_workload_onboarding_updated |
valueType: AgenticUserWorkloadOnboardingUpdated |
ActivityContext[AgenticUserWorkloadOnboardingUpdatedActivity] |
The workload onboarding state changed. |
Invoke activities
Return the response body, or an InvokeResponse to also set the status. If no handler returns a value, the SDK responds with 200 OK and an empty body.
Invoke name |
Decorator | Context type | Response body type | Description |
|---|---|---|---|---|
| Any invoke | @app.on_invoke |
ActivityContext[InvokeActivity] |
Any | Invoke activities with a name listed in this table. |
adaptiveCard/action |
@app.on_card_action |
ActivityContext[AdaptiveCardInvokeActivity] |
AdaptiveCardInvokeResponse |
An Adaptive Card action. |
adaptiveCard/action with Action.Execute |
@app.on_card_action_execute, @app.on_card_action_execute(action) |
ActivityContext[AdaptiveCardInvokeActivity] |
AdaptiveCardInvokeResponse |
An Action.Execute action, optionally filtered by the action key in the card's data. |
application/search |
@app.on_card_search |
ActivityContext[SearchInvokeActivity] |
SearchInvokeResponse |
An Adaptive Card Input.ChoiceSet dynamic search. |
task/fetch |
@app.on_dialog_open, @app.on_dialog_open(dialog_id) |
ActivityContext[TaskFetchInvokeActivity] |
TaskModuleInvokeResponse |
A dialog (task module) was opened, optionally filtered by dialog_id in the request data. |
task/submit |
@app.on_dialog_submit, @app.on_dialog_submit(action) |
ActivityContext[TaskSubmitInvokeActivity] |
TaskModuleInvokeResponse |
A dialog (task module) was submitted, optionally filtered by action in the submitted data. |
composeExtension/query |
@app.on_message_ext_query |
ActivityContext[MessageExtensionQueryInvokeActivity] |
MessagingExtensionInvokeResponse |
A message extension search query. |
composeExtension/selectItem |
@app.on_message_ext_select_item |
ActivityContext[MessageExtensionSelectItemInvokeActivity] |
MessagingExtensionInvokeResponse |
A message extension search result was selected. |
composeExtension/fetchTask |
@app.on_message_ext_open |
ActivityContext[MessageExtensionFetchTaskInvokeActivity] |
MessagingExtensionActionInvokeResponse |
A message extension action command opened a dialog. |
composeExtension/submitAction |
@app.on_message_ext_submit |
ActivityContext[MessageExtensionSubmitActionInvokeActivity] |
MessagingExtensionActionInvokeResponse |
A message extension action command was submitted, including bot message preview edit and send. |
composeExtension/queryLink |
@app.on_message_ext_query_link |
ActivityContext[MessageExtensionQueryLinkInvokeActivity] |
MessagingExtensionInvokeResponse |
A link was pasted for unfurling. |
composeExtension/anonymousQueryLink |
@app.on_message_ext_anon_query_link |
ActivityContext[MessageExtensionAnonQueryLinkInvokeActivity] |
MessagingExtensionInvokeResponse |
A link was pasted for zero-install unfurling. |
composeExtension/querySettingUrl |
@app.on_message_ext_query_settings_url |
ActivityContext[MessageExtensionQuerySettingUrlInvokeActivity] |
MessagingExtensionInvokeResponse |
The message extension settings URL was requested. |
composeExtension/setting |
@app.on_message_ext_setting |
ActivityContext[MessageExtensionSettingInvokeActivity] |
MessagingExtensionInvokeResponse |
Message extension settings were saved. |
composeExtension/onCardButtonClicked |
@app.on_message_ext_card_button_clicked |
ActivityContext[MessageExtensionCardButtonClickedInvokeActivity] |
None | A button on a card inserted by a message extension was selected. |
tab/fetch |
@app.on_tab_open |
ActivityContext[TabFetchInvokeActivity] |
TabInvokeResponse |
An Adaptive Card tab was opened. |
tab/submit |
@app.on_tab_submit |
ActivityContext[TabSubmitInvokeActivity] |
TabInvokeResponse |
An Adaptive Card tab was submitted. |
config/fetch |
@app.on_config_open |
ActivityContext[ConfigFetchInvokeActivity] |
ConfigInvokeResponse |
The agent's configuration was requested. |
config/submit |
@app.on_config_submit |
ActivityContext[ConfigSubmitInvokeActivity] |
ConfigInvokeResponse |
The agent's configuration was submitted. |
fileConsent/invoke |
@app.on_file_consent |
ActivityContext[FileConsentInvokeActivity] |
None | A file consent card was accepted or declined. Read ctx.activity.value.action. |
actionableMessage/executeAction |
@app.on_message_execute |
ActivityContext[ExecuteActionInvokeActivity] |
None | An action on an Office 365 connector card was selected. |
message/fetchTask |
@app.on_message_fetch_task |
ActivityContext[MessageFetchTaskInvokeActivity] |
TaskModuleInvokeResponse |
A custom feedback form was requested. |
message/submitAction |
@app.on_message_submit |
ActivityContext[MessageSubmitActionInvokeActivity] |
None | A message action was submitted. |
message/submitAction with value.actionName: feedback |
@app.on_message_submit_feedback |
ActivityContext[MessageSubmitActionInvokeActivity] |
None | Feedback was submitted on an agent message. |
handoff/action |
@app.on_handoff_action |
ActivityContext[HandoffActionInvokeActivity] |
None | A conversation was handed off to the agent. |
suggestedActions/submit |
@app.on_suggested_action_submit (experimental) |
ActivityContext[SuggestedActionSubmitInvokeActivity] |
None | A suggested action was selected. |
htmlwidget/calltool |
@app.on_widget_call_tool (experimental) |
ActivityContext[HtmlWidgetCallToolInvokeActivity] |
HtmlWidgetCallToolResponse |
An HTML widget called a tool on the agent. |
signin/tokenExchange |
@app.on_signin_token_exchange |
ActivityContext[SignInTokenExchangeInvokeActivity] |
TokenExchangeInvokeResponseType |
Handled by the SDK. Your handler runs after the SDK's handling. |
signin/verifyState |
@app.on_signin_verify_state |
ActivityContext[SignInVerifyStateInvokeActivity] |
None | Handled by the SDK. Your handler runs after the SDK's handling. |
signin/failure |
@app.on_signin_failure |
ActivityContext[SignInFailureInvokeActivity] |
None | Handled by the SDK. Your handler runs after the SDK's handling. |
Events without a dedicated handler
| Activity | Handler that receives it |
|---|---|
conversationUpdate with channelData.eventType of channelShared, channelUnshared, channelMemberAdded, channelMemberRemoved, teamMemberAdded, or teamMemberRemoved |
@app.on_conversation_update |
installationUpdate with action: upgrade |
@app.on_installation_update |
installationUpdate with action of add-upgrade or remove-upgrade |
Not supported. The activity fails validation before routing, no handler runs, and the SDK responds with 500. |
endOfConversation, trace, and handoff activities, and event or invoke name values not listed in the tables |
Not supported. The activity fails validation before routing, no handler runs, and the SDK responds with 500. |
Handler behavior
- When several handlers match one activity, they run in registration order, and each later handler runs only if the previous one calls
await ctx.next(). For example, a channel creation matches both@app.on_conversation_updateand@app.on_channel_created, but only the first one registered runs unless it callsawait ctx.next(). - Use
@app.event("sign_in")to run code after the SDK completes a sign-in, and@app.event("error")to handle errors.
Message reaction activities
Each reaction has a type value, such as angry, heart, laugh, like, sad, or surprised. The payload doesn't include the original message contents, so store the message when you send it if your agent needs those contents to process reactions. Payloads can also include the older message identifier in legacy.replyToId. See the added and removed reaction payload examples.
Use OnMessageReaction to handle both changes. Read context.Activity.ReactionsAdded and context.Activity.ReactionsRemoved for the reactions, and context.Activity.ReplyToId for the message ID.
teams.OnMessageReaction(async (context, cancellationToken) =>
{
});
Teams SDK also provides separate handlers specifically for OnMessageReactionAdded and OnMessageReactionRemoved. Implement either the general handler or the specific handlers, not both. The following example illustrated using the specific handlers to log each added or removed reaction's type.
teams.OnMessageReactionAdded(async (context, cancellationToken) =>
{
foreach (var reaction in context.Activity.ReactionsAdded ?? [])
{
Console.WriteLine($"User added reaction: {reaction.Type}");
}
});
teams.OnMessageReactionRemoved(async (context, cancellationToken) =>
{
foreach (var reaction in context.Activity.ReactionsRemoved ?? [])
{
Console.WriteLine($"User removed reaction: {reaction.Type}");
}
});
Handle both changes with the messageReaction event. Read context.activity.reactionsAdded and context.activity.reactionsRemoved for the reactions, and context.activity.replyToId for the message ID.
app.on('messageReaction', async (context) => {
});
The following example processes both added and removed reactions in one handler and logs each reaction's type:
app.on('messageReaction', async ({ activity }) => {
for (const reaction of activity.reactionsAdded ?? []) {
console.log(`User added reaction: ${reaction.type}`);
}
for (const reaction of activity.reactionsRemoved ?? []) {
console.log(`User removed reaction: ${reaction.type}`);
}
});
Handle both changes with @app.on_message_reaction. Read ctx.activity.reactions_added and ctx.activity.reactions_removed for the reactions, and ctx.activity.reply_to_id for the message ID.
@app.on_message_reaction
async def handle_reaction(ctx: ActivityContext):
pass
The following example processes both added and removed reactions in one handler and logs each reaction's type:
@app.on_message_reaction
async def handle_reaction(ctx: ActivityContext[MessageReactionActivity]):
for reaction in ctx.activity.reactions_added or []:
print(f"User added reaction: {reaction.type}")
for reaction in ctx.activity.reactions_removed or []:
print(f"User removed reaction: {reaction.type}")
conversationUpdate activities
conversationUpdate activities are used to represent multiple kinds of events in Teams. Different conversationUpdate events can be distinguished by examining their channelData properties. In most cases, this is not necessary, as Teams SDK provided dedicated activity handler subscriptions for each kind.
Conversation update activity payloads have type of conversationUpdate. Channel and team lifecycle events identify the change in channelData.eventType. Membership changes also populate membersAdded or membersRemoved.
| Event | Payload event type or field | Scope | Payload example |
|---|---|---|---|
| Channel created | channelData.eventType: channelCreated |
Team | Channel created |
| Channel renamed | channelData.eventType: channelRenamed |
Team | Channel renamed |
| Channel deleted | channelData.eventType: channelDeleted |
Team | Channel deleted |
| Channel restored | channelData.eventType: channelRestored |
Team | Channel restored |
| Members added | membersAdded; in a team, channelData.eventType: teamMemberAdded |
All | Team installation, personal installation |
| Members removed | membersRemoved; in a team, channelData.eventType: teamMemberRemoved |
All | Members removed |
| Team renamed | channelData.eventType: teamRenamed |
Team | Team renamed |
| Team deleted | channelData.eventType: teamDeleted |
Team | Team deleted |
| Team archived | channelData.eventType: teamArchived |
Team | Team archived |
| Team unarchived | channelData.eventType: teamUnarchived |
Team | Team unarchived |
| Team restored | channelData.eventType: teamRestored |
Team | Team restored |
Channel lifecycle payloads include the channel's ID and name in channelData.channel and the team ID in channelData.team. Team lifecycle payloads include the team's ID and name in channelData.team. Use these fields to identify the affected channel or team and, when appropriate, notify users about the change.
Azure Communication Services clients joining or leaving Teams meetings do not trigger conversation update activities.
Member changes
Member-added events occur when the agent is installed or a user joins a conversation where the agent is installed. Member-removed events occur when the agent is uninstalled, a user leaves, or a user is permanently deleted from the tenant.
These events can describe either the agent itself or another user. Compare each member's id in membersAdded or membersRemoved with recipient.id to determine whether the event concerns the agent. The agent's ID has the format 28:<MicrosoftAppId>.
In a team context, the member-added event uses channelData.eventType of teamMemberAdded, and the member-removed event uses teamMemberRemoved.
User IDs in these payloads are unique to the agent. Cache them when needed for future interactions, such as directly messaging a user. When the agent is removed, clear cached data for the team as appropriate for your app's data-retention requirements.
When the agent is installed in a team, conversation.id identifies the channel selected by the user during installation or the channel from which installation was initiated. It isn't necessarily the General channel. For agent installation and removal workflows, prefer the installation update event.
Installation update event details
Teams sends an activity with type of installationUpdate when an agent is installed in or uninstalled from a conversation thread. Use installation updates to send an introductory message when your agent is installed and to clean up user or conversation-thread data when it's uninstalled. This helps your app meet privacy and data-retention requirements.
Inspect action to determine the change.
| Action | Meaning |
|---|---|
add |
The agent was installed in a conversation thread. |
remove |
The agent was uninstalled from a conversation thread. |
add-upgrade |
An app upgrade added the agent to the manifest. |
remove-upgrade |
An app upgrade removed the agent from the manifest. |
upgrade |
An app upgrade didn't add or remove the agent. |
When an app upgrade adds or removes an agent from the manifest, Teams sends add-upgrade or remove-upgrade. For other upgrades of an app installed in personal scope, Teams sends upgrade. In team scope, other upgrades don't trigger an installation update event.
Install update event
When an agent is installed in a team, conversation.id in both the conversation update and installation update activities identifies the channel selected during installation or the channel where installation occurred. Send your welcome message to this channel, where the user intends the agent to operate. If you explicitly need the General channel ID, use channelData.team.id.
The installation payload also shows channelData.settings.selectedChannel.id, channelData.channel, channelData.team, tenant information, and the installation source.
The following example shows installation in the Response channel of the Daves Demo team. Both activities identify the Response channel:
Note
The selected channel ID is only set on installationUpdate add events when an app is installed into a team. In the associated team-installation conversation update payload, conversation.id and channelData.settings.selectedChannel.id identify the selected channel.
Uninstall behavior for personal app with agent
When an app is uninstalled, its agent is also uninstalled. Users receive a 403 response if they attempt to send a message to the app, and the agent receives a 403 response when it attempts to post new messages.
Personal scope follows the same post-uninstall behavior as team and group chat scopes: the agent can't send or receive messages after the app is uninstalled.
Event handling for install and uninstall events
Teams can add new events at any time, so design your agent to accept events it doesn't recognize. By default, Teams SDK responds with 200 OK to events for which you haven't registered a handler.
If you build an agent without Teams SDK or customize the SDK's default event handling, preserve this behavior for unexpected events. Otherwise, new installation, uninstallation, or other events can cause exceptions in your agent.
Handling errors in conversation events
Don't send error messages that lack meaningful context to the conversation. The following screenshot shows an unhelpful error response:
During development, meaningful diagnostic messages can help explain a specific error. In production, log errors and events to Azure Application Insights instead of posting debugging details to the conversation. For more information, see Add telemetry to your bot.
Event payload examples
The following JSON examples show incoming activities independently of the SDK language. Sample IDs and timestamps are illustrative.
Channel created payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:34:07.478Z",
"localTimestamp": "2017-02-23T12:34:07.478-07:00",
"id": "f:dd6ec311",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1wR7IdIRIoerMIWbewMi75JA3scaMuxvFon9eRQW2Nix5loMDo0362st2IaRVRirPZBv1WdXT8TIFWWmlQCizZQ"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterBot"
},
"channelData": {
"channel": {
"id": "19:6d97d816470f481dbcda38244b98689a@thread.skype",
"name": "FunDiscussions"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"eventType": "channelCreated",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Channel renamed payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:34:07.478Z",
"localTimestamp": "2017-02-23T12:34:07.478-07:00",
"id": "f:dd6ec311",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1wR7IdIRIoerMIWbewMi75JA3scaMuxvFon9eRQW2Nix5loMDo0362st2IaRVRirPZBv1WdXT8TIFWWmlQCizZQ"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterBot"
},
"channelData": {
"channel": {
"id": "19:6d97d816470f481dbcda38244b98689a@thread.skype",
"name": "PhotographyUpdates"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"eventType": "channelRenamed",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Channel deleted payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:34:07.478Z",
"localTimestamp": "2017-02-23T12:34:07.478-07:00",
"id": "f:dd6ec311",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1wR7IdIRIoerMIWbewMi75JA3scaMuxvFon9eRQW2Nix5loMDo0362st2IaRVRirPZBv1WdXT8TIFWWmlQCizZQ"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterBot"
},
"channelData": {
"channel": {
"id": "19:6d97d816470f481dbcda38244b98689a@thread.skype",
"name": "PhotographyUpdates"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"eventType": "channelDeleted",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Channel restored payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:34:07.478Z",
"localTimestamp": "2017-02-23T12:34:07.478-07:00",
"id": "f:dd6ec311",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1wR7IdIRIoerMIWbewMi75JA3scaMuxvFon9eRQW2Nix5loMDo0362st2IaRVRirPZBv1WdXT8TIFWWmlQCizZQ"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterBot"
},
"channelData": {
"channel": {
"id": "19:6d97d816470f481dbcda38244b98689a@thread.skype",
"name": "FunDiscussions"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"eventType": "channelRestored",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Members added team installation payload
This example shows the activity received when the agent is added to a team. conversation.id and channelData.settings.selectedChannel.id identify the channel selected during installation or the channel from which installation was triggered.
{
"type": "conversationUpdate",
"membersAdded": [
{
"id": "28:608cacfd-1cea-40c9-b678-4b93e69bb72b"
}
],
"timestamp": "2021-12-07T22:34:56.534Z",
"id": "f:0b9079f4-d4d3-3d8e-b883-798298053c7e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"from": {
"id": "29:1ljv6N86roXr5pjPrCJVIz6xHh5QxjI....",
"aadObjectId": "eddfa9d4-346e-4cce-a18f-fa6261ad776b"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"tenantId": "b28fdbfd-2b78-4f93-b0f8-8881793f0f8f",
"id": "19:0b7f32667e064dd9b25d7969801541f4@thread.tacv2",
"name": "2021 Test Channel"
},
"recipient": {
"id": "28:608cacfd-1cea-40c9-b678-4b93e69bb72b",
"name": "Test Agent"
},
"channelData": {
"settings": {
"selectedChannel": {
"id": "19:0b7f32667e064dd9b25d7969801541f4@thread.tacv2"
}
},
"team": {
"aadGroupId": "f3ec8cd2-e704-4344-8c47-9a3a21d683c0",
"name": "TestTeam2022",
"id": "19:zFLSDFWsesfzcmKArqKJ-65aOXJz@sgf462H2wz41@thread.tacv2"
},
"tenant": {
"id": "b28fdbfd-2b78-4f93-b0f8-8881793f0f8f"
},
"source": {
"name": "message"
}
},
"action": "add"
}
Members added personal installation payload
This example shows the activity received when the agent is added to a one-to-one chat.
{
"membersAdded": [
{
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0"
},
{
"id": "29:<userID>",
"aadObjectId": "***"
}
],
"type": "conversationUpdate",
"timestamp": "2019-04-23T10:17:44.349Z",
"id": "f:5f85c2ad",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:<USERID>",
"aadObjectId": "***"
},
"conversation": {
"conversationType": "personal",
"id": "***"
},
"recipient": {
"id": "28:<BOT ID>",
"name": "<BOT NAME>"
},
"channelData": {
"tenant": {
"id": "<TENANT ID>"
}
}
}
Members removed payload
This example's channelData describes a team membership change, not a group chat or a new one-to-one conversation.
{
"membersRemoved": [
{
"id": "29:1_LCi5Up14pAy65yZuaJzG1uIT7ujYhjjSTsUNqjORsZHjLHKiQIBJa4cX2XsAsRoaY7va2w6ZymA9-1VtSY_g"
}
],
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:37:06.96Z",
"localTimestamp": "2017-02-23T12:37:06.96-07:00",
"id": "f:d8a6a4aa",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0OIy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterAgent"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"eventType": "teamMemberRemoved",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Team renamed payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:35:56.825Z",
"localTimestamp": "2017-02-23T12:35:56.825-07:00",
"id": "f:1406033e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype",
"name": "New Team Name"
},
"eventType": "teamRenamed",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Team deleted payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:35:56.825Z",
"localTimestamp": "2017-02-23T12:35:56.825-07:00",
"id": "f:1406033e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype",
"name": "Team Name"
},
"eventType": "teamDeleted",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Team restored payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:35:56.825Z",
"localTimestamp": "2017-02-23T12:35:56.825-07:00",
"id": "f:1406033e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype",
"name": "Team Name"
},
"eventType": "teamRestored",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Team archived payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:35:56.825Z",
"localTimestamp": "2017-02-23T12:35:56.825-07:00",
"id": "f:1406033e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype",
"name": "Team Name"
},
"eventType": "teamArchived",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Team unarchived payload
{
"type": "conversationUpdate",
"timestamp": "2017-02-23T19:35:56.825Z",
"localTimestamp": "2017-02-23T12:35:56.825-07:00",
"id": "f:1406033e",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype",
"name": "Team Name"
},
"eventType": "teamUnarchived",
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
}
}
Reactions added payload
{
"reactionsAdded": [
{
"type": "like"
}
],
"type": "messageReaction",
"timestamp": "2017-10-16T18:45:41.943Z",
"id": "f:9f78d1f3",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA",
"aadObjectId": "c33aafc4-646d-4543-9d4c-abd28e4d2110"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:3629591d4b774aa08cb0887902eee7c1@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"channel": {
"id": "19:3629591d4b774aa08cb0887902eee7c1@thread.skype"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
},
"replyToId": "1575667808184",
"legacy": {
"replyToId": "1:19uJ8TZA1cZcms7-2HLOW3pWRF4nSWEoVnRqc0DPa_kY"
}
}
Reactions removed payload
{
"reactionsRemoved": [
{
"type": "like"
}
],
"type": "messageReaction",
"timestamp": "2017-10-16T18:45:41.943Z",
"id": "f:9f78d1f3",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/amer-client-ss.msg/",
"from": {
"id": "29:1I9Is_Sx0O-Iy2rQ7Xz1lcaPKlO9eqmBRTBuW6XzkFtcjqxTjPaCMij8BVMdBcL9L_RwWNJyAHFQb0TRzXgyQvA",
"aadObjectId": "c33aafc4-646d-4543-9d4c-abd28e4d2110"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"id": "19:3629591d4b774aa08cb0887902eee7c1@thread.skype"
},
"recipient": {
"id": "28:f5d48856-5b42-41a0-8c3a-c5f944b679b0",
"name": "SongsuggesterLocal"
},
"channelData": {
"channel": {
"id": "19:3629591d4b774aa08cb0887902eee7c1@thread.skype"
},
"team": {
"id": "19:efa9296d959346209fea44151c742e73@thread.skype"
},
"tenant": {
"id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
},
"replyToId": "1575667808184",
"legacy": {
"replyToId": "1:19uJ8TZA1cZcms7-2HLOW3pWRF4nSWEoVnRqc0DPa_kY"
}
}
Installation update payload
{
"type": "installationUpdate",
"id": "f:816eb23d-bfa1-afa3-dfeb-d2aa338e9541",
"timestamp": "2021-11-09T04:47:30.91Z",
"serviceUrl": "https://smba.trafficmanager.net/amer/",
"channelId": "msteams",
"from": {
"id": "29:1ljv6N86roXr5pjPrCJVIz6xHh5QxjI....",
"aadObjectId": "eddfa9d4-346e-4cce-a18f-fa6261ad776b"
},
"recipient": {
"id": "28:608cacfd-1cea-40c9-b678-4b93e69bb72b",
"name": "Test Agent"
},
"locale": "en-US",
"entities": [
{
"type": "clientInfo",
"locale": "en-US"
}
],
"conversation": {
"isGroup": true,
"id": "19:0b7f32667e064dd9b25d7969801541f4@thread.tacv2",
"name": "2021 Test Channel",
"conversationType": "channel",
"tenantId": "b28fdbfd-2b78-4f93-b0f8-8881793f0f8f"
},
"channelData": {
"settings": {
"selectedChannel": {
"id": "19:0b7f32667e064dd9b25d7969801541f4@thread.tacv2"
}
},
"channel": {
"id": "19:0b7f32667e064dd9b25d7969801541f4@thread.tacv2"
},
"team": {
"aadGroupId": "da849743-4259-475f-ae7a-4f4b0fb49943",
"name": "TestTeam2022",
"id": "19:zFLSDFWsesfzcmKArqKJ-65aOXJz@sgf462H2wz41@thread.tacv2"
},
"tenant": {
"id": "b28fdbfd-2b78-4f93-b0f8-8881793f0f8f"
},
"source": {
"name": "message"
}
},
"action": "add"
}