- Notifications
You must be signed in to change notification settings - Fork1
wayscript/ws-slack
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 workspacePOST /message
send message to a channel or userGET /status
checks whether the API is properly integrated with slack
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.
Open the OAuth & Permissions section from the app sidebar. It's the same place you setup the app scopes. Copy theBot User OAuth Token
.
Next, save the key to the.secrets
file in your Lair. Set thekey
asSLACK_API_TOKEN
and thevalue
as the token you obtained from slack.
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 endpointshere.
Visit theENDPOINT/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 theexample.py
by typingpython example.py
inside a WayScript terminal or press the play button in the top right corner of wayscript withexample.py
open.
You can run tests that cover the functionality by running
python -m pytest