问题
I have a message extension, available on the "..." message context menu, that launches a Task Module. In the task module, I submit some sample data (e.g. microsoftTeams.tasks.submitTask({"x":"y"});
)
I receive the call for "composeExtension/submitAction", but when I try insert something into the compose box, by submitting a response like the following:
var card = new HeroCard
{
Title = "foo",
Text = "bar"
};
var attachments = new List<MessagingExtensionAttachment>();
attachments.Add(new MessagingExtensionAttachment
{
Content = card,
ContentType = HeroCard.ContentType,
Preview = card.ToAttachment(),
});
var activity = new Activity
{
Type = ActivityTypesEx.InvokeResponse,
Value = new InvokeResponse
{
Status = (int)HttpStatusCode.OK,
Body = new MessagingExtensionActionResponse
{
ComposeExtension = new MessagingExtensionResult
{
AttachmentLayout = "list",
Type = "result",
Attachments = attachments
},
}
}
};
await turnContext.SendActivityAsync(activity, cancellationToken: cancellationToken);
Then I get an error on the task module, and in the browser debug tools I see the following error:
<BotError>Error when processing invoke response: Task or Task Type is missing in Task Module response
Here is the payload being returned from my bot to Teams:
{
"task": null,
"composeExtension": {
"attachmentLayout": "list",
"type": "result",
"attachments": [
{
"preview": {
"contentType": "application/vnd.microsoft.card.hero",
"contentUrl": null,
"content": {
"title": "foo",
"subtitle": null,
"text": "bar",
"images": null,
"buttons": null,
"tap": null
},
"name": null,
"thumbnailUrl": null
},
"contentType": "application/vnd.microsoft.card.hero",
"contentUrl": null,
"content": {
"title": "foo",
"subtitle": null,
"text": "bar",
"images": null,
"buttons": null,
"tap": null
},
"name": null,
"thumbnailUrl": null
}
],
"suggestedActions": null,
"text": null,
"activityPreview": null
}
}
The empty "task" object is there because of the "MessagingExtensionActionResponse" type, but I've tried removing it with my own custom type, and I've also tried various ideas of what to possibly put inside there. Per the docs, I can't actually see that a "task" is required though (e.g. per here).
Can anybody see where I'm going wrong, or how to guide me to a working solution on this.
来源:https://stackoverflow.com/questions/61175591/error-inserting-adaptive-card-to-compose-box-from-a-message-extension-composeex