Skip to content

Instantly share code, notes, and snippets.

Avatar
🔧
Making Slack tools in Japan

Kazuhiro Sera seratch

🔧
Making Slack tools in Japan
View GitHub Profile
@seratch
seratch / app.py
Last active Oct 17, 2020
Deploying a Bolt for Python app using only AWS CLI
View app.py
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
SlackRequestHandler.clear_all_log_handlers()
import logging
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)
from slack_bolt import App, Ack
from slack_sdk.web import WebClient
# export SLACK_BOT_TOKEN=xoxb-
@seratch
seratch / MyApp.kt
Last active Oct 5, 2020
Steps from Apps in Kotlin
View MyApp.kt
import com.slack.api.bolt.App
import com.slack.api.bolt.jetty.SlackAppServer
import com.slack.api.bolt.middleware.builtin.WorkflowStep
import com.slack.api.model.block.Blocks.divider
import com.slack.api.model.block.Blocks.section
import com.slack.api.model.block.LayoutBlock
import com.slack.api.model.block.composition.BlockCompositions.plainText
import com.slack.api.model.kotlin_extension.block.withBlocks
import com.slack.api.model.view.Views.view
import com.slack.api.model.view.Views.viewTitle
@seratch
seratch / index.js
Last active Sep 18, 2020
Passing request headers to Bolt JS
View index.js
const { LogLevel } = require("@slack/logger");
const { App } = require("@slack/bolt");
const { MyExpressReceiver } = require("./receiver")
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
logLevel: process.env.SLACK_LOG_LEVEL || LogLevel.DEBUG,
receiver: new MyExpressReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET
}),
@seratch
seratch / Gemfile
Last active Sep 17, 2020
Slack app built with Sinatra
View Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
gem "sinatra"
gem "slack-ruby-client"
@seratch
seratch / Application.java
Created Sep 8, 2020
Bolt for Java + Spring Boot
View Application.java
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) {
@seratch
seratch / index.js
Last active Jul 21, 2020
Workflow Builder: Steps from apps - https://api.slack.com/workflows/steps
View index.js
const config = require("dotenv").config().parsed;
for (const k in config) {
process.env[k] = config[k];
}
// npm install @slack/bolt@feat-workflow-steps
const { App } = require("@slack/bolt");
const app = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
token: process.env.SLACK_BOT_TOKEN,
@seratch
seratch / ScalatraBootstrap.scala
Created Jun 10, 2020
Slack app built with Scalatra
View ScalatraBootstrap.scala
import com.slack.api.bolt.App
import com.slack.api.bolt.handler.builtin.SlashCommandHandler
import com.slack.api.bolt.servlet.SlackAppServlet
import javax.servlet.ServletContext
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import org.scalatra._
class RootController extends ScalatraServlet {
get("/") {
views.html.hello()
@seratch
seratch / HomeController.scala
Last active Jun 10, 2020
Slack app built with Play Framework (Scala)
View HomeController.scala
package controllers
import javax.inject._
import play.api.mvc._
@Singleton
class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
def index() = Action { implicit request: Request[AnyContent] =>
Ok("Hello World!")
@seratch
seratch / MyApp.kt
Last active Jun 7, 2020
Slack app built with HTTP4K
View MyApp.kt
import com.slack.api.bolt.App
import com.slack.api.bolt.request.RequestHeaders
import com.slack.api.bolt.util.SlackRequestParser
import com.slack.api.model.block.Blocks.*
import com.slack.api.model.block.composition.BlockCompositions.*
import com.slack.api.model.block.element.BlockElements.plainTextInput
import com.slack.api.model.block.element.BlockElements.staticSelect
import com.slack.api.model.view.View
import com.slack.api.model.view.Views.*
import org.http4k.core.*
@seratch
seratch / SlackApp.java
Last active Apr 18, 2020
How to run Bolt app with Quarkus - remove quarkus-universe-bom
View SlackApp.java
package hello;
import com.slack.api.bolt.App;
import com.slack.api.bolt.servlet.SlackAppServlet;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
@WebServlet("/slack/events")
public class SlackApp extends SlackAppServlet {
You can’t perform that action at this time.