How to use pymsteams - 1 common examples

To help you get started, we’ve selected a few pymsteams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alerta / alerta-contrib / plugins / msteams / alerta_msteams.py View on Github external
LOG.error('MS Teams: ERROR - Template(TEXT_FMT) render failed: %s', e)
                    return
            else:
                text = alert.text

            LOG.debug('MS Teams payload: %s', summary)

        try:
            if MS_TEAMS_PAYLOAD:
                # Use requests.post to send raw json message card
                LOG.debug("MS Teams sending(json payload) POST to %s", MS_TEAMS_WEBHOOK_URL)
                r = requests.post(MS_TEAMS_WEBHOOK_URL, data=card_json, timeout=MS_TEAMS_DEFAULT_TIMEOUT)
                LOG.debug('MS Teams response: %s / %s' % (r.status_code, r.text))
            else:
                # Use pymsteams to send card
                msTeamsMessage = pymsteams.connectorcard(hookurl=MS_TEAMS_WEBHOOK_URL, http_timeout=MS_TEAMS_DEFAULT_TIMEOUT)
                msTeamsMessage.title(summary)
                msTeamsMessage.text(text)
                msTeamsMessage.addLinkButton("Open in Alerta", url)
                msTeamsMessage.color(color)
                msTeamsMessage.send()
        except Exception as e:
            raise RuntimeError("MS Teams: ERROR - %s", e)

pymsteams

Format messages and post to Microsoft Teams.

Apache-2.0
Latest version published 3 days ago

Package Health Score

71 / 100
Full package analysis

Popular pymsteams functions

Similar packages