How to send Slack Message using JAVA


1. Get URL from admin who look after Slack. ASk him to create a hook and give the URL

String url = "https://hooks.slack.com/services/starts like tis but it has some alphanumericoverlength";

2. Create a channel on your slack where you login succesfully. you should belong to same group as hooks created by admin
String channelName = "#channel";

3. Below is the code to send slack message

Payload payload = Payload.builder().channel(channelName).username("Test Automation Results")
.iconEmoji(":robot_face:")
.text("Hi, Please find the Test Automation Results after Deployment Run.   Kind Regards  \n Test Automation Team")
.build();

Slack slack = Slack.getInstance();
WebhookResponse response = slack.send(url, payload);

Comments

Popular posts from this blog

Inspect iOS app using Appium Inspector

How to Upload a file to S3 Bucket on AWS using JAVA

Android Native element functions / classes Appium