Skip to content

Client Slack

Keith Sterling edited this page Mar 15, 2019 · 4 revisions

Slack Client

Slack is a cloud-based set of proprietary team collaboration tools and services, founded by Stewart Butterfield. Slack began as an internal tool used by their company, Tiny Speck, in the development of Glitch, a now-defunct online game. The name is an acronym for "Searchable Log of All Conversation and Knowledge"

For an introduction on how to configure your Slack bot for integration with Program-Y read the Slack Documentation

##Creating a Slack Bot Login into slack and then head over to the Slack Apps page at https://api.slack.com/apps which should look something like the following screen

Click ‘Create an App’

The following pop up will appear

Give your app a name and select which workspace to associate it.

Click ‘Create App’ and wait for the app the be created. The web site will then automatically switch you apps Basic Information page, which should look something like this

Next we need to create a Bot User. Click on the ‘Bots’ panel, and the screen will look like this following

Click ‘Add Bot User’ to see the following screen

You can pretty much leave the info as it is, and click ‘Add Bot User’, wait for the user to be created then click ‘Save Changes’

Next, on the left hand side menu click ’Event Subscriptions’

Then toggle ‘Enable Events’ on On, The screen should change to the following

Finally click on ‘OAuth & Permissions’ on the left hand side menu

And click ‘Install App into Workspace’

Click ‘Authorize’, and it will return you to the following page with some new tokens for you bot

Click the ‘Copy’ button to copy the token under the title ‘Bot User OAuth Access Token’. You copy this token into your licenses.keys file

You are now ready to talk to your bot

Running Slack Client

To run the Facebook client, you can use the shell script in Y-Bot scripts folder

./y-bot-slack.sh

Or you can use the command line

python3 -m programy.clients.polling.slack.client --config <PATH TO CONFIG> --cformat yaml --logging <PATH TO LOGGING>
``

Either way you should see the following output

```bash
Loading Slack client, please wait. See log output for progress...
No bot root argument set, defaulting to [../../config/xnix]
Found a total of 1 errors in your grammars, check your errors store
Found a total of 6 duplicates in your grammars, check your duplicates store
Slack Bot connected and running...

Head over to your favourite client, and you should see you app in the list of apps on the left hand side

You interact my sending a direct message using the @ and then your question

Configuration

The client only requires a single setting in config.yaml. The polling interval for which to check for news messages. This is set as follows

slack:
  polling_interval: 1
Clone this wiki locally