This is easy way to implement your first slack bot in ruby use slack-ruby-bot gem.
$ git clone git@github.com:mgleon08/simple_slack_bot.git
Registering the bot to get SLACK_API_TOKEN
https://my.slack.com/services/new/bot
Get YOUTUBE_API_TOKEN
from https://console.developers.google.com
copy .env_example
to .env
SLACK_API_TOKEN=[copy you apply for slack token]
YOUTUBE_API_TOKEN=[copy you apply for youtube token]
If you want to show gif, you can add WITH_GIPHY=
in .env
.
foreman start
Commands:
@<bot> - Show about information
@<bot> help - Show help information
@<bot> youtube <query> - Searches YouTube for the query and returns the video embed link.
simple_slack_bot/main_bot/commands/[yourfile]
Bot trigged word
module MainBot
module Commands
class Help < SlackRubyBot::Commands::Base
command 'help' do |client, data, _match|
client.say(channel: data.channel, text: MainBot::HELP, gif: 'help')
end
end
end
end
simple_slack_bot/main_bot/supports/[yourfile]
Bot Support features
module MainBot
HELP = <<-HELP.freeze
*Commands:*
*@<bot>* - Show about information
*@<bot> help* - Show help information
*@<bot> youtube <query>* - Searches YouTube for the query and returns the video embed link.
HELP
end
It have three way to match word match
, comman
, scan
# create new heroku project
heroku create
# push heroku
git push heroku master
# env config setting
heroku config:add SLACK_API_TOKEN=[YOUR_ SLACK_API_TOKEN]
# env config remove
heroku config:remove SLACK_API_TOKEN
# log
heroku logs --tail
# scale
heroku ps:scale web=2
uptimerobot To prevent dormancy
See below to get more information