export SLACK_SIGNING_SECRET=xxx
export SLACK_APP_CLIENT_ID=111.222
export SLACK_APP_CLIENT_SECRET=xxx
export SLACK_APP_SCOPE=commands,chat:write.public,chat:write
export SLACK_APP_USER_SCOPE=
export SLACK_APP_REDIRECT_URI=
export SLACK_APP_OAUTH_START_PATH=/slack/oauth/start
export SLACK_APP_OAUTH_CALLBACK_PATH=/slack/oauth/callback
export SLACK_APP_OAUTH_COMPLETION_URL=https://www.example.com/completion
export SLACK_APP_OAUTH_CANCELLATION_URL=https://www.example.com/cancellation
gradle clean bootRun
Created
September 8, 2020 14:56
-
-
Save seratch/2ae0cac0e5acf6fe6f2912000e4dbacd to your computer and use it in GitHub Desktop.
Bolt for Java + Spring Boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.web.servlet.ServletComponentScan; | |
@SpringBootApplication | |
@ServletComponentScan | |
public class Application { | |
public static void main(String[] args) { | |
SpringApplication.run(Application.class, args); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logging.level: | |
com.slack.api: DEBUG | |
server: | |
port: 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'org.springframework.boot' version '2.3.3.RELEASE' | |
id 'io.spring.dependency-management' version '1.0.10.RELEASE' | |
id 'java' | |
} | |
group = 'com.example' | |
version = '0.0.1-SNAPSHOT' | |
repositories { | |
mavenCentral() | |
mavenLocal() | |
} | |
dependencies { | |
implementation 'org.springframework.boot:spring-boot-starter-web' | |
implementation 'com.squareup.okhttp3:okhttp:4.8.1' | |
implementation 'com.slack.api:bolt-servlet:1.1.3' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import com.slack.api.bolt.App; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
public class SlackApp { | |
@Bean | |
public App initSlackApp() { | |
App app = new App().asOAuthApp(true); | |
app.command("/hello-oauth-app", (req, ctx) -> { | |
return ctx.ack("What's up?"); | |
}); | |
return app; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import com.slack.api.bolt.App; | |
import com.slack.api.bolt.servlet.SlackAppServlet; | |
import javax.servlet.annotation.WebServlet; | |
@WebServlet("/slack/events") | |
public class SlackEventsController extends SlackAppServlet { | |
public SlackEventsController(App app) { | |
super(app); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import com.slack.api.bolt.App; | |
import com.slack.api.bolt.servlet.SlackOAuthAppServlet; | |
import javax.servlet.annotation.WebServlet; | |
@WebServlet("/slack/oauth/callback") | |
public class SlackOAuthCallbackController extends SlackOAuthAppServlet { | |
public SlackOAuthCallbackController(App app) { | |
super(app); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import com.slack.api.bolt.App; | |
import com.slack.api.bolt.servlet.SlackAppServlet; | |
import com.slack.api.bolt.servlet.SlackOAuthAppServlet; | |
import javax.servlet.annotation.WebServlet; | |
@WebServlet("/slack/oauth/start") | |
public class SlackOAuthStartController extends SlackOAuthAppServlet { | |
public SlackOAuthStartController(App app) { | |
super(app); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment