Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / app.py
Last active August 21, 2024 04:01
Two Slack App Installation Flow Example (Flask + SQLAlchemy)
import logging
from typing import Callable
logging.basicConfig(level=logging.DEBUG)
logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
import os
from slack_bolt import App, BoltContext, Ack
from slack_bolt.adapter.flask import SlackRequestHandler
from slack_bolt.oauth.oauth_settings import OAuthSettings
@seratch
seratch / SlackApp.gs
Created February 18, 2021 15:51
Slack App in Google Apps Script
// *** Request Verification ***
// The currently recommended way is to verify request signature: https://api.slack.com/authentication/verifying-requests-from-slack
// Unfortunately, GAS web apps don"t have means to access request headers. Thus, this example uses the old way to verify requests.
// >>> Settings > Basic Information > App Credentials > Verification Token
const legacyVerificationToken = PropertiesService.getScriptProperties().getProperty("SLACK_VERIFICATION_TOKEN");
// *** OAuth Access Token ***
// Install your Slack app into its development workspace.
// >>> Settings > Install App > Bot User OAuth Access Token
const token = PropertiesService.getScriptProperties().getProperty("SLACK_BOT_TOKEN");
@seratch
seratch / app.ts
Created March 31, 2022 05:39
@slack/bolt meets Fastify
import Fastify from 'fastify';
import { App, FileInstallationStore, LogLevel } from '@slack/bolt';
import { FileStateStore } from '@slack/oauth';
import { FastifyReceiver } from 'slack-bolt-fastify';
const fastify = Fastify({ logger: true });
fastify.get('/', async (_, res) => {
res.redirect('/slack/install');
});
@seratch
seratch / Gemfile
Last active April 2, 2024 13:22
twitter oauth example
source 'https://rubygems.org/'
gem 'sinatra'
gem 'omniauth-twitter'
gem 'json'
gem 'twitter'
gem 'dotenv'
gem 'thin'
@seratch
seratch / README.md
Last active March 31, 2024 13:43
Sign in with Slack - the simplest example

You can run this app by following the steps below:

Set up your Slack app

  • Create a new Slack app from https://api.slack.com/apps?new_app=1
  • Go to OAuth & Permissions
    • Add identity.basic & identity.email to User Token Scopes
    • Add OAuth Redirect URL
  • Go to Basic Information
  • Grab the Client ID & Client Secret in the page
@seratch
seratch / app-manifest.yml
Created November 14, 2023 07:06
file input block in bolt-python apps
display_information:
name: file-uploader
features:
bot_user:
display_name: file-uploader
slash_commands:
- command: /send-files
description: Send files on a modal
should_escape: false
oauth_config:
@seratch
seratch / go.mod
Last active August 14, 2023 16:16
Slack Socket Mode in Go
module socket-mode-app
go 1.15
require github.com/slack-go/slack v0.8.0
@seratch
seratch / build.sbt
Created March 8, 2012 03:06
Using Anorm 2.0 without Play Framework
scalaVersion := "2.9.1"
resolvers += "typesafe" at "http://repo.typesafe.com/typesafe/releases"
libraryDependencies ++= Seq(
"play" %% "anorm" % "2.0-RC4",
"com.github.seratch" %% "scalikejdbc" % "[0.5,)",
"org.hsqldb" % "hsqldb" % "[2,)"
)
@seratch
seratch / HomeController.scala
Last active March 26, 2023 14:17
Slack app built with Play Framework (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 / Application.java
Created September 8, 2020 14:56
Bolt for Java + Spring Boot
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) {