Skip to main content

msteams-connector is a Python-based tool to simplify the process of sending messages, adaptive card to Microsoft Teams channels via incoming webhooks. Whether you’re automating release notifications, error alerts, or general messages, this connector provides a seamless interface for working with Microsoft Teams.

Project description

msteams-connector

A Python connector for sending messages to Microsoft Teams channels via webhooks.

Python MSTeams PyPI PyPI - Downloads GitHub CI codecov

Overview

msteams-connector is a Python-based library to simplify the process of sending messages, adaptive cards to Microsoft Teams channels via incoming webhooks. Whether you need to automate notifications, release announcements, or send custom messages, this connector provides a seamless interface for working with Microsoft Teams.

Prerequisites

Get MSTeams Webhook

Before using this package, you will need to obtain an MS Teams webhook URL. Follow the instructions in the Microsoft Teams Documentation to create a new incoming webhook in your MS Teams channel.

Installation

Install the library via pip:

pip install msteams_con

Usage

Example Code

Here is an example of how to send a basic text message to an MS Teams channel using this library:

from msteams_con import *
import os

hook_url = os.environ["MSTEAMS_WEBHOOK"]

msteams = MSTeamsConnector(hook_url)
payload = msteams.generate_text_payload("Hello World!")
msteams.send_payload(payload)

CLI

The package also provides CLI commands for sending messages to MS Teams.

Send with our release card template

msteams-connector send_release_card --version <software-release-version> --hook_url <your_webhook_url>

Send a simple text message

msteams-connector send_text --text "Hello World!" --hook_url <your_webhook_url> 

Video Instructions

Watch the video

Developer Setup

If you want to contribute or modify the code, follow these steps to set up the project locally:

git clone https://github.com/cloud-bees/msteams-connector.git
cd msteams-connector
export PYTHONPATH=$(pwd)
export MSTEAMS_WEBHOOK=<your_webhook_url>
pip install -e ".[dev]"

This installs the package in editable mode along with all development dependencies.

Running Tests

To run tests and check code quality, use the following commands:

Pytest

Run the unit tests using pytest:

pytest tests -v -s --log-cli-level=DEBUG

You can also run pytest in Visual Studio Code Debug mode. Make sure to add the WEBHOOK environment variable in .vscode/launch.json and set the Python interpreter correctly.

Ruff for Linting and Formatting

To check and autofix formatting issues, use ruff:

ruff check --fix
ruff format

Contribution Guidelines

If you want to contribute:

  1. Fork the repository.
  2. Create a feature branch.
  3. Submit a pull request with a clear description of the changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msteams_con-1.0.1.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

msteams_con-1.0.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file msteams_con-1.0.1.tar.gz.

File metadata

  • Download URL: msteams_con-1.0.1.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for msteams_con-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c7c1749220755d99af710e9d0fe62e706c852341a2d9ae0cba651641b54bb567
MD5 6aaac3e911f38599673a8f70dde84239
BLAKE2b-256 e2c413df284e3d9078b9783715fec7b074bb5cb2f3d8aa4f58fb93703125c022

See more details on using hashes here.

File details

Details for the file msteams_con-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: msteams_con-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for msteams_con-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edc98be4b131d0cf5631e41f31a21d450333cc5fcd2b91a841c47cc04b5a91c8
MD5 3fe328873885bed20e449d71149aec03
BLAKE2b-256 dc6293b6c8b3f7e87ca139ea9ec978caa31870335f5569bf9656c787e407f954

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page