rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
422 stars 78 forks source link

Allow passing a json object from the Cards playgrounds #72

Closed elChapoSing closed 4 years ago

elChapoSing commented 4 years ago

I understand that the whole point of the library is to provide a nice wrapper around building the payload but why not allow it to be passed or overriden ?

Maybe I am missing something but when I try to set the payload (which I got from a random https://amdesigner.azurewebsites.net/ design) by doing :

teams_msg = pymsteams.connectorcard(self.channel_url)
teams_msg.payload = {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "Container",
            "id": "4c2dc9a5-c7e3-47a4-bc91-0757cd2111df",
            "padding": "None",
            "items": [
                {
                    "type": "FactSet",
                    "id": "33ddcb61-e98f-6ca1-f966-b8297fef4a55",
                    "facts": [
                        {
                            "title": "Blah",
                            "value": "Blah"
                        },
                        {
                            "title": "Blah2",
                            "value": "Blah3"
                        }
                    ]
                },
                {
                    "type": "ColumnSet",
                    "id": "dcd32e4a-b929-f5bb-0baa-be2c05450912",
                    "columns": [
                        {
                            "type": "Column",
                            "id": "88bd4cc2-80f3-1529-7a44-a18481018ce9",
                            "padding": "None",
                            "width": "auto",
                            "items": [
                                {
                                    "type": "Input.Date",
                                    "id": "61b02780-cae1-f98c-105e-f11e9c74a9c1"
                                }
                            ]
                        }
                    ],
                    "padding": "None"
                }
            ]
        }
    ],
    "padding": "None"
}
teams_msg.text("test text")
teams_msg.send()

I get a regular message in the channel, not the one I had designed. I had to add a text because otherwise it would fail with a 400 error (Summary or Text is required).

Is there a specific, more restrictive card playground that is compatible with Teams only maybe ?

SamPetherbridge commented 4 years ago

Unfortunately the Webhook URL requires the use of the legacy MessageCard format. You will need to use the MessageCard Designer available at https://messagecardplayground.azurewebsites.net/

Documentation: https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors