Search code examples
c#microsoft-teamsadaptive-cards

refresh for user specific views in adaptive card are not triggering Invoke


Currently trying to implement a User Specific View for adaptive Cards.

The documentation shows how to auto refresh an adaptive Card and also how to deal with the invoke. I implemented my BotMessageActivity and whenever I write something to the bot response with a card as a result:

await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);

So far so good. I receive the Card but somehow my I InvokeActivity is not getting triggered:

protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken){...}

My main goal is to change the title and value of the URL at the end.

This is how my adaptive Card looks like:

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.4",
"refresh": {
    "action": {
        "type": "Action.Execute",
        "title": "Refresh",
        "verb": "refresh",
        "data": {
            "CreatedBy": "test"
        }
    },
    "userIds": [
        "999111999111999111"
    ]
},
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "Image",
                            "url": "URL"
                        }
                    ]
                }
            ]
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "auto",
                    "items": [
                        {
                            "type": "Image",
                            "url": "URL"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "TestText",
                            "wrap": true,
                            "weight": "Bolder"
                        },
                        {
                            "color": "default",
                            "horizontalAlignment": "left",
                            "isSubtle": false,
                            "size": "medium",
                            "weight": "default",
                            "type": "TextBlock",
                            "text": "TestText",
                            "wrap": true,
                            "spacing": "medium"
                        }
                    ],
                    "verticalContentAlignment": "center"
                }
            ]
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "title": "TestId",
                                    "value": "JustAnId"
                                },
                                {
                                    "title": "AnyData",
                                    "value": "AnyTest"
                                }
                            ]
                        }
                    ]
                }
            ],
            "spacing": "medium"
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.OpenUrl",
                    "title": "ButtonA",
                    "url": "UrlA"
                }
            ],
            "spacing": "medium"
        }
    ]
}

Solution

  • I thought I could simply use the User Object ID for testing purposes and that the User Object ID is the same Value as the MRI. However, I discovered that this was not the case; the MRI and User Object ID are indeed different entities.

    After entering the right MRI value, the Bot was able to call the Invoke method.