GithubHelp home page GithubHelp logo

ws-slack's Introduction

img

Spin Up a Slack Microservice using Flask

This template is an example of a web server inside the WayScript X lair environment that can query the Slack API. It includes 3 endpoints -

  • GET /channels - get all the channels in a workspace
  • POST /message send message to a channel or user
  • GET /status checks whether the API is properly integrated with slack

Setup

1) Setup a Slack App

In order to setup a slack app, complete the following tutorials.

  • Create an app
  • Request scopes - Scopes dictate how much power your slack app posessess. In the sidebar of your app page, click on "OAuth & Permissions" and scroll down to the Scopes section. Add the following scopes channels:read, chat:write, chat:write.public.
  • Install to a workspace of your choice - Click on the "Install App" button in the sidebar of your app page. Click on the "Install App To Workspace" to install to your workspace.

2) Save auth token to Lair

Open the OAuth & Permissions section from the app sidebar. It's the same place you setup the app scopes. Copy the Bot User OAuth Token.

Next, save the key to the .secrets file in your Lair. Set the key as SLACK_API_TOKEN and the value as the token you obtained from slack.

3) Deploy application

A trigger should already be pre-configured. Follow this guide to set a trigger in case the trigger isn't present. Press the play button next to the trigger to deploy the flask app.

The app should now be accessible via the endpoint specified next to the trigger. By default, the endpoint is only privately accessible, i.e. it can only be accessed in a browser where you are already logged into WayScript. You can make it publicly accesssible by going to the endpoints tab and setting "Make endpoints publicly accessible" to true. You can learn more about endpoints here.

4) Verify that service is up and working correctly

Visit the ENDPOINT/status endpoint. If you get "Slack API is connected and working properly", it means the service is running and authenticated to connect with your slack workspace. You can also run the example.py by typing python example.py inside a WayScript terminal or press the play button in the top right corner of wayscript with example.py open.

Run tests

You can run tests that cover the functionality by running

python -m pytest

Further reading

Setup a Flask Server (Python)

ws-slack's People

Contributors

haranrk avatar jdhayford avatar jeffbuswell avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nick-mylo

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.