Giter Site home page Giter Site logo

slack-bot-template's Introduction

Slack Bot Template

Go 製の SlackBot テンプレート

開発方法

1. インストール

git clone [email protected]:yukinissie/slack-bot-template.git
cd slack-bot-template/bot
make init
cd ..

2. SlackApp のボットトークンを設定

cp conf/dev/dev.yml.example conf/dev/dev.yml

dev.yml に SlackApp のボットトークンを設定する。

※SlackApp はここで作る。

OAuth & Permissions > Scopes > Bot Token Scopes には channels:history と chat:write を追加する。 スクリーンショット 2022-07-02 7 39 17

OAuth & Permissions の Bot User OAuth Token を slackToken に追記する。 スクリーンショット 2022-07-02 7 37 29

slackToken: 'xoxb-...'

Event Subscriptions > Subscrive to be bot events に message.channels を追加する。 スクリーンショット 2022-07-02 7 00 00

3. ローカルサーバーを起動

3000 ポートに ApiGateway をエミュレートしたサーバーが立ちます。

cd bot
make local_run

4. SlackApp とローカルサーバーを連携

ngrok を使って一時的にローカルサーバーを公開します。これは SlackApp と連携するためです。

ngrok http 3000

表示された TLS 化済みの URL を SlackApp の Event Subscriptions > Request URL に登録します。 スクリーンショット 2022-07-02 7 40 03

例:https://022d-131-129-4-95.ngrok.io/dev/example

Go のコードを書き換えた場合は 3 を繰り返し実行します。

ngrok を一度でも落とした場合は 4 を繰り返します。

デプロイ

AWS 上にデプロイする方法です。2 種類あります。うまくいく保証はありません。

  • 手動デプロイ(dev 用)
  • GitHub Actions でデプロイ(prod 用)

手動デプロイ(dev 用)

開発環境用の AWS リソースを自動的に作成し、デプロイします。

cd bot
make dev_deploy

GitHub Actions でデプロイ(prod 用)

GitHub リポジトリのSettings>SecretsSLACK_BOT_TOKENAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYSLACK_WEBHOOKキーを登録します。

あとはmainブランチにプッシュすることでデプロイされます。

slack-bot-template's People

Contributors

yukinissie avatar renovate[bot] avatar renovate-bot avatar dependabot[bot] avatar

Stargazers

 avatar Shu Nakashima avatar  avatar

Watchers

James Cloos avatar

slack-bot-template's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/deploy.yml
  • actions/checkout master
  • actions/setup-node v3
  • actions/setup-go v3
  • homoluctus/slatify master
gomod
bot/go.mod
  • github.com/aws/aws-lambda-go v1.32.1
  • github.com/slack-go/slack v0.11.0
npm
package.json
  • serverless 3.20.0
  • serverless-offline 8.8.0

  • Check this box to trigger a request for Renovate to run again on this repository

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.