Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my chatbot refresh cards in Teams not refreshing?

I am serving out O365 connector cards to my teams channel in my chatbot, for the user to use an HttpPost action to send data back to the bot. Here is a sample invoke message when the user saves:

{
    "name": "actionableMessage/executeAction",
    "type": "invoke",
    "timestamp": "2018-06-16T20:58:24.388Z",
    "localTimestamp": "2018-06-16T21:58:24.388+01:00",
    "id": "snip",
    "channelId": "msteams",
    "serviceUrl": "https://smba.trafficmanager.net/emea-client-ss.msg/",
    "from": {
        "id": "snip",
        "name": "my name",
        "aadObjectId": "snip"
    },
    "conversation": {
        "conversationType": "personal",
        "id": "long conversation id"
    },
    "recipient": {
        "id": "bot id",
        "name": "bot name"
    },
    "entities": [
        {
            "locale": "en-US",
            "country": "US",
            "platform": "Web",
            "type": "clientInfo"
        }
    ],
    "channelData": {
        "tenant": {
            "id": "tenant id"
        },
        "source": {
            "name": "message"
        }
    },
    "replyToId": "message id",
    "value": {
        "body": "{\"sportType\":\"1\", \"tournamentName\":\"FIFA Soccer World Cup\",\"startTime\":\"2018-06-14T03: 00: 00.000Z\", \"endTime\":\"2018-07-16T07: 30: 00.000Z\", \"timeZone\":\"Russian Standard Time\", \"tournamentId\": \"1\"}",
        "actionId": "SaveTournament"
    }
}

In response to a save card, I am returning an ActionCard in the response body, and I am including an HTTP header "CARD-UPDATE-IN-BODY" with a value "true". Here is a sample response message:

{
    "@type": "ActionCard",
    "inputs": [
        {
            "@type": "TextInput",
            "isMultiline": true,
            "maxLength": 500.0,
            "id": "SaveStatus",
            "isRequired": false,
            "title": "Save Status",
            "value": "You updated the tournament FIFA Soccer World Cup running from 6/14/2018 to 7/16/2018 in timezone Russian Standard Time"
        }
    ],
    "actions": [
        {
            "@type": "HttpPOST",
            "body": "{\"tournamentId\": \"1\"}",
            "name": "Update FIFA Soccer World Cup again",
            "@id": "UpdateTournament#1"
        }
    ],
    "name": "Save Tournament",
    "@id": "SaveTournament"
}

I have traced this in my web app so I know that is what is being returned to the bot framework middleware.

In my teams app in the browser,when I trace the response message with Fiddler, the card invoke response is not getting the refresh card I send, it is just getting a generic 200 response with an empty response body. Can anyone point me to a demo of refresh cards that work with Teams, or tell me what's wrong with my messages?

like image 978
Joon Avatar asked Dec 18 '25 23:12

Joon


1 Answers

Teams doesn't support updating the original card by responding to the invoke message. Instead, you need to explicitly update the message by calling the Bot Framework API (see https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bot-conversations/bots-conversations#updating-messages).

The incoming invoke message has the information you need to update the original message:

<serviceurl>/v3/conversations/<conversationid>/activities/<activityid>

  • <serviceurl>: serviceUrl
  • <conversationid>: conversation.id
  • <activityid>: replyToId

(The details of how to update a message depends on exactly which SDK you're using, but in the end you'll need those 3 items to refer to the message.)

like image 114
Adrian Solis Avatar answered Dec 21 '25 06:12

Adrian Solis