Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Building Slack Apps with Ruby – Kirill Shevchenko


Published on

Ruby Meditation #22
May 19, 2018

Published in: Technology
  • You can ask here for a help. They helped me a lot an i`m highly satisfied with quality of work done. I can promise you 100% un-plagiarized text and good experts there. Use with pleasure! ⇒ ⇐
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

Building Slack Apps with Ruby – Kirill Shevchenko

  1. 1. Building SlackBuilding Slack Apps withApps with RubyRuby
  2. 2. Integrations OverviewIntegrations Overview Slash Commands Custom Integrations Bot Users Incoming Webhooks
  3. 3. Incoming webhooksIncoming webhooks A way to send messages to Slack
  4. 4. Incoming webhooksIncoming webhooks require 'slack/incoming/webhooks' slack = 'WEBHOOK_URL' ) 'Useful information'
  5. 5. ExampleExample
  6. 6. 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
  7. 7. Creating a Slack AppCreating a Slack App
  8. 8. Response PermissionResponse Permission
  9. 9. Adding a commandAdding a command
  10. 10. Local HTTPS-ProxyLocal HTTPS-Proxy ./ngrok http 9292
  11. 11. Response SampleResponse Sample require 'sinatra' post '/' do 'OK' end
  12. 12. Legacy custom integrationsLegacy custom integrations Custom integrationsCustom integrations
  13. 13. Bot usersBot users
  14. 14. ToolsTools 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.
  15. 15. slack-ruby-botslack-ruby-bot require 'slack-ruby-bot' class PongBot < SlackRubyBot::Bot command 'ping' do |client, data, match| client.say(text: 'pong', channel: end end A Minimal Bot SLACK_API_TOKEN=... bundle exec ruby pongbot.rb
  16. 16. AuthenticationAuthentication
  17. 17. { "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
  18. 18. Slack Web APISlack Web API The Web API is a collection of , all with URLs in the form: HTTP RPC-style methods�
  19. 19. slack-ruby-clientslack-ruby-client client = token: 'SLACK_BOT_TOKEN' ) client.chat_postMessage( channel: '#general', text: 'Hello World' )
  20. 20. Web API rate limitWeb API rate limit
  21. 21. Interactive messagesInteractive messages
  22. 22. Message FormattingMessage Formatting
  23. 23. Walkie BotWalkie Bot Prototyping Tool for Slack Bots
  24. 24. Slack RTMSlack RTM The Real Time Messaging API is a WebSocket-based API that allows you to receive �from Slack in real
  25. 25. rtm.connectrtm.connect Workspace wss://
  26. 26. client = token: 'SLACK_BOT_TOKEN' ) client.on :message do |data| client.message( channel:, text: "Hi <@#{data.user}>!" ) end client.start!
  27. 27. Ruby Websocket ClientsRuby Websocket Clients Faye::Websocket websocket-client-simple
  28. 28. Multiple connectionsMultiple connections Workspace 1 Workspace 2 Workspace N wss:// wss:// wss://
  29. 29. Concurrent ProcessingConcurrent Processing eventmachine celluloid concurrent-ruby
  30. 30. slack-ruby-clientslack-ruby-client Slack::RealTime.configure do |config| config.concurrency = Slack::RealTime::Concurrency::Celluloid # config.concurrency = Slack::RealTime::Concurrency::Eventmachine end
  31. 31. AlternativesAlternatives
  32. 32. API UpdatesAPI Updates
  33. 33. CommunityCommunity
  34. 34. Thanks!Thanks! kirillshevchkirillshevch @kirill_shevch@kirill_shevch @kirill_shevch@kirill_shevch