The Project is part of Microverse Ruby Curriculum. Its task is to build a simple bot as described in here
- Ruby
- Ruby Gems
- VSCode
- Terminal
- Linter
The implemented project is a bot that interacts with the users on the Slack Platform and returns news from the CNN Platform.
The bot takes the API token to work on Slack and is implemented using the rss functionality of the page of the CNN-rss.
In order to understand the coding for the bot, these are some links that are helpful:
https://www.driftingruby.com/episodes/creating-a-simple-slack-bot
https://github.com/slack-ruby/slack-ruby-bot
https://www.rubydoc.info/gems/slack-ruby-bot/0.8.0/SlackRubyBot/Bot
https://www.rubydoc.info/gems/slack-ruby-bot/0.8.0/SlackRubyBot/Commands/Base
https://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html
Start creating your repo and on the terminal type $bundle init
. This command is going to create your Gemfile.
Add the gems as the following screenshot:
Now, to Link your file to the API with Slack, go to slack.com/services/new/bot in your workspace (You must be on a workspace so the link will work) and create a bot application to get a SLACK_API_TOKEN.
Choose from the two options to connect your machine to Slack:
Option 1 - .env file
- Add
SLACK_API_TOKEN = @your_token_here
- Add
gem 'dotenv' to your Gemfile
- Code the config.ru file as in this repo
Option 2 - export
- Type
$export SLACK_API_TOKEN=@your_token_here
on your terminal
- Add
token=ENV['SLACK_API_TOKEN']
as in the video of the last link (check after 13')
If you choose to apply option 1, add the same Gems on the Gemfile of this Repo
- celluloid-io
- dotenv
- puma
- rack
- slack-ruby-bot
The files main.rb
and bot.rb
just require the communication with other files and/or describe the functionality of the help command, respectively.
The important file to understand of your first Bot implementation, is the command file get_news.rb
. The main concept in this file is that you can open an url after requiring require 'open-uri'
and then you can Parse the information within the variable to finally access it as items format.
Finally, just run on your terminal the bundle exec rackup
to connect your first Slack Ruby bot to the workspace previosly.
The link for the video presentation in Loom platform is here
👤 Rafael Nazario
- Github: @rsnazario
- Twitter: @rsnazario
- Linkedin: Rafael Nazario
Contributions, issues are welcome!
Feel free to check the issues page here
Give a ⭐️ if you like this project!
- Microverse!
- Programming Partner: Elbie Moonga
- Microverse Friends: Julio Añoveros Barrera | Eduardo Cruz
- Microverse Mentor: Carlos Augusto Medeiros Filho