N1netails is an open-source project that provides practical alerts and monitoring for applications. Use the N1netails Teams Webhook Client to easily send webhook messages to a teams channel.
In order to use this webhook client you will need to have a Microsoft 365 Business account.
- In Microsoft Teams, choose a channel and from the options menu (...) select Workflows.
- Search for Send webhook alerts to a channel and select it.
- Provide a name for your new webhook select Next.
- In the details section select the Microsoft Teams Team and the Microsoft Teams Channel you want the webhook to be linked to select Add Workflow.
- The dialog will present a unique URL that maps to the channel. Copy this webhook URL.
- Your webhook is now ready to receive messages.
You can confirm your workflow is set up correctly by going to the channel where the workflow is installed.
- Click on More Options it will be three dots '...' next to the channel when you hover over it.
- Select Workflows.
- Click Manage in the bottom-left corner.
- Hover over your target webhook and select More commands → Edit.
If configured correctly, it should look like the image below:
Install the teams webhook client by adding the following dependency:
<dependency>
<groupId>com.n1netails</groupId>
<artifactId>n1netails-teams-webhook-client</artifactId>
<version>0.3.0</version>
</dependency>Gradle (Groovy)
implementation 'com.n1netails:n1netails-teams-webhook-client:0.3.0'To send a message to your Teams channel, use the TeamsWebhookClient.
import com.n1netails.n1netails.teams.api.TeamsWebhookClient;
import com.n1netails.n1netails.teams.internal.TeamsWebhookClientImpl;
import com.n1netails.n1netails.teams.model.WebhookMessage;
import com.n1netails.n1netails.teams.service.WebhookService;
public class Example {
public static void main(String[] args) {
try {
WebhookService webhookService = new WebhookService();
TeamsWebhookClient client = new TeamsWebhookClientImpl(webhookService);
WebhookMessage message = new WebhookMessage();
message.setContent("Hello, from n1netails-teams-webhook-client!");
client.sendMessage("YOUR_WEBHOOK_URL", message);
} catch (Exception e) {
e.printStackTrace();
}
}
}The message card is a more flexible and customizable way to send messages.
import com.n1netails.n1netails.teams.api.TeamsWebhookClient;
import com.n1netails.n1netails.teams.internal.TeamsWebhookClientImpl;
import com.n1netails.n1netails.teams.model.*;
import com.n1netails.n1netails.teams.service.WebhookService;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Example {
public static void main(String[] args) {
try {
WebhookService webhookService = new WebhookService();
TeamsWebhookClient client = new TeamsWebhookClientImpl(webhookService);
MessageCard messageCard = new MessageCard();
messageCard.setTitle("Message Card Title");
messageCard.setSummary("Message Card Summary");
List<Section> sections = new ArrayList<>();
Section section = new Section();
section.setTitle("Section Title");
List<Fact> facts = new ArrayList<>();
facts.add(new Fact("Fact 1", "Fact 1 Value"));
facts.add(new Fact("Fact 2", "Fact 2 Value"));
section.setFacts(facts);
section.setImageUrl("https://raw.githubusercontent.com/n1netails/n1netails/refs/heads/main/n1netails_icon_transparent.png");
sections.add(section);
messageCard.setSections(sections);
List<Action> actions = new ArrayList<>();
actions.add(new Action("View Website", "https://github.com/n1netails/n1netails-teams-webhook-client"));
messageCard.setActions(actions);
client.sendMessage("YOUR_WEBHOOK_URL", messageCard);
} catch (Exception e) {
e.printStackTrace();
}
}
}import com.n1netails.n1netails.teams.api.TeamsWebhookClient;
import com.n1netails.n1netails.teams.internal.TeamsWebhookClientImpl;
import com.n1netails.n1netails.teams.model.WebhookMessage;
import com.n1netails.n1netails.teams.service.WebhookService;
public class Example {
public static void main(String[] args) {
try {
WebhookService webhookService = new WebhookService();
TeamsWebhookClient client = new TeamsWebhookClientImpl(webhookService);
WebhookMessage message = new WebhookMessage();
message.setContent("Hello, from n1netails-teams-webhook-client!");
message.setImageUrl("https://raw.githubusercontent.com/n1netails/n1netails/refs/heads/main/n1netails_icon_transparent.png");
List<Action> actions = new ArrayList<>();
actions.add(new Action("Visit Website", "https://github.com/n1netails/n1netails-teams-webhook-client"));
message.setActions(actions);
client.sendMessage("YOUR_WEBHOOK_URL", message);
} catch (Exception e) {
e.printStackTrace();
}
}
}import com.n1netails.n1netails.teams.api.TeamsWebhookClient;
import com.n1netails.n1netails.teams.internal.TeamsWebhookClientImpl;
import com.n1netails.n1netails.teams.model.WebhookMessage;
import com.n1netails.n1netails.teams.service.WebhookService;
public class Example {
public static void main(String[] args) {
try {
WebhookService webhookService = new WebhookService();
TeamsWebhookClient client = new TeamsWebhookClientImpl(webhookService);
WebhookMessage message = new WebhookMessage();
message.setContent("Hello, from n1netails-teams-webhook-client!");
// Gifs are also supported
message.setImageUrl("https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExYmEwajlsZjBqb2d2Zmk1bmJoYTEyN2Q0czRmOWtmYjd4YWVzMHoxaCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/xsE65jaPsUKUo/giphy.gif");
List<Action> actions = new ArrayList<>();
actions.add(new Action("Visit Website", "https://github.com/n1netails/n1netails-teams-webhook-client"));
message.setActions(actions);
client.sendMessage("YOUR_WEBHOOK_URL", message);
} catch (Exception e) {
e.printStackTrace();
}
}
}Build the project using the following command
mvn clean installUse the following doc to get setup with publishing to the maven central repository https://central.sonatype.org/register/central-portal/#publishing
Maven install using release profile.
mvn clean install -P releaseMaven deploy to the maven central repository
mvn deploy -P releaseFor community users, open an issue on GitHub or Join our Discord
Please use the following guidelines for contributions CONTRIBUTING




