728x90
    
    
  이 부분해서 Slack 에서 대화생성하기 이후에 던져주는 부분을 활용하려면 아래와 같이 Slack 에서 Oauth Permission 을 허용시켜주어야 한다.
conversations.create
Initiates a public or private channel-based conversation
https://api.slack.com/methods/conversations.create
conversations.create API method
Initiates a public or private channel-based conversation
api.slack.com
Bot token 에 대해서 제대로 설정해주고, 해당 부분에 대한 코드를 작성하면 된다.
(물론 샘플 코드도 있더라)
import com.slack.api.bolt.App;
import com.slack.api.bolt.AppConfig;
import com.slack.api.bolt.jetty.SlackAppServer;
import com.slack.api.methods.SlackApiException;
import java.io.IOException;
public class ConversationsCreate {
    public static void main(String[] args) throws Exception {
        var config = new AppConfig();
        config.setSingleTeamBotToken(System.getenv("SLACK_BOT_TOKEN"));
        config.setSigningSecret(System.getenv("SLACK_SIGNING_SECRET"));
        var app = new App(config); // `new App()` does the same
        // Listen for a message shortcut with the callback_id "sample_message_action"
        // Message shortcuts require the commands scope
        app.messageShortcut("sample_message_action", (req, ctx) -> {
            var logger = ctx.logger;
            try {
                var payload = req.getPayload();
                // Call the conversations.create method using the built-in WebClient
                var result = ctx.client().conversationsCreate(r -> r
                    // The token you used to initialize your app
                    .token(System.getenv("SLACK_BOT_TOKEN"))
                    // The name of the conversation
                    .name("pretend-channel")
                );
                // Print result
                logger.info("result: {}", result);
            } catch (IOException | SlackApiException e) {
                logger.error("error: {}", e.getMessage(), e);
            }
            // Acknowledge incoming command event
            return ctx.ack();
        });
        var server = new SlackAppServer(app);
        server.start();
    }
}
하지만 여기서 단순하게 이렇게 설정하게 만들어주면 망하는 결과가 ... (난 Back-end API 에서 중계단을 만들거니까 이렇게 만들면 안되고 Service 부터 DTO 등까지 죄다 세세하게 분배해주었다.)
'Java > Spring Boot JPA' 카테고리의 다른 글
| [Scheduler] merged two duplicated scheduler completly (0) | 2023.08.31 | 
|---|---|
| [Spring] DB커넥션풀과 Hikari CP 알아보기 (62) | 2023.08.30 | 
| [Trouble Shooting] Godomall Session expired (0) | 2023.08.11 | 
| [Trouble Shooting] Shop Credential released issue (0) | 2023.08.05 | 
| [Trouble Shooting] AopInvocationException Handling (0) | 2023.08.03 |