How to mention people in Teams messages?

Solved!
lightnessofbein
Level 2
How to mention people in Teams messages?

Hey!

Right now I'm using Reporters + Teams Adaptive cards to mention people inside messages. Is there a way to mention people via Python API messaging? Something like 

message_sender = scenario.get_message_sender("LS_data_ingestions_channel")
# some HTML-formatted text
html_message = "<p style='color:orange'>Your scenario is running!@NameSurname</p>"
message_sender.send(subject="The scenario is doing well", message=html_message, sendAsHTML=True)

The second possible solution is sending adaptive cards jsons via message_sender. There are no examples/docs on that subject, unfortunately. Does anyone know if it is possible to do so? 

0 Kudos
1 Solution
AlexT
Dataiker

A similar approach could work to send you can create a team channel in Administration -Settings - Notifications & Integrations.

from dataiku.scenario import Scenario

json_payload = """{
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "themeColor": "${if(outcome == 'SUCCESS', '29AF5D', '')}${if(outcome == 'FAILED', 'F44336', '')}${if(outcome == '', '28A9DD', '')}",
    "summary": "${scenarioName} run report",
    "sections": [
        {
            "text": "${if(outcome == 'SUCCESS', '&#x2705;', '')}${if(outcome == 'FAILED', '&#x1F534;', '')}${if(outcome == '', '&#x1F514;', '')} [${scenarioName}](${scenarioRunURL}): **${outcome}**",
            "facts": [
                { "name": "Project", "value": "${scenarioProjectKey}" },
                { "name": "Triggered by", "value": "${triggerName}" }
            ]
        }
    ],
    "potentialAction": [
        {
            "@type": "OpenUri",
            "name": "View in DSS",
            "targets": [
                { "os": "default", "uri": "${scenarioRunURL}" }
            ]
        }
    ]
}"""


scenario = Scenario()
sender = scenario.get_message_sender("msft-teams")
sender.send(message=json_payload)

I don't have a Microsoft team account to test, but it worked with a webhook endpoint the payload was received accordingly.

Thanks


View solution in original post

3 Replies
AlexT
Dataiker

Hi,

You should be able to use "@username" or @channel_name  within a message or message card.
You can find an example of message card here :
https://doc.dataiku.com/dss/latest/scenarios/reporters.html#microsoft-teams-integration-setup

Thanks

0 Kudos
lightnessofbein
Level 2
Author

Hey, it is only possible to mention someone using Adaptive cards. Here is an example link

However, I'm only able to configure the Adaptive card json in scenario UI, there is no documented way on how json might be passed into Python sender API. And that's what my question is about - is there any way to mention people within Teams messages via Python API?

0 Kudos
AlexT
Dataiker

A similar approach could work to send you can create a team channel in Administration -Settings - Notifications & Integrations.

from dataiku.scenario import Scenario

json_payload = """{
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "themeColor": "${if(outcome == 'SUCCESS', '29AF5D', '')}${if(outcome == 'FAILED', 'F44336', '')}${if(outcome == '', '28A9DD', '')}",
    "summary": "${scenarioName} run report",
    "sections": [
        {
            "text": "${if(outcome == 'SUCCESS', '&#x2705;', '')}${if(outcome == 'FAILED', '&#x1F534;', '')}${if(outcome == '', '&#x1F514;', '')} [${scenarioName}](${scenarioRunURL}): **${outcome}**",
            "facts": [
                { "name": "Project", "value": "${scenarioProjectKey}" },
                { "name": "Triggered by", "value": "${triggerName}" }
            ]
        }
    ],
    "potentialAction": [
        {
            "@type": "OpenUri",
            "name": "View in DSS",
            "targets": [
                { "os": "default", "uri": "${scenarioRunURL}" }
            ]
        }
    ]
}"""


scenario = Scenario()
sender = scenario.get_message_sender("msft-teams")
sender.send(message=json_payload)

I don't have a Microsoft team account to test, but it worked with a webhook endpoint the payload was received accordingly.

Thanks