{"id":390581,"date":"2024-06-29T09:19:45","date_gmt":"2024-06-29T09:19:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=390581"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-29T09:19:45","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=390581","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e slack-\u0431\u043e\u0442\u0430 \u043d\u0430 Java<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u2014 \u0421\u0430\u0448\u0430 \u041a\u0430\u0437\u0430\u043d\u0446\u0435\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 hh.ru. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0432 Slack \u043d\u0430 java \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f slack api.<\/p>\n<p>\u0421\u043b\u0430\u043a \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u043e\u0439 \u0438 \u0432\u0441\u0435\u043e\u0431\u044a\u0435\u043c\u043b\u044e\u0449\u0435\u0439 <a href=\"https:\/\/api.slack.com\/docs\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/u><\/a> \u0438 <a href=\"https:\/\/api.slack.com\/tutorials\"><u>\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u043c\u0438<\/u><\/a>, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430, \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u043b\u0430\u043f\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0438\u043b\u0438\u043c \u043f\u043e-\u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443.\u00a0<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u043e\u043c\u0443 \u043b\u0435\u043d\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435: \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u043e\u0442\u0430, \u0430 \u043f\u043e\u0441\u043b\u0435 \u2014 \u043b\u0438\u0440\u0438\u043a\u0430 \u043f\u0440\u043e \u043d\u0430\u0448\u0438\u0445. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d66\/674\/c96\/d66674c96187c8b2ebfb4b27c250ff8d.png\" alt=\"Slack \u0442\u0435\u0431\u0435 \u0432 \u0440\u0443\u043a\u0438!\" title=\"Slack \u0442\u0435\u0431\u0435 \u0432 \u0440\u0443\u043a\u0438!\" width=\"1600\" height=\"900\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d66\/674\/c96\/d66674c96187c8b2ebfb4b27c250ff8d.png\"\/><figcaption>Slack \u0442\u0435\u0431\u0435 \u0432 \u0440\u0443\u043a\u0438!<\/figcaption><\/figure>\n<p><strong>\u041a\u0440\u0443\u0447\u0443 \u0440\u0443\u0447\u043a\u0443, \u043f\u0438\u0448\u0443 \u0431\u043e\u0442\u0430<\/strong><\/p>\n<p>\u0411\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0439 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u201c<a href=\"https:\/\/api.slack.com\/apps\"><u>\u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435<\/u><\/a>\u201d. \u0411\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/api.slack.com\/tutorials\/tracks\/hello-world-bolt\"><u>\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435<\/u><\/a><strong>.<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <strong>From scratch. <\/strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9ae\/04a\/c87\/9ae04ac8747ce42d8f9c23f3eabc1d0d.png\" width=\"518\" height=\"370\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ae\/04a\/c87\/9ae04ac8747ce42d8f9c23f3eabc1d0d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043c\u044f \u0438 workspace.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/278\/17f\/adf\/27817fadfc58c3124b840540968963a9.png\" width=\"513\" height=\"477\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/278\/17f\/adf\/27817fadfc58c3124b840540968963a9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u00a0 \u043c\u0435\u043d\u044e <strong>OAuth &amp; Permissions <\/strong>\u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c <strong>Bot User OAuth Token <\/strong>\u0432\u0438\u0434\u0430 xoxb-YOUR-TOKEN. \u041e\u043d \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u0448\u0435\u043c\u0443 \u0431\u043e\u0442\u0443. \u0412 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u043d\u044e \u043d\u0438\u0436\u0435. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7bd\/c6e\/200\/7bdc6e200040ba3bb2353ce363082659.png\" width=\"232\" height=\"378\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7bd\/c6e\/200\/7bdc6e200040ba3bb2353ce363082659.png\"\/><figcaption><\/figcaption><\/figure>\n<p><em>Slack \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0438\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u043a\u043e\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f.<\/em><\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <\/summary>\n<div class=\"spoiler__content\">\n<p>\u0417\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e <a href=\"https:\/\/api.slack.com\/methods\/chat.postMessage\"><u>\u043c\u0435\u0442\u043e\u0434\u0430<\/u><\/a>.\u00a0<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a24\/506\/1c0\/a245061c0cf9f1da072dc14a422421d2.png\" width=\"789\" height=\"140\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a24\/506\/1c0\/a245061c0cf9f1da072dc14a422421d2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0432\u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430. \u041b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <strong>chat:write. <\/strong><a href=\"https:\/\/api.slack.com\/scopes\"><u>\u0412\u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/u><\/a>.<\/p>\n<\/div>\n<\/details>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <\/strong><a href=\"https:\/\/github.com\/heruv1m\/slack-example\"><strong><u>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/u><\/strong><\/a><\/p>\n<details class=\"spoiler\">\n<summary>pom.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?> &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"          xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\">     &lt;modelVersion>4.0.0&lt;\/modelVersion>     &lt;parent>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-parent&lt;\/artifactId>         &lt;version>2.6.0&lt;\/version>     &lt;\/parent>     &lt;groupId>ru.hh.example&lt;\/groupId>     &lt;artifactId>slack-example&lt;\/artifactId>     &lt;version>0.0.1-SNAPSHOT&lt;\/version>     &lt;name>slack-example&lt;\/name>      &lt;properties>         &lt;java.version>11&lt;\/java.version>         &lt;slack.bolt.version>1.13.0&lt;\/slack.bolt.version>     &lt;\/properties>      &lt;dependencies>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter&lt;\/artifactId>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter-test&lt;\/artifactId>             &lt;scope>test&lt;\/scope>         &lt;\/dependency>          &lt;!--        slack base and web-->         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt-servlet&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>          &lt;!--        socket mode-->         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt-socket-mode&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.glassfish.tyrus.bundles&lt;\/groupId>             &lt;artifactId>tyrus-standalone-client&lt;\/artifactId>             &lt;version>1.9&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>javax.websocket&lt;\/groupId>             &lt;artifactId>javax.websocket-api&lt;\/artifactId>             &lt;version>1.1&lt;\/version>         &lt;\/dependency>     &lt;\/dependencies>      &lt;build>         &lt;plugins>             &lt;plugin>                 &lt;groupId>org.springframework.boot&lt;\/groupId>                 &lt;artifactId>spring-boot-maven-plugin&lt;\/artifactId>             &lt;\/plugin>         &lt;\/plugins>     &lt;\/build>  &lt;\/project><\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>SlackController.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package ru.hh.example.slack;  import com.slack.api.Slack; import com.slack.api.methods.MethodsClient; import com.slack.api.methods.SlackApiException; import com.slack.api.methods.response.chat.ChatPostMessageResponse; import com.slack.api.methods.response.conversations.ConversationsListResponse; import com.slack.api.model.Conversation; import java.io.IOException; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;  @RestController public class SlackController {   private static final Logger LOGGER = LoggerFactory.getLogger(SlackController.class);    @PostMapping(path = \"\/\", consumes = {APPLICATION_FORM_URLENCODED_VALUE})   public String slackCommand(@RequestParam Map&lt;String, String> slackRequest) {     LOGGER.info(\"slackRequest: {}\", slackRequest);     return \"hello \" + slackRequest.get(\"user_name\");   }    @PostMapping(path = \"\/send-to-chat\")   public void sendMessage() throws SlackApiException, IOException {     \/\/ https:\/\/api.slack.com\/authentication\/oauth-v2     String token = \"xoxb-YOUR-TOKEN\";     String channelName = \"YOUR-CHANNEL-NAME\";     String message = \"hello\";      var client = Slack.getInstance().methods(token);     var channelId = findChannel(client, channelName);      ChatPostMessageResponse chatPostMessageResponse = postMessage(client, channelId, message);     LOGGER.info(\"chatPostMessageResponse.isOk() : {}\", chatPostMessageResponse.isOk());   }    \/\/ https:\/\/api.slack.com\/messaging\/retrieving#finding_conversation   private String findChannel(MethodsClient client, String channelName) throws SlackApiException, IOException {     String nextCursor = null;     do {       var result = getConversationsList(client, nextCursor);       nextCursor = result.getResponseMetadata().getNextCursor();       for (Conversation channel : result.getChannels()) {         if (channel.getName().equalsIgnoreCase(channelName)) {           return channel.getId();         }       }     } while (nextCursor != null);     throw new IllegalStateException();   }    private ConversationsListResponse getConversationsList(MethodsClient client, String nextCursor) throws SlackApiException, IOException {     return client.conversationsList(r -> r.cursor(nextCursor));   }    \/\/ https:\/\/api.slack.com\/messaging\/sending#publishing   private ChatPostMessageResponse postMessage(MethodsClient client, String conversationId, String message) throws SlackApiException, IOException {     return client.chatPostMessage(r -> r.channel(conversationId).text(message));   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c token (<strong>Bot User OAuth Token)<\/strong> \u0438 \u0438\u043c\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 (<strong>channelName<\/strong>).<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0421\u043b\u0430\u043a \u0441\u043c\u043e\u0433 \u0434\u043e\u0441\u0442\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435 \u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e <a href=\"https:\/\/ngrok.com\/\"><u>ngrok<\/u><\/a>.\u00a0<\/p>\n<p><strong>.\/ngrok $PORT<\/strong> <\/p>\n<p>Spring boot \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0430 8080.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u201c\u0442\u043e\u0440\u0447\u0430\u0442\u044c \u043d\u0430\u0440\u0443\u0436\u0443\u201d? \u0412 web api \u0421\u043b\u0430\u043a\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 (\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435) \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/125\/d24\/b4b\/125d24b4bd205482eaa602a91831960a.png\" width=\"669\" height=\"333\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/125\/d24\/b4b\/125d24b4bd205482eaa602a91831960a.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u201c<\/strong><a href=\"https:\/\/api.slack.com\/apps\"><strong><u>\u043b\u043a<\/u><\/strong><\/a><strong>\u201d \u0441\u043b\u0430\u043a\u0430<\/strong><\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Slash Commands. <\/strong>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 url \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041e\u0442 \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043b\u0438 ngrok.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/158\/f3b\/4fb\/158f3b4fb02578a6658080625f8f9f7b.png\" width=\"537\" height=\"230\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/158\/f3b\/4fb\/158f3b4fb02578a6658080625f8f9f7b.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043e\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e\u00a0 <strong>Slackbot<\/strong>, \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0431\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <strong>Slackbot<\/strong>, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 <a href=\"https:\/\/api.slack.com\/interactivity\/slash-commands\"><u>\u0442\u0443\u0442<\/u><\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0442\u0440\u0438\u0445 \u0432 <a href=\"https:\/\/api.slack.com\/apps\"><u>\u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435<\/u><\/a>\u00a0\u2014 Install App \u0438 Reinstall to Workspace.\u00a0<\/p>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u043e\u0442:<\/strong><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48d\/842\/9fc\/48d8429fc6bbaff2d495b3b1fe4a9a62.gif\" width=\"400\" height=\"175\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/48d\/842\/9fc\/48d8429fc6bbaff2d495b3b1fe4a9a62.gif\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u041c\u0435\u0442\u043e\u0434 sendMessage<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u044e\u0437\u0435\u0440\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. <\/p>\n<p>curl -X POST <a href=\"http:\/\/localhost:8080\/send-to-chat\">http:\/\/localhost:8080\/send-to-chat<\/a><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c9\/515\/dfa\/6c9515dfab3a179cf70bca8f127b6cfb.png\" width=\"400\" height=\"164\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c9\/515\/dfa\/6c9515dfab3a179cf70bca8f127b6cfb.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b\u0435.<\/p>\n<p><strong>\u0427\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c<\/strong><\/p>\n<p>Slack \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <a href=\"https:\/\/api.slack.com\/start\/planning\/choosing\"><u>api<\/u><\/a><strong>:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>Webhook<\/strong> \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0425\u043e\u0440\u043e\u0448 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e slack \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u0435\u0433\u043e\u00a0\u043f\u043e http. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/okmeter.io\/\"><u>okmeter<\/u><\/a> \u0438 \u0438\u0437 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u0435\u043f\u043b\u043e\u0439\u043c\u0435\u043d\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p><strong>Conversations api<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430;\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Events API <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 \u0438\u0437 C\u043b\u0430\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0445\u043e\u0434 \u0432 \u043a\u0430\u043d\u0430\u043b, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430). \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u2014 web, \u043a\u0430\u043a \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438 socket. \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u044f \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b socket, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430\u0440\u0443\u0436\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u0440\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435  \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0431\u043e\u0442\u0430. \u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/api.slack.com\/block-kit\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a><u>.<\/u><\/p>\n<details class=\"spoiler\">\n<summary>\u0418 \u0435\u0449\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 socket mode<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043c\u043e\u0435\u043c \u0431\u043e\u0442\u0435 \u043e\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Socket Mode<\/strong><\/p>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c <strong>enable<\/strong><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de9\/b31\/051\/de9b31051cdf7d802a29e12d2ebf5dff.png\" width=\"668\" height=\"235\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de9\/b31\/051\/de9b31051cdf7d802a29e12d2ebf5dff.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410\u043b\u0438\u0430\u0441 \u0434\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c74\/8ae\/d29\/c748aed29ffe4a06b8e8f56ef949d87c.png\" width=\"505\" height=\"446\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c74\/8ae\/d29\/c748aed29ffe4a06b8e8f56ef949d87c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d (\u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e):<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/433\/09c\/521\/43309c521ae095b5cd9ff6161ea0daa1.png\" width=\"500\" height=\"411\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/433\/09c\/521\/43309c521ae095b5cd9ff6161ea0daa1.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0438\u0432\u0435\u043d\u0442\u044b. \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <strong>app_mention.<\/strong><\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Event Subscriptions<\/strong><\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/550\/e0c\/1a7\/550e0c1a7b43874d416a53eeb8b7b9e6.png\" width=\"650\" height=\"624\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/550\/e0c\/1a7\/550e0c1a7b43874d416a53eeb8b7b9e6.png\"\/><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>SocketExample.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package ru.hh.example.slack;   import com.slack.api.bolt.App; import com.slack.api.bolt.AppConfig; import com.slack.api.bolt.socket_mode.SocketModeApp; import com.slack.api.model.event.AppMentionEvent;  public class SocketExample {   public static void main(String[] args) throws Exception {         String botToken = \"xoxb-YOUR-BOT-TOKEN\";         String appToken = \"xapp-APPTOKEN\";      AppConfig appConfig = AppConfig.builder().singleTeamBotToken(botToken).build();     App app = new App(appConfig);      app.event(AppMentionEvent.class, (req, ctx) -> {       System.out.println(\"HI! I received event!\" + req.getEvent());       ctx.say(\"I was mentioned by user with id \" + req.getEvent().getUser());       return ctx.ack();     });      SocketModeApp socketModeApp = new SocketModeApp(appToken, app);  \/\/ #start() method establishes a new WebSocket connection and then blocks the current thread. \/\/ If you do not want to block this thread, use #startAsync() instead.     socketModeApp.start();   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<p><strong>xoxb-YOUR-BOT-TOKEN<\/strong> \u2014 \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p><strong>xapp-APPTOKEN<\/strong> \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7bc\/b85\/168\/7bcb851681b35f964a740c94f9b4daac.png\" width=\"400\" height=\"157\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7bc\/b85\/168\/7bcb851681b35f964a740c94f9b4daac.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0447\u0435\u0440\u0435\u0437 socket api:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/71d\/72e\/938\/71d72e9383033b297723893e9be9ca1d.png\" width=\"1600\" height=\"817\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/71d\/72e\/938\/71d72e9383033b297723893e9be9ca1d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u2014 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043a\u0435\u0442 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0422\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0435. \u0410 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 web api.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <a href=\"https:\/\/slack.dev\/java-slack-sdk\/guides\/socket-mode\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a> \u0438 <a href=\"https:\/\/slack.dev\/java-slack-sdk\/guides\/events-api\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a><u>.<\/u><\/p>\n<p>P.S.: \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0438\u0432\u0435\u043d\u0442\u044b, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u043d\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043d\u0438\u0445 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 <strong>Event Subscriptions <\/strong>(\u044f \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043a\u0430\u043a\u043e\u0435 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c).<\/p>\n<\/div>\n<\/details>\n<p><strong>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/strong>\u00a0<\/p>\n<p>\u041d\u0430\u0448\u0438 \u0441\u043b\u0430\u043a \u0431\u043e\u0442\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443, \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0445\u043e\u0434 \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043b\u0430\u043c\u043f\u043e\u0432\u043e\u0441\u0442\u0438 \u0432 \u043a\u0430\u043d\u0430\u043b\u044b.<\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0431\u043e\u0442 &#8212; \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0441\u0442\u0430\u0442\u0443\u0441 \u0441\u0442\u0435\u043d\u0434\u043e\u0432 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0445 \u201c\u0431\u0440\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u201d. \u0410 \u0435\u0449\u0435 \u0440\u0430\u0441\u0441\u044b\u043b\u0430\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a: \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0440\u0435\u043b\u0438\u0437\u0430\u043c\u0438 etc.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/335\/680\/13d\/33568013d83689fbd37fb633d6e4c78c.png\" width=\"1252\" height=\"306\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/335\/680\/13d\/33568013d83689fbd37fb633d6e4c78c.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/513\/11f\/b99\/51311fb99d4c52dcca65e987658a805d.png\" width=\"1566\" height=\"680\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/513\/11f\/b99\/51311fb99d4c52dcca65e987658a805d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u201c\u043a\u0430\u043c\u0435\u0440\u043d\u044b\u0435\u201d \u0431\u043e\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0440\u043e\u0442\u0442\u043b\u0435\u0440 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 <a href=\"https:\/\/github.com\/pythonbatya\/D-arby\"><u>\u043f\u043b\u0430\u043d\u0438\u043d\u0433 \u043f\u043e\u043a\u0435\u0440<\/u><\/a>. \u0412\u0441\u0435\u0433\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u043f\u043e\u043b\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0436\u0435 \u043b\u044e\u0431\u044f\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0432\u0430\u043d\u0438\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ab\/5c5\/4db\/7ab5c54db7ce148e64d0b5571e065d87.gif\" width=\"400\" height=\"468\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7ab\/5c5\/4db\/7ab5c54db7ce148e64d0b5571e065d87.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043c\u043e\u0439 \u043b\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0439\u0442\u0438\u043d\u0433 \u0431\u043e\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/hhru.slack.com\/apps\/A04E6JX41-polly\"><u>Polly<\/u><\/a>\u00a0\u2014 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u043e\u043f\u0440\u043e\u0441\u044b;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/hhru.slack.com\/apps\/A5GE9BMQC-zoom?tab=more_info\"><u>Zoom<\/u><\/a> \u0438 <a href=\"https:\/\/slack.com\/app-pages\/teams-calls\"><u>Teams<\/u><\/a> \u0431\u043e\u0442\u044b\u00a0 \u0434\u0435\u043b\u0430\u044e\u0442 \u0436\u0438\u0437\u043d\u044c \u0447\u0443\u0442\u044c \u043f\u0440\u043e\u0449\u0435;<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/hhru.slack.com\/apps\/A0DV3EEN4-disco?tab=more_info\"><u>Disco<\/u><\/a> &#8212; \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f \u043a\u043e\u0440\u043f\u043e\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043e\u0431\u0449\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/595837\/\"> https:\/\/habr.com\/ru\/articles\/595837\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u2014 \u0421\u0430\u0448\u0430 \u041a\u0430\u0437\u0430\u043d\u0446\u0435\u0432, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 hh.ru. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0432 Slack \u043d\u0430 java \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f slack api.<\/p>\n<p>\u0421\u043b\u0430\u043a \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u043e\u0431\u0448\u0438\u0440\u043d\u043e\u0439 \u0438 \u0432\u0441\u0435\u043e\u0431\u044a\u0435\u043c\u043b\u044e\u0449\u0435\u0439 <a href=\"https:\/\/api.slack.com\/docs\"><u>\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/u><\/a> \u0438 <a href=\"https:\/\/api.slack.com\/tutorials\"><u>\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430\u043c\u0438<\/u><\/a>, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u0431\u043e\u0442\u0430, \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u0435. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u043b\u0430\u043f\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0438\u043b\u0438\u043c \u043f\u043e-\u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443.\u00a0<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u043e\u043c\u0443 \u043b\u0435\u043d\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0435: \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0431\u043e\u0442\u0430, \u0430 \u043f\u043e\u0441\u043b\u0435 \u2014 \u043b\u0438\u0440\u0438\u043a\u0430 \u043f\u0440\u043e \u043d\u0430\u0448\u0438\u0445. <\/p>\n<figure class=\"full-width\"><figcaption>Slack \u0442\u0435\u0431\u0435 \u0432 \u0440\u0443\u043a\u0438!<\/figcaption><\/figure>\n<p><strong>\u041a\u0440\u0443\u0447\u0443 \u0440\u0443\u0447\u043a\u0443, \u043f\u0438\u0448\u0443 \u0431\u043e\u0442\u0430<\/strong><\/p>\n<p>\u0411\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0441\u043b\u043e\u0432 \u0438 \u043f\u0440\u0435\u043b\u044e\u0434\u0438\u0439 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0434\u0435\u043b\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u201c<a href=\"https:\/\/api.slack.com\/apps\"><u>\u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435<\/u><\/a>\u201d. \u0411\u043e\u043b\u044c\u0448\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c <a href=\"https:\/\/api.slack.com\/tutorials\/tracks\/hello-world-bolt\"><u>\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435<\/u><\/a><strong>.<\/strong><\/p>\n<p>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c <strong>From scratch. <\/strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u043c\u0430\u043d\u0438\u0444\u0435\u0441\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u043c\u044f \u0438 workspace.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437\u00a0 \u043c\u0435\u043d\u044e <strong>OAuth &amp; Permissions <\/strong>\u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c <strong>Bot User OAuth Token <\/strong>\u0432\u0438\u0434\u0430 xoxb-YOUR-TOKEN. \u041e\u043d \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0430 \u043d\u0430\u0448\u0435\u043c\u0443 \u0431\u043e\u0442\u0443. \u0412 \u0442\u043e\u043c \u0436\u0435 \u043c\u0435\u043d\u044e \u043d\u0438\u0436\u0435. <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p><em>Slack \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0438\u0434 \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u043a\u043e\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c\u0441\u044f.<\/em><\/p>\n<details class=\"spoiler\">\n<summary>\u041e\u0431\u0449\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 <\/summary>\n<div class=\"spoiler__content\">\n<p>\u0417\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e <a href=\"https:\/\/api.slack.com\/methods\/chat.postMessage\"><u>\u043c\u0435\u0442\u043e\u0434\u0430<\/u><\/a>.\u00a0<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0430\u043c \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043d\u0435 \u0432\u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430. \u041b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u043e\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e <strong>chat:write. <\/strong><a href=\"https:\/\/api.slack.com\/scopes\"><u>\u0412\u0441\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/u><\/a>.<\/p>\n<\/div>\n<\/details>\n<p><strong>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c <\/strong><a href=\"https:\/\/github.com\/heruv1m\/slack-example\"><strong><u>\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/u><\/strong><\/a><\/p>\n<details class=\"spoiler\">\n<summary>pom.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?> &lt;project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"          xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\">     &lt;modelVersion>4.0.0&lt;\/modelVersion>     &lt;parent>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-parent&lt;\/artifactId>         &lt;version>2.6.0&lt;\/version>     &lt;\/parent>     &lt;groupId>ru.hh.example&lt;\/groupId>     &lt;artifactId>slack-example&lt;\/artifactId>     &lt;version>0.0.1-SNAPSHOT&lt;\/version>     &lt;name>slack-example&lt;\/name>      &lt;properties>         &lt;java.version>11&lt;\/java.version>         &lt;slack.bolt.version>1.13.0&lt;\/slack.bolt.version>     &lt;\/properties>      &lt;dependencies>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter&lt;\/artifactId>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.springframework.boot&lt;\/groupId>             &lt;artifactId>spring-boot-starter-test&lt;\/artifactId>             &lt;scope>test&lt;\/scope>         &lt;\/dependency>          &lt;!--        slack base and web-->         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt-servlet&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>          &lt;!--        socket mode-->         &lt;dependency>             &lt;groupId>com.slack.api&lt;\/groupId>             &lt;artifactId>bolt-socket-mode&lt;\/artifactId>             &lt;version>${slack.bolt.version}&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>org.glassfish.tyrus.bundles&lt;\/groupId>             &lt;artifactId>tyrus-standalone-client&lt;\/artifactId>             &lt;version>1.9&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>javax.websocket&lt;\/groupId>             &lt;artifactId>javax.websocket-api&lt;\/artifactId>             &lt;version>1.1&lt;\/version>         &lt;\/dependency>     &lt;\/dependencies>      &lt;build>         &lt;plugins>             &lt;plugin>                 &lt;groupId>org.springframework.boot&lt;\/groupId>                 &lt;artifactId>spring-boot-maven-plugin&lt;\/artifactId>             &lt;\/plugin>         &lt;\/plugins>     &lt;\/build>  &lt;\/project><\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>SlackController.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package ru.hh.example.slack;  import com.slack.api.Slack; import com.slack.api.methods.MethodsClient; import com.slack.api.methods.SlackApiException; import com.slack.api.methods.response.chat.ChatPostMessageResponse; import com.slack.api.methods.response.conversations.ConversationsListResponse; import com.slack.api.model.Conversation; import java.io.IOException; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;  @RestController public class SlackController {   private static final Logger LOGGER = LoggerFactory.getLogger(SlackController.class);    @PostMapping(path = \"\/\", consumes = {APPLICATION_FORM_URLENCODED_VALUE})   public String slackCommand(@RequestParam Map&lt;String, String> slackRequest) {     LOGGER.info(\"slackRequest: {}\", slackRequest);     return \"hello \" + slackRequest.get(\"user_name\");   }    @PostMapping(path = \"\/send-to-chat\")   public void sendMessage() throws SlackApiException, IOException {     \/\/ https:\/\/api.slack.com\/authentication\/oauth-v2     String token = \"xoxb-YOUR-TOKEN\";     String channelName = \"YOUR-CHANNEL-NAME\";     String message = \"hello\";      var client = Slack.getInstance().methods(token);     var channelId = findChannel(client, channelName);      ChatPostMessageResponse chatPostMessageResponse = postMessage(client, channelId, message);     LOGGER.info(\"chatPostMessageResponse.isOk() : {}\", chatPostMessageResponse.isOk());   }    \/\/ https:\/\/api.slack.com\/messaging\/retrieving#finding_conversation   private String findChannel(MethodsClient client, String channelName) throws SlackApiException, IOException {     String nextCursor = null;     do {       var result = getConversationsList(client, nextCursor);       nextCursor = result.getResponseMetadata().getNextCursor();       for (Conversation channel : result.getChannels()) {         if (channel.getName().equalsIgnoreCase(channelName)) {           return channel.getId();         }       }     } while (nextCursor != null);     throw new IllegalStateException();   }    private ConversationsListResponse getConversationsList(MethodsClient client, String nextCursor) throws SlackApiException, IOException {     return client.conversationsList(r -> r.cursor(nextCursor));   }    \/\/ https:\/\/api.slack.com\/messaging\/sending#publishing   private ChatPostMessageResponse postMessage(MethodsClient client, String conversationId, String message) throws SlackApiException, IOException {     return client.chatPostMessage(r -> r.channel(conversationId).text(message));   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c token (<strong>Bot User OAuth Token)<\/strong> \u0438 \u0438\u043c\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u0430\u043d\u0430\u043b\u0430 (<strong>channelName<\/strong>).<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0421\u043b\u0430\u043a \u0441\u043c\u043e\u0433 \u0434\u043e\u0441\u0442\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0434\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435 \u0438\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e <a href=\"https:\/\/ngrok.com\/\"><u>ngrok<\/u><\/a>.\u00a0<\/p>\n<p><strong>.\/ngrok $PORT<\/strong> <\/p>\n<p>Spring boot \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043d\u0430 8080.<\/p>\n<p>\u0417\u0430\u0447\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u201c\u0442\u043e\u0440\u0447\u0430\u0442\u044c \u043d\u0430\u0440\u0443\u0436\u0443\u201d? \u0412 web api \u0421\u043b\u0430\u043a\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u043d \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 (\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435) \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 \u201c<\/strong><a href=\"https:\/\/api.slack.com\/apps\"><strong><u>\u043b\u043a<\/u><\/strong><\/a><strong>\u201d \u0441\u043b\u0430\u043a\u0430<\/strong><\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Slash Commands. <\/strong>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043c\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 url \u0441\u0435\u0440\u0432\u0438\u0441\u0430. \u041e\u0442 \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043b\u0438 ngrok.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u043e\u0442\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e\u00a0 <strong>Slackbot<\/strong>, \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0431\u043e\u0442\u0430 \u043a \u0441\u0435\u0431\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <strong>Slackbot<\/strong>, \u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434 <a href=\"https:\/\/api.slack.com\/interactivity\/slash-commands\"><u>\u0442\u0443\u0442<\/u><\/a>.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0442\u0440\u0438\u0445 \u0432 <a href=\"https:\/\/api.slack.com\/apps\"><u>\u043b\u0438\u0447\u043d\u043e\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0435<\/u><\/a>\u00a0\u2014 Install App \u0438 Reinstall to Workspace.\u00a0<\/p>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u043e\u0442:<\/strong><\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u041c\u0435\u0442\u043e\u0434 sendMessage<\/strong><\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u041e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u044e\u0437\u0435\u0440\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0438\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. <\/p>\n<p>curl -X POST <a href=\"http:\/\/localhost:8080\/send-to-chat\">http:\/\/localhost:8080\/send-to-chat<\/a><\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u043d\u0430\u043b\u0435.<\/p>\n<p><strong>\u0427\u0442\u043e \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u043b\u0438\u0442\u044c<\/strong><\/p>\n<p>Slack \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <a href=\"https:\/\/api.slack.com\/start\/planning\/choosing\"><u>api<\/u><\/a><strong>:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>Webhook<\/strong> \u2014 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u0425\u043e\u0440\u043e\u0448 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e slack \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u0440\u0433\u0430\u0442\u044c \u0435\u0433\u043e\u00a0\u043f\u043e http. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0430\u043b\u0435\u0440\u0442\u043e\u0432 \u0438\u0437 <a href=\"https:\/\/okmeter.io\/\"><u>okmeter<\/u><\/a> \u0438 \u0438\u0437 \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0434\u0435\u043f\u043b\u043e\u0439\u043c\u0435\u043d\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p><strong>Conversations api<\/strong> \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0441\u0438\u043b\u0438\u0439 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430;\u00a0<\/p>\n<\/li>\n<li>\n<p><strong>Events API <\/strong>\u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438 \u0438\u0437 C\u043b\u0430\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0445\u043e\u0434 \u0432 \u043a\u0430\u043d\u0430\u043b, \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430). \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u2014 web, \u043a\u0430\u043a \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438 socket. \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u044f \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b socket, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043d\u0430\u0440\u0443\u0436\u0443.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u0440\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435  \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0431\u043e\u0442\u0430. \u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/api.slack.com\/block-kit\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a><u>.<\/u><\/p>\n<details class=\"spoiler\">\n<summary>\u0418 \u0435\u0449\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 socket mode<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u043c\u043e\u0435\u043c \u0431\u043e\u0442\u0435 \u043e\u043d \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043d\u043e \u0431\u044b\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f<\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Socket Mode<\/strong><\/p>\n<p>\u0412\u044b\u0441\u0442\u0430\u0432\u0438\u0442\u044c <strong>enable<\/strong><\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0410\u043b\u0438\u0430\u0441 \u0434\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d (\u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e):<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0438\u0432\u0435\u043d\u0442\u044b. \u0414\u043b\u044f \u043c\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0435 <strong>app_mention.<\/strong><\/p>\n<p>\u0412 \u043c\u0435\u043d\u044e <strong>Event Subscriptions<\/strong><\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>SocketExample.java<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">package ru.hh.example.slack;   import com.slack.api.bolt.App; import com.slack.api.bolt.AppConfig; import com.slack.api.bolt.socket_mode.SocketModeApp; import com.slack.api.model.event.AppMentionEvent;  public class SocketExample {   public static void main(String[] args) throws Exception {         String botToken = \"xoxb-YOUR-BOT-TOKEN\";         String appToken = \"xapp-APPTOKEN\";      AppConfig appConfig = AppConfig.builder().singleTeamBotToken(botToken).build();     App app = new App(appConfig);      app.event(AppMentionEvent.class, (req, ctx) -> {       System.out.println(\"HI! I received event!\" + req.getEvent());       ctx.say(\"I was mentioned by user with id \" + req.getEvent().getUser());       return ctx.ack();     });      SocketModeApp socketModeApp = new SocketModeApp(appToken, app);  \/\/ #start() method establishes a new WebSocket connection and then blocks the current thread. \/\/ If you do not want to block this thread, use #startAsync() instead.     socketModeApp.start();   } }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435<\/p>\n<p><strong>xoxb-YOUR-BOT-TOKEN<\/strong> \u2014 \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430.<\/p>\n<p><strong>xapp-APPTOKEN<\/strong> \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0445\u0435\u043c\u0430 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0447\u0435\u0440\u0435\u0437 socket api:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0437<\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-390581","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/390581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=390581"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/390581\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=390581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=390581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=390581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}