Skip to content

Instantly share code, notes, and snippets.

@sasasin
Created April 25, 2020 18:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasasin/28fbb22d3e40dd8518be5f2f30df5e42 to your computer and use it in GitHub Desktop.
Save sasasin/28fbb22d3e40dd8518be5f2f30df5e42 to your computer and use it in GitHub Desktop.
slack_slash_command.rb
#!/usr/bin/env ruby
require 'slack-ruby-client'
Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
end
client = Slack::Web::Client.new
channel_name = ARGV[0]
slash_command = ARGV[1]
message_text = ARGV[2]
channel_id = client.channels_id(channel: channel_name).channel.id
response = client.chat_command(channel: channel_id, command: slash_command, text: message_text)
pp response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment