'MS Teams Bot -- Is it possible to invoke a botMessagePreview from a task/submit activity as opposed to from a composeExtension/submitAction activity?
I am building a messaging extension in Teams that uses task modules and sends adaptive cards.
I want to invoke the same task module from both a messaging extension command and from a button on an adaptive card that is sent to the user.
The intended flow through the application is the following:
End user launches a task module containing a react page by clicking a messaging extension command under the compose box -> user finds an object in the task module -> user clicks an 'export to chat' button on the react page -> microsoftTeams.tasks.submitTask()
is triggered on the react page -> task module closes -> in the bot activity handler handleTeamsMessagingExtensionSubmitAction
returns a botMessagePreview like shown here -> user is able to preview the adaptive card and can send it as a message from the bot to the chat.
The adaptive card contains a button "View Object":
{
type: "Action.Submit",
title: "View Object",
data: {
msteams: {
type: "task/fetch",
},
goToUrl: url,
},
}
From the adaptive card, I am able to invoke a task module, but this time I have to use handleTeamsTaskModuleFetch
instead of handleTeamsMessagingExtensionFetchTask
. This means that once the end user submits the task module they will not see the botMessagePreview because that functionality seems to be exclusive to the messaging extension. Is there any way I can work around this?
So far I have tried duplicating my logic from the messaging extension handlers in handleTeamsTaskModuleFetch
and handleTeamsTaskModuleSubmit
but I haven't found a way to avoid side effects that crash my app or a way to display the botMessagePreview.
Solution 1:[1]
This seems to be not possible to invoke a botMessagePreview from a task/submit activity.
botMessagePreview functionality is not supported for task/submit activity.
This functionality supported in Messaging extension.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nivedipa-MSFT |