/askia is a free Slack app created by Askia to ask & answer simple polling questions in a Slack workspace. He can be yours right now, simply download him from here.
/askia is open source (licensed under GNU GPL v3), and you can use him to help you decide anything: where you'll be eating for lunch, what time your friends or colleagues want to meet up, ...
-
Go on https://api.slack.com/apps. Then create a new app in Slack.
-
Give it a name and associate it to a Slack
domain
-
Select
Slash Commands
and clickCreate New Command
-
Set your slash command settings to
https://{yourdomain}/post
-
Select
Interactive Components
and add a requesthttps://{yourdomain}/actions
-
Select
OAuth & Permissions
and clickInstall App to Workspace
-
Add redirect url :
https://{yourserveraddress}/slack/auth/redirect
-
Get your workspace token
-
Scroll down to
Scopes
and sets your workspace rightschat:write:bot
chat:write:user
-
Install mongodb
-
Set your database url in env var.
export DATABASE_URL="mongodb://127.0.0.1:27017"
-
Set your database name in mongodb and then in env vars too.
export DATABASE_NAME="myPollDb"
-
Create a Unix server and install:
node: 10.x.x
npm: 6.x.x
-
Clone the repository on your server.
-
Go at the root level of your repository and then install package dependencies
npm install
-
Set
SLACK_APP_OAUTH
environment variable with token that you got at step6
from theSlack configuration
guide.export SLACK_APP_OAUTH=xoxp-xxx-xxx-xxx-xxx
-
Set
SLACK_APP_TOKEN
environment variable with token that you can get on your Slack application management interface. Go toBasic Information
then scroll down toApp Credentials
and gets theVerification Token
value.export SLACK_APP_TOKEN=xxxxxxxxxx
-
If your app is not distributed you'll have to disable the team authentication
export DISABLE_SLACK_TEAM_AUTH=1
Otherwise:
export DISABLE_SLACK_TEAM_AUTH=""
-
Set the server
PORT
export PORT=6463
-
Install and run certbot to generate the SSL certificate
sudo apt install certbot
-
Once SSL cert is generated:
- set
SSL_KEY
to yourprivkey.pem
path - set
SSL_CERT
to yourcert.pem
path - set
SSL_CHAIN
to yourchain.pem
path
- set
-
Install PM2 with npm
npm install --global pm2
-
Register and launch your application with pm2
-
Go back to the slack app interface and go to
Manage distribution
and click to the slack button and proceed to the installation
NOTES: Do not forget to launch PM2 and exports variables at startup.
- PM2 startup script: https://pm2.io/docs/en/runtime/guide/startup-hook
- Env variables can be defined in pm2 ecosystem file: https://pm2.io/doc/en/runtime/guide/ecosystem-file/
To create a simple poll you can specify question and responses like this:
/askia Drink? Wine Beer Pastis Water
If the question or the responses contains space they must be wrapped between quotes " characters like this:
/askia "What ya wanna drink?" "IPA Beer" "Stout Beer" Other
If a response is too long to be displayed as button or if you simply don't want to repeat the whole text of your response in a button. You can select the part of your text that will be displayed as button by using @label{}. in the response text:
/askia "What ya wanna drink?" "Double @label{IPA}" "Milk @label{Imperial Stout}"
--limit
/askia "What ya wanna drink?" Wine Beer Scotch Pastis Water --limit 1
Sets a limit of responses that a user can votes for. When set to 0 no limit is applied. Default value is set to 0.
--expires
/askia "What ya wanna drink on Friday?" Wine Beer Water --expires "1d 2h"
Sets the times before users votes will expires. The times can be expressed like this:
- for 1 day 1d
- for 2 hours 2h
- for 10 min 10min
- for 30 seconds 30s
--anonymous
/askia Drink? Wine Beer Water --anonymous
The name of users will not be displayed while they vote--no-anonymous-label/askia Drink? Beer Water --anonymous --no-anonymous-labelWhen the anonymous flag is set, hides the anonymous poll quote at the end of the poll message.
/askia is licensed by Askia - automating insight under GNU GPL v3.
You are welcome to create issues for this project; could they be bug fixes and/or feature requests. In such cases, due to limited availability, we'd appreciate you provide in your issue:
- The error message.
- Slack environments (public / private channel, direct message, user group, user rights, ...)
- Steps to reproduce the error.
We also encourage contributions via Pull Requests.