I'm trying to implement the function that user can add tag in card using Input.ChoiceSet. Since it seems there is no action invoked by selecting tag from the shown tag list(choises), I'm trying to do it with "Action.Execute" button. But when I click button, its added tag disappears from the input form.
How can I avoid it?
My current code is:
public async onInvokeActivity(context: any): Promise<any> {
if (
context.activity.name === "adaptiveCard/action" &&
context.activity.value.action.verb === "submitTags"
) {
console.log(
"adaptive card action is ",
context.activity.value.action.data
);
const submittedTags = context.activity.value.action.data?.tagsChoiceSet;
updateSelectedValuesInCard(submittedTags);
return {
status: 200,
body: sentCard,
};
}
////other code
return super.onInvokeActivity(context);
}
function updateSelectedValuesInCard(newValues) {
sentCard.attachments[0].content.body[5].value = newValues;
sentCard.attachments[0].content.body[5].choices = newValues
.split(",")
.map((tag) => {
return { title: tag, value: tag, selected: true };
});
console.log(
"new values are ",
newValues,
"choices are ",
sentCard.attachments[0].content.body[5].choices
);
return sentCard;
}
Card:
sentCard = {
type: "message",
attachments: [
{
contentType: "application/vnd.microsoft.card.adaptive",
contentUrl: null,
content: {
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
type: "AdaptiveCard",
version: "1.4",
body: [
///other code
{
type: "TextBlock",
text: submittedMessage,
wrap: true,
size: "Medium",
},
{
type: "TextBlock",
weight: "Bolder",
text: "Tags:",
wrap: true,
size: "Medium",
},
{
type: "Input.ChoiceSet",
id: "tagsChoiceSet",
choices: tagsList,
value: submittedTags,
style: "filtered",
"choices.data": {
type: "Data.Query",
dataset: "tagDataSet",
},
isMultiSelect: true,
},
///other code
],
actions: [
{
data: {
url: originalMessageURL,
id: "choosedTags",
},
type: "Action.Execute",
title: "Save Tags",
verb: "submitTags",
},
],
},
},
],
};