Skip to content

baloise-incubator/ms-teams-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

CI Quality Gate Status

ms-teams-connector

Utilize a AdaptiveCard and publish it to a MS-Teams channel via webhook workflow.

Special thanks goes to Roland Seidel for the idea and his reference implementation.

Change Log

  • Version 0.5.0
    • support blocking thread executor for batch / cli usage
    • ⚠️ Breaking: removed deprecated config parameter
  • Version 0.4.0 is the first version supporting AdaptiveCards
  • Version 0.2.3 is the last version supporting Java 8

Usage

Create a webhook workflow that posts cards in teams

MS Teams webhook workflow screenshot

Add dependency to your project

<dependency>
  <groupId>com.baloise.open</groupId>
  <artifactId>ms-teams-connector</artifactId>
  <version>0.5.0</version>
</dependency>

Create publisher per channel

final String uri = "webhook_url";
final MessagePublisher channelPublisher = MessagePublisher.getInstance(uri);

Now you can publish any message using MessagePublisher (e.g., create and publish a simple message)

final AdaptiveCard msg = AdaptiveCardFactory.createSimpleAdaptiveCard("Title", "Hello **World**");
ScheduledFuture<?> publishedFuture = channelPublisher.publish(msg);

Example

Using MessageCardFactory builder

MessageCardFactory builder extends the "SimpleMessageCard" by adding facts. Facts are key-value pairs added as table below the text.

AdaptiveCardFactory.builder("A crisp title", "A little more descriptive text.")
    .withFact("Status", "Failure")
    .withFact("Reason", "Out of memory")
    .build();

Configuration

Parameter Default Description
PROPERTY_RETRIES 3 Defines the number of retries to publish the message in case of unsuccessful answer from webhook. Accepts any positive integer > 0.
PROPERTY_RETRY_PAUSE 60 Defines the pause time between PROPERTY_RETRIES in seconds. Accepts any positive integer > 0.
PROPERTY_WEBHOOK_URI none The URI to your webhook. Required property provided either as String or URI.
PROPERTY_PROXY_URI none The URI to your web proxy.
PROPERTY_BLOCKING false Set to true to block main thread until message was sent or max retries time is reached. Default is sending messages asynchronously.

System Environment

Alternatively you can also specify a system environment variable named https_proxy to connect via a proxy URL.

About

MS-TEAMS SDK to publish AdaptiveCards to any Teams channel

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 5

Languages