Building Slack Apps with Ruby – Kirill Shevchenko

Ruby Meditation
Ruby MeditationRuby Meditation
Building SlackBuilding Slack
Apps withApps with
RubyRuby
Integrations OverviewIntegrations Overview
Slash Commands
Custom Integrations
Bot Users
Incoming Webhooks
Incoming webhooksIncoming webhooks
A way to send messages to Slack
https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
Incoming webhooksIncoming webhooks
require 'slack/incoming/webhooks'
slack = Slack::Incoming::Webhooks.new(
'WEBHOOK_URL'
)
slack.post 'Useful information'
https://github.com/shoyan/slack-incoming-webhooks
ExampleExample
Slash commandsSlash commands
A way to add /slash commands
Creating a new Slack App
Command request authorization
Command validation and response
Sending messages through Slack Web API
Creating a Slack AppCreating a Slack App
https://api.slack.com/apps
Response PermissionResponse Permission
Adding a commandAdding a command
Local HTTPS-ProxyLocal HTTPS-Proxy
./ngrok http 9292
Response SampleResponse Sample
require 'sinatra'
post '/' do
'OK'
end
Building Slack Apps with Ruby – Kirill Shevchenko
Legacy custom integrationsLegacy custom integrations
Custom integrationsCustom integrations
https://api.slack.com/custom-integrations/legacy-tokens
Bot usersBot users
ToolsTools
https://github.com/slack-ruby
slack-ruby-botslack-ruby-bot
Provides DSL for building text commands.
slack-ruby-clientslack-ruby-client
A Ruby and command-line client for the Slack Web and
Real Time Messaging APIs.
slack-ruby-botslack-ruby-bot
require 'slack-ruby-bot'
class PongBot < SlackRubyBot::Bot
command 'ping' do |client, data, match|
client.say(text: 'pong', channel: data.channel)
end
end
PongBot.run
A Minimal Bot
SLACK_API_TOKEN=... bundle exec ruby pongbot.rb
AuthenticationAuthentication
{
"access_token": "xoxp-XXXXXXXX-XXXXXXXX-XXXXX",
"scope": "commands,bot",
"team_name": "Team Installing Your Bot",
"team_id": "XXXXXXXXXX",
"bot":{
"bot_user_id":"UTTTTTTTTTTR",
"bot_access_token":"xoxb-XXXXXXXXXXXX-TTTTTTTTTTTTTT"
}
}
ResponseResponse
Slack Web APISlack Web API
The Web API is a collection of , all with
URLs in the form:
HTTP RPC-style methods
https://slack.com/api/METHOD_FAMILY.method 
slack-ruby-clientslack-ruby-client
client = Slack::Web::Client.new(
token: 'SLACK_BOT_TOKEN'
)
client.chat_postMessage(
channel: '#general', text: 'Hello World'
)
https://api.slack.com/methods/chat.postMessage
Web API rate limitWeb API rate limit
https://api.slack.com/methods/chat.update
Interactive messagesInteractive messages
https://api.slack.com/interactive-messages
Message FormattingMessage Formatting
https://api.slack.com/docs/messages/builder
Walkie BotWalkie Bot
Prototyping Tool for Slack Bots
https://github.com/FoundersAS/walkiebot
Building Slack Apps with Ruby – Kirill Shevchenko
Slack RTMSlack RTM
The Real Time Messaging API is a WebSocket-based API that
allows you to receive  from Slack in real time.events
rtm.connectrtm.connect
Workspace
https://api.slack.com/methods/rtm.connect
wss://slack-msgs.com/websocket/uid
client = Slack::RealTime::Client.new(
token: 'SLACK_BOT_TOKEN'
)
client.on :message do |data|
client.message(
channel: data.channel,
text: "Hi <@#{data.user}>!"
)
end
client.start!
Ruby Websocket ClientsRuby Websocket Clients
Faye::Websocket
websocket-client-simple
Multiple connectionsMultiple connections
Workspace 1
Workspace 2
Workspace N
wss://slack-msgs.com/websocket/uid
wss://slack-msgs.com/websocket/uid
wss://slack-msgs.com/websocket/uid
Concurrent ProcessingConcurrent Processing
eventmachine
celluloid
concurrent-ruby
slack-ruby-clientslack-ruby-client
Slack::RealTime.configure do |config|
config.concurrency = Slack::RealTime::Concurrency::Celluloid
# config.concurrency = Slack::RealTime::Concurrency::Eventmachine
end
Building Slack Apps with Ruby – Kirill Shevchenko
AlternativesAlternatives
https://github.com/slackapi/node-slack-sdk
https://github.com/BlakeWilliams/Elixir-Slack
Building Slack Apps with Ruby – Kirill Shevchenko
API UpdatesAPI Updates
https://slack.com/apps/A0F81R7U7-rss
CommunityCommunity
https://community.botkit.ai
Thanks!Thanks!
kirillshevchkirillshevch
@kirill_shevch@kirill_shevch
@kirill_shevch@kirill_shevch
1 of 38

More Related Content

Similar to Building Slack Apps with Ruby – Kirill Shevchenko(20)

Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman108.6K views
AWS Serverless WorkshopAWS Serverless Workshop
AWS Serverless Workshop
Mikael Puittinen1.3K views
Intro to Alfresco for DevelopersIntro to Alfresco for Developers
Intro to Alfresco for Developers
Jeff Potts12.1K views
Power Shell and Sharepoint 2013Power Shell and Sharepoint 2013
Power Shell and Sharepoint 2013
Mohan Arumugam520 views
Dev streams2Dev streams2
Dev streams2
David Mc Donagh154 views
OpenFaaS JeffConf 2017 - MilanOpenFaaS JeffConf 2017 - Milan
OpenFaaS JeffConf 2017 - Milan
Alex Ellis1.5K views
Scala Vienna Website: reloadedScala Vienna Website: reloaded
Scala Vienna Website: reloaded
Nikolay Kushin559 views
Spring Cloud Stream with KafkaSpring Cloud Stream with Kafka
Spring Cloud Stream with Kafka
David Kiss392 views
Flutter for webFlutter for web
Flutter for web
rihannakedy302 views
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
ssuser65180a1K views
Function as a ServiceFunction as a Service
Function as a Service
rich fernandez745 views
Building Serverless APIs on AWSBuilding Serverless APIs on AWS
Building Serverless APIs on AWS
Julien SIMON1.1K views

More from Ruby Meditation(20)

Recently uploaded(20)

METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation23 views
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya51 views
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web Developers
Maximiliano Firtman152 views

Building Slack Apps with Ruby – Kirill Shevchenko