Giter VIP home page Giter VIP logo

tirthajyoti-ghosh / slack-adder-bot Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 85 KB

A simple slack chatbot that adds two numbers. Eg: when the user types to the bot `234 + 123`, it responds back with `357`. Built with Ruby.

Home Page: https://enigmatic-thicket-31440.herokuapp.com/

License: MIT License

Ruby 66.76% HTML 13.30% JavaScript 19.94%
slack-bot ruby mongodb mongoid slack-ruby-bot-server

slack-adder-bot's Introduction

Contributors Forks Stargazers Issues License: MIT LinkedIn


Logo

Slack Adder Bot

A Slack bot that adds two numbers. Built with Ruby.
Explore the docs »

Video Demo · Report Bug · Request Feature

Table of Contents

About The Project

A simple slack chat bot that adds two numbers. Eg: when the user types to the bot 234 + 123, it responds back with 357.

Screenshot

Built With

  • slack-ruby-bot-server
  • slack-ruby-bot-server-events
  • mongodb
  • mongoid

Live demo

IMPORTANT! Checkout this video first - https://www.loom.com/share/07050cd0480c4109b01ad411b9e92189

Deployed to Heroku - https://enigmatic-thicket-31440.herokuapp.com/

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • MongoDB
  • Ruby
  • Admin access to a Slack Workspace.

Setting Up Slack

  1. Create a new Slack app from here

  2. Scroll down and you will find the App Credentials section. Take note of these four fields:

    • Client ID
    • Client Secret
    • Signing Secret
    • Verification Token

    image

    You will need these later.

  3. Go to OAuth & Permissions. You will find this option in the side bar.

    image

  4. Scroll down to Scopes and add these 👇 scopes one-by-one to Bot Token Scopes:

    • users:read
    • channels:read
    • groups:read
    • chat:write
    • commands
    • im:history
    • incoming-webhook

    image)

  5. Go to Event Subscriptions. You will find this option in the side bar. Then enable events.

    image

  6. Click on Subscribe to bot events. Then click on the Add Bot User Event button. Then add message.im event.

    image

    Everytime you send a direct message to the bot, the message.im event will be fired.

  7. Now you have to install this app to your workspace. Go to Basic Information. You will find this option in the side bar. Then click the Install to Workspace button.

    image

  8. In the next page, you will be asked to Allow the bot permissions. In the last permission (Where should Example Bot post?), select any channel.

    image

Installation

  1. Clone this repository.

    git clone https://github.com/tirthajyoti-ghosh/slack-adder-bot.git
  2. Create an .env file in the root directory. Then fill these 👇 with their respective values (client id, client secret, etc. from slack app). The values must be put after the = sign.

    SLACK_CLIENT_ID=
    SLACK_CLIENT_SECRET=
    SLACK_SIGNING_SECRET=
    SLACK_VERIFICATION_TOKEN=
    
  3. Run bundle install and foreman start to boot the app.

    $ foreman start
    07:44:47 web.1  | started with pid 59258
    07:44:50 web.1  | * Listening on tcp://0.0.0.0:5000

Setting Up Web Hook

  1. Since Slack won't send a POST request to localhost, we need to expose our local server through a public tunneling service. You can use ngrok.

    $ ngrok http 5000
    Forwarding https://ddfd97f80615.ngrok.io -> http://localhost:5000
  2. Go to Event Subscriptions in your Slack apps dashboard. You will find this option in the side bar. Then paste this URL in the Request URL field:

    <your ngrok URL>/api/slack/event
    
    Eg.,
    
    https://ddfd97f80615.ngrok.io/api/slack/event
    

    image

  3. Click on Save Changes if necessary.

Usage

Start a direct chat with the bot. The input must be in this format => 6+3. If the input does not have two numbers and an addition symbol in between, respond back with a error message - "Sorry, I didn't understand that. I only add numbers in this format. eg: 5+6 or 6+3".

usage

Roadmap

  • Add tests.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

👤 Tirthajyoti Ghosh

Project Link: https://github.com/tirthajyoti-ghosh/slack-adder-bot

Acknowledgements

slack-adder-bot's People

Contributors

tirthajyoti-ghosh avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

menyagah

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.