Giter VIP home page Giter VIP logo

smarthr-textlint-bot's Introduction

smarthr-textlint-bot

textlint の SmartHR 用ルールプリセットを使って、Slack 上から文書のlintfixを行える bot です。

何ができる?

  • Slack 内で、bot のメンションを付けてメッセージを送信すると、textlint を通して文書のチェックと、自動校正を実行します。

開発方法

bot 開発にはBoltを使っています。 ローカルで bot アプリを起動するには、以下のステップに従ってください。

  • プロジェクトのルートディレクトリに .envファイルを作って、必要な情報を設定
  • yarnまたはnpm installを実行して依存ライブラリをインストール
  • yarn devまたはnpm run devを実行して、アプリを起動
  • ngrok をインストールしていなければインストール - https://ngrok.com/
    • brew install ngrokのインストールを推奨します。
  • 別のターミナルでngrok http 3000を実行して公開エンドポイントを立ち上げる

.envを配置して Bot Token と Signing Secret を設定

SLACK_BOT_TOKEN=xoxb-111-111-xxx
SLACK_SIGNING_SECRET=xxx

ローカルアプリを起動

node --version # v10.13.0 以上
yarn
yarn dev` # 起動すると http://localhost:3000/slack/events でリクエストを受け付けます

ngrokSlackからのリクエストをフォワードするために起動

ngrok をまだインストールしていなければ、ダウンロードして設定します。以下のステップで、適切に設定できたか確認します。

# ローカルでアプリが立ち上がっていることを確認
curl -I -XPOST http://localhost:3000/slack/events # HTTP/1.1 401 Unauthorized が返ってくるはず

# 別のターミナルで実行
./ngrok http 3000

# ngrok の有償プランを使っているなら以下のように固定のサブドメインを指定できます
./ngrok http 3000 --subdomain {whatever-you-want}

# 再度、公開エンドポイントからリクエストをして、同じように 401 が返ってくるか確認
curl -I -XPOST https://{your random subdomain here}.ngrok.io/slack/events # HTTP/1.1 401 Unauthorized が返ってくれば OK

デプロイ方法

  • Heroku CLI をインストール、heroku helpでインストールされているか確認
  • heroku loginでログイン、heroku auth:whoamiでログインできるているか確認
  • Heroku のデプロイ先を設定
  • 更新や修正を行って origin に push する
  • git push heroku mainを実行し、Heroku に deploy する
  • 完了

詳細な手順: https://slack.dev/bolt-js/ja-jp/deployments/heroku

Heroku CLIをインストール

brew install heroku/brew/heroku

Heroku のデプロイ先指定

heroku git:remote -a smarthr-textlint-bot-staging

HerokuへDeploy

Deploy

smarthr-textlint-bot's People

Contributors

kgsi avatar renovate-bot avatar diescake avatar mkmn avatar otapo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.