mstlib is a lightweight Java library for building and sending Microsoft Teams Incoming Webhook Adaptive Cards with ease.
This library simplifies the process of creating rich messages using Adaptive Cards and posting them to Teams channels via incoming webhooks.
- Create Adaptive Cards in Java with a fluent API
- Post cards directly to Microsoft Teams via Incoming Webhooks
- Supports text blocks, images, facts and more
Add the following to your pom.xml
(Maven):
<dependency>
<groupId>de.scplabs</groupId>
<artifactId>mstlib</artifactId>
<version>1.0.0</version>
</dependency>
Follow Microsoft's documentation to create an Incoming Webhook for your Teams channel.
import de.scplabs.mstlib.IncomingWebhookBuilder;
import de.scplabs.mstlib.Webhook;
public class Main {
public static void main(String[] args) {
IncomingWebhookBuilder builder = new IncomingWebhookBuilder("WEBHOOK_URL");
Webhook wh = builder
.addTextBlock("Hello Teams!").getStyle(FontStyle.BOLD).prev()
.addTextBlock("This is a sample Adaptive Card.").prev()
.build();
wh.execute();
}
}
- ✅ TextBlock
- ✅ Image
- ✅ Media
- ✅ MediaSource
- ✅ CaptionSource
- ✅ RichTextBlock
- ✅ TextRun
- ✅ Container
- ✅ ColumnSet
- ✅ Column
- ✅ FactSet
- ✅ Fact
- ✅ ImageSet
- ✅ Table
- ✅ TableCell
- ✅ BackgroundImage
git clone https://github.com/Flo0205/mstlib.git
cd mstlib
mvn clean install
MIT License. See LICENSE for details.
Pull requests are welcome!
If you’d like to improve or extend the library, please open an issue or PR.
Created by Florian Keil