Skip to content

Instantly share code, notes, and snippets.

@wiserfirst
Last active May 12, 2022 02:37
Show Gist options
  • Save wiserfirst/0012014c21907843baadf0699f24ff8e to your computer and use it in GitHub Desktop.
Save wiserfirst/0012014c21907843baadf0699f24ff8e to your computer and use it in GitHub Desktop.

How to create a Slash command

  1. Create a Slack app on https://api.slack.com/apps
  2. Create a new Slash command in app management on Slack. A number of fields to fill out, but most important are:
    • Command name: what the user should type after /
    • Request URL: URL of the Slack app backend. When the user do type the command, Slack will send a POST request to the Request URL. It needs to be publicly accessible and it needs to be able to handle the requests from Slack.
  3. Sample request from Slack
  %{
    "api_app_id" => "A02DMAGNJ21",
    "channel_id" => "C02FFNUTGBS",
    "channel_name" => "priv-test-video",
    "command" => "/meet",
    "is_enterprise_install" => "false",
    "response_url" =>
      "https://hooks.slack.com/commands/T033NA***/2763195051441/9Euw22LTMOHkjqK8cfgE4wVI",
    "team_domain" => "telnyx",
    "team_id" => "T033NA***",
    "text" => "",
    "token" => "RSVU4xGkEEwBYIZrM9GJGTcN",
    "trigger_id" => "2752826282196.3124344411.690a4adfbdb8bf7f4a86dba3529445c0",
    "user_id" => "U02DKE08LUA",
    "user_name" => "qingwu"
  }
  1. Respond using Block kit
  2. Verify request signature https://api.slack.com/authentication/verifying-requests-from-slack

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment