Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

SlackのSlashコマンドからGASへのパラメータの引き渡し

alt

SlackのSlashコマンドからGASへのパラメータの引き渡しについて

Slack から送られてくるリクエスト内容

  • token
  • team_id
  • team_domain
  • channel_id
  • channel_name
  • user_id
  • user_name
  • command
  • text
  • response_url

サンプル

command と text を取得してみます

コード

function doGet(e) {
  var res = {"text": "pong:" + e.parameter.command + e.parameter.text};
  return ContentService.createTextOutput(JSON.stringify(res)).setMimeType(ContentService.MimeType.JSON);
}

デモ

  • 入力
/ping hoge hige
  • 出力

f:id:tbpg:20161221230940p:plain

関連情報