Giter VIP home page Giter VIP logo

slack2drive-searchapp's Introduction

Slack2Drive-SearchApp

Slackから任意のGoogle Drive内をファイル名検索します

Usage

  • [/設定したコマンド 検索語] ex. /searchfile Mtg image
  • 検索したいドライブを選択 image
  • 検索結果が返ってくる image

各種機能の住み分け

このアプリは3つの機能から構成されています.

機能 詳細
Action Slackからコマンド入力を受けつけてメッセージを返す
Interactivity ユーザーの反応に対して検索結果を返す
Database ドライブのIDを保管する

Slack Appの設定

まずSlack Appを追加するための設定をしましょう.
といっても,必要な設定はoAuthでwrite系列のものを承認すればいいだけです.
アプリ名とか画像は後でも大丈夫です.

次にこの何もできないアプリに機能を追加していきましょう.

Action

Action機能はコマンド入力から検索語を取得し,メッセージを返す機能です.
GASとSlackのCommand機能から成り立っています.
コードはこちら
Slackのトークンなどのパラメータは各自入力してください.

こちらのコードをデプロイしたら,デプロイ結果のURLをSlack AppのCommand機能にぶちこんでください.

Interactivity

Interactivity機能はユーザーが選択した結果に対して,検索結果を返す機能です.
GASとSlackのInteractivity機能から成り立っています.
コードはこちら
ドライブIDなどのパラメータは各自入力してください.

こちらのコードをデプロイしたら,デプロイ結果のURLをSlack AppのInteractivity機能にぶちこんでください.

Database

Database機能は検索したい親ドライブのフォルダ情報を保持する機能です.
GSSとGASから成り立っています.
コードはこちら
GSSの見本はこちら

Slack Appのインストール

最後に各種機能を追加したアプリをインストールしましょう.

- [ ]oAuthが設定されていること
- [ ]各種GASのパラメータを調整したこと
- [ ]データベースのGSSにドライブ情報が入っていること
- [ ]Command機能が設定されていること
- [ ]Interactivity機能が設定されていること
- [ ]インストール先が正しいこと

開発裏話

Slack Responseは3秒以内に返らないとSlackが無視してしまう...

つまりどういうことかというと,GASで外部APIを呼び出しすぎると検索処理が間に合わないのです.
親フォルダ以下のサブフォルダを全探索する処理が3秒で間に合うはずがありません.
そこで本来なら必要のないDatabase機能を追加しました.すると圧倒的速度で検索できるようになりました.

APIがボトルネックになる,という学び

slack2drive-searchapp's People

Contributors

naoe241 avatar

Watchers

 avatar

slack2drive-searchapp's Issues

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.