How to mention people in Teams messages?

Registered Posts: 5
edited July 2024 in Using Dataiku

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&lt;/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?

Best Answer

  • Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,270 Dataiker
    edited July 2024 Answer ✓

    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


Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.