Hello! I'm trying to use ActionTypes.PostBack on card returned from OnTeamsMessagingExtensionSelectItemAsync of my Teams bot with following code:
var card = new ThumbnailCard
{
Title = project.Name,
Buttons = new List<CardAction>
{
new CardAction { Type = ActionTypes.PostBack, Title = "Subscribe", Value = query },
},
};
var attachment = new MessagingExtensionAttachment { ContentType = ThumbnailCard.ContentType, Content = card, };
return Task.FromResult(new MessagingExtensionResponse
{
ComposeExtension = new MessagingExtensionResult
{
Type = "result",
AttachmentLayout = "list",
Attachments = new List<MessagingExtensionAttachment> { attachment }
}
});
but when I press the button in browser I'm getting following error and nothing happens:
TypeError: Cannot read property 'isChannelConversation' of undefined
at t.getAppDefinitionFromCard (https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-c7c53b37.js:3:308254)
at t.logTelementryForCardAction (https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-c7c53b37.js:3:276083)
at _.debounce.trailing (https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-c7c53b37.js:3:148902)
at e (https://statics.teams.cdn.office.net/hashedjs/2-vendor.min-68b363d0.js:64:245)
at f (https://statics.teams.cdn.office.net/hashedjs/2-vendor.min-68b363d0.js:65:49)
at t.e.buttonClicked (https://statics.teams.cdn.office.net/hashedjs/3.2-app.min-c7c53b37.js:3:148400)
Am I sending the card wrong? Is it supported flow? MessageBack and ImBack cause slightly different errors but anyway none of them work for me.
It's duplicate of https://github.com/microsoft/botframework-sdk/issues/5811 but I'm not sure what is the better place to ask the question.
The flow I'm trying to implement is:
As I understand the Card should be sent in order to enable buttons. But is it possible to use buttons without sending the card (while it's in compose message area)? Or can I show prompt instead of sending card into compose area?
BTW it looks like Value of CardAction can be only JObject but not regular object. In case of plain object value will be set to null.
Hello @GDreyV - I would like to help but I have a few questions.
Value of CardAction can be only JObject but not regular object. In case of plain object value will be set to null." what do you mean by a regular object/plain object? JObject derives from object just like all other C# classes.Also, please post a screenshot/gif of the Teams client so we can better understand what's happening
Open button works in all scenarios.
@GDreyV - Thank you for the screenshot, that helps. Would you go ahead and try it in the desktop client and answer question 5?
in the app when I press the button it doesn't do anything. And after couple clicks button kind of hangs:

@GDreyV - What is your answer to question 5?
Oh, sorry, I missed it.
new CardAction {
Type = ActionTypes.MessageBack,
Title = "Subscribe",
Value = new { project.Id }
}
and this code works
new CardAction {
Type = ActionTypes.MessageBack,
Title = "Subscribe",
Value = JObject.FromObject(new { project.Id })
}
@GDreyV - Since you posted in the sample repo, are you following a specific sample? Sample 50 perhaps? https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/50.teams-messaging-extensions-search
really 52.teams-messaging-extensions-search-auth-config, 50 looks pretty the same.
Hi @GDreyV, can you give example data for what you are sending in the card, namely the project.Name and project.Id? Knowing the kinds of data you are sending will be useful. Also, what is expected to happen when "Subscribe" is pressed? Is it supposed to open a link, begin some process by the bot, or something else?
Hello @stevkan project.Name and project.Id are just simple string values. Specifically Name is just something like "New project" and Value is converted to string mongo id. Subscribe button is represented by the action:
new CardAction { Type = ActionTypes.PostBack, Title = "Subscribe", Value = query }
where query is { project.Id }. So I suppose when card is in the message composing area buttons should be either disabled (if it not supposed to be pressed) or should work correctly. Right now nothing happens except errors in console.
@GDreyV, thank you for your patience. I am working on this and hope to have some response to you shortly.
@stevkan, I'm not sure if it's related issue but here the case. I sent card into the General channel with Subscribe button as in the example above. User who is not authorized in the bot is pressing that button and nothing happens. The error in the console says:
angular.min.js:113 2020-05-06T00:10:28.848Z AppsService: getInstalledAppForTeam - Invalid teamId and/or appId specified
(anonymous) @ angular.min.js:113
e.logMessage @ msteams-web-ng1-services.min.js:1
e.error @ msteams-web-ng1-services.min.js:1
t.getInstalledAppForTeam @ msteams-web-ng1-services.min.js:1
(anonymous) @ msteams-web-ng1-services.min.js:1
f @ angular.min.js:126
(anonymous) @ angular.min.js:126
$eval @ angular.min.js:141
$digest @ angular.min.js:138
f.$digest @ msteams-web-ng1-services.min.js:1
$apply @ angular.min.js:141
(anonymous) @ angular.min.js:269
dispatch @ jquery.min.js:1
v.handle @ jquery.min.js:1
msteams-web-common.min.js:1 Uncaught (in promise) Invalid teamId and/or appId specified
(anonymous) @ msteams-web-common.min.js:1
f @ angular.min.js:126
(anonymous) @ angular.min.js:126
$eval @ angular.min.js:141
$digest @ angular.min.js:138
f.$digest @ msteams-web-ng1-services.min.js:1
$apply @ angular.min.js:141
(anonymous) @ angular.min.js:269
dispatch @ jquery.min.js:1
v.handle @ jquery.min.js:1
Should I create separate issue for that?
@GDreyV, to clarify, is the error occurring in 1:1, channel, or both? And, as you mentioned unauthorized bot users, is it occurring for both authorized and unauthorized users?
Also, if you wouldn't mind, can you post your bot's manifest? It might be a red herring, but I'd like to see all applicable parts.
We didn't test these issues in 1:1 conversation, so it was channel and multiusers conversation. The last error I sent was just for not authorized user.
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0",
"bots": [
{
"botId": "",
"scopes": [ "personal", "team" ],
"supportsFiles": false,
"isNotificationOnly": false,
"commandLists": [
{
"scopes": [ "personal" ],
"commands": [
{ "title": "Help", "description": "Show help info" },
{ "title": "Sign In", "description": "Sign in into account for links unfurling and notifications" },
{ "title": "Sign Out", "description": "Sign out from the account" },
{ "title": "Subscribe to {url}", "description": "Subscribe for updates" },
{ "title": "Unsubscribe from {url}", "description": "Unsubscribe from updates" }
]
}
]
}
],
"composeExtensions": [
{
"botId": "",
"commands": [
{
"id": "searchQuery",
"type": "query",
"title": "Search",
"description": "Perform a projects search",
"initialRun": false,
"fetchTask": false,
"context": [ "commandBox", "compose", "message" ],
"parameters": [ { "name": "searchQuery", "title": "Search", "description": "Project's name", "inputType": "text" } ]
}
],
"messageHandlers": [
{
"type": "link",
"value": {
"domains": [ "*.domain.com" ]
}
}
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [ "*.domain.com", "*.botframework.com" ]
}
@stevkan Can you update the status of this for the customer?
@GDreyV, I just noticed you are trying to send a "postBack" action type which is not supported in Teams. If you are trying to send a message back to the bot that is not intended to be displayed to the user, you will want to use the "invoke" action type, referenced here. A response should look something similar to this.
Please try with one of the supported action types and let me know if the issue resolves itself or persists.
Sorry, it was incorrect code pasted, really the code is:
new CardAction { Type = ActionTypes.MessageBack, Title = "Subscribe", Value = JObject.FromObject(new { project.Id }) }
Can you show me the method in your bot that you are using to handle the incoming MessageBack?
Sorry, it might be wrong but as I recall this one:
protected async override Task OnTeamsMessagingExtensionCardButtonClickedAsync(
ITurnContext<IInvokeActivity> turnContext,
JObject cardData,
CancellationToken cancellationToken)
{
if (cardData != null && cardData.ContainsKey("Id"))
{
await this.subscribeFlow.SubscribeToProject(cardData["Id"].Value<string>(), turnContext, cancellationToken);
}
}
but really in the cases we faced this method was not called. We were just facing numerous exceptions in the browser.
Hi @GDreyV, on April 21st (when you posted the issue), you stated
But is it possible to use buttons without sending the card (while it's in compose message area)?
In subsequent readings, I missed the "in compose message area" of that question. Unfortunately, the answer is no. While the card is in the compose message state, the actions associated with any buttons are outside the context of the bot as the card, itself, hasn't entered the message thread, yet. This means that any action you would wish the bot to respond to cannot occur because it can't reach the bot until the card is sent by the user.
As you can see in this doc, all the card actions mention interacting with the bot in some way. It's not surprising that openUrl is the only action that _does_ work because the context of that action is separate from the bot and Teams.
Ah, thank a lot for the details. I got it. Thank you for your time and investigation!