Giter Club home page Giter Club logo

simple_slack_bot's Introduction

BUILD YOUR OWN SLACKBOT

slackimage

SUMMARY

We are going to build a bot using node, which we will run from our own machine. It will interface with two APIs, so that when the user asks for a joke we will return the joke from the API in the slack channel.

RESOURCES

SLACKBOT API

Link here , you can install this easily from command line by running npm install slackbots .

This lib is very easy and practical.

FROM SCRATCH

workspace

Go to here to sign up, then once you have entered your email, select create a new workspace

You will then go into your slack workspace - which looks like a chat window. You have two workspaces, we want the bot to work in the general chanel.

CREATE THE BOT

Go to https://api.slack.com/apps and give the bot a name, and select your workspace name from the dropdown.

From the basic information tab on the left hand side, we then select bots followed by add bot user

online

Keep the always show bot as online selected off. This means it will only come online once your server is running.

Make change and select save changes.

features

Notice features should now be ticked.

Next step is to select install app to your workspace below the features button. Select authorize and you will notice it is also now ticked.

features

Scroll down on the main page, add an avatar including a description

START YOUR PROJECT

Open up terminal or in my case VSCODE and work on shell from there and run :

npm init

Give it a description, author, etc.

Lets add our dependencies - we need slackbot as mentioned above and also axios so we can make api requests.

npm i slackbots axios

Lets ensure our app starts when we start the server by adding hte following snippet into package.json if you are unsure look at my example in the directory above.

  "scripts": {
    "start": "node index.js"
  },

Let's create our index.js file and you can modify from my example in this repo. The only major thing you need to remember is to get the token, you need to go to OAuth and Permissions tab on the left hand side of your bot creation page as shown below, then select Bot User OAuth Access Token

features

In my code I am reading the contents from a file called js.txt which i have not included in this repo.

I have left the second API call for you to modify and fix yourself to pull back the joke required.

When you are ready to test and run your app, just enter into command line:

npm start

Good luck!!

simple_slack_bot's People

Contributors

murchie85 avatar

Stargazers

Nigel Abbott avatar

Watchers

 avatar  avatar

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.