日本語は後述
Google App Scripts to manage Trello using its API and Google Spreadsheet.
- code.gs:
[Required]
Primary file with the main codes written. To be used as a spreadsheet-bound script. - backup.gs:
[Optional]
Script to create a full backup of all available Trello boards including actions and attachments. Requires additional authentications as mentioned below. - _TrelloScriptLibrary.gs: Code for the Google App Script library Trello Script used in code.gs.
- Connect to an external service: https://www.googleapis.com/auth/script.external_request
- See, edit, create, and delete your spreadsheets in Google Drive: https://www.googleapis.com/auth/spreadsheets
- Send email as you: https://www.googleapis.com/auth/script.send_mail
- See, edit, create, and delete all of your Google Drive files: https://www.googleapis.com/auth/drive
- Create a new Google Spreadsheet (or use an existing Spreadsheet).
- Copy contents of code.gs and common.gs into the spreadsheet using the script editor (Custom Functions in Google Sheets is a good place to start if you don't know what I mean by the script editor) and save the code.
- From the script editor, go to File -> Project Properties to set some script properties:
- trelloKey: API key for Trello
- trelloToken: API token for Trello
- boardId: Trello Board Id that you want to manage using the script
If you're not sure where to find the API keys and tokens for Trello, see API Key Security at the Trello Developers documentation.
- Enable TrelloScript Library by entering its script ID
1w2bHQ52dRMv1CG1XR7sW-B4P-A1B6ilaI5n8qNpUFjtJ3RIzla4sAa-Y
on Resources -> Library -> Add a Library. The default identifierTrelloScript
is used in scripts of code.gs. - Refresh the Google Spreadsheet; you'll see that a menu Trello is added to your menu
- You'll be asked for authentications, as mentioned above, when executing the script for the first time.
trelloBoardsLists()
(Menu Name: Get My Board): Returns the list of the names and IDs of all Trello boards and its lists available to your account as a new sheet. Useful for getting board IDs for other functions.setTargetBoardId()
(Menu Name: Set targetBoardId): Registers the value of the selected cell to script propertytargetBoardId
. Used intrelloReport
.trelloDeleteArchivedCards()
(Menu Name: Delete Archived Cards): Delete archived cards in a Trello board. Designate board by board ID. USE WITH CARE; CANNOT BE UNDONE!!trelloReport()
(Menu Name: Get Board Content): Creates a new sheet on the spreadsheet and list all cards in a Trello board, including archived ones, on it. Designate board by board ID.trelloShowKeyToken()
(Menu Name: Key & Token): Shows on an alert window your Trello API key and token registered on your script properties. Useful for making test requests on Trello Developers website.
See TrelloScriptLibrary_documentation.md
- Trello Developers: Official documentation for Trello API
GASとGoogleスプレッドシートを使ってTrelloを管理する。
- code.gs:
[必須]
主要なコードが書かれたファイル。スプレッドシートにコンテナバインドされたスクリプトとして使用。 - backup.gs:
[任意]
アクセス可能な全てのTrelloボードをGoogle Driveにバックアップするためのスクリプト。 - _TrelloScriptLibrary.gs: code.gsで使用するGoogle App Scriptライブラリ「Trello Script」のコード
- Connect to an external service: https://www.googleapis.com/auth/script.external_request
- See, edit, create, and delete your spreadsheets in Google Drive: https://www.googleapis.com/auth/spreadsheets
- Send email as you: https://www.googleapis.com/auth/script.send_mail
- See, edit, create, and delete all of your Google Drive files: https://www.googleapis.com/auth/drive
- このスクリプトを利用するための新しいGoogleスプレッドシートを作成する(既存のスプレッドシートでも可)。
- code.gsおよびcommon.gsの内容を、スプレッドシートのスクリプトエディタにコピー&ペーストする。「スクリプトエディタ??」という状態なら【初心者向けGAS】本当の最初の一歩!スクリプトエディタでプロジェクトを開くなどがわかりやすい。
- スクリプトエディタで、下記スクリプトプロパティを設定する(ファイル -> プロジェクトのプロパティ -> スクリプトのプロパティ):
- trelloKey: TrelloのAPI key
- trelloToken: TrelloのAPIトークン
- boardId: このスクリプトで管理したいTrelloボードのID
TrelloのAPI keyやトークンについての説明は公式ドキュメントのAPI Key Security参照。
- リソース -> ライブラリ -> Add a Libraryに、スクリプトID
1w2bHQ52dRMv1CG1XR7sW-B4P-A1B6ilaI5n8qNpUFjtJ3RIzla4sAa-Y
を入力することで、ライブラリTrello Scriptを有効にする。最新バージョンを選択。IdentifierTrelloScript
は初期値のままでok。変更するならば、code.gs内の記述変更を忘れずに。 - コードを保存の上、スプレッドシートを更新。メニュー「Trello」が追加されていることを確認すれば準備完了。
- スクリプトの初回実行時には、「認証のスコープ」にあるとおりの許可を行う必要がある。
trelloBoardsLists()
(メニュー名: My Boards & Lists): 自分のアカウントからアクセス可能な全てのTrelloボード及びそのリストの名前とIDを、新しいシートに一覧表として表示。他の関数を実行する際に便利。setTargetBoardId()
(メニュー名: Set targetBoardId): 選択したセルのBoard IDを、デフォルトBoard IDとしてスクリプトプロパティtargetBoardId
に登録。trelloReportで反映される。trelloDeleteArchivedCards()
(メニュー名: Delete Archived Cards): 指定したTrelloボード内の、アーカイブされたカードを削除する。対象はボードIDで指定。元に戻せないので、実行は要注意!!!trelloReport()
(メニュー名: Board Content): 新しいシートを作り、そこに指定したTrelloボード内の全てのカードをリスト化する。アーカイブされたカードも含まれる。対象はボードIDで指定。trelloShowKeyToken()
(メニュー名: Key & Token): ポップアップメッセージとして、スクリプトプロパティに設定されたTrello APIキーとトークンを表示させる。公式ドキュメントTrello Developers内で試験リクエストするときに便利。
- Trello Developers: Trello APIの公式ガイド