Slackbot is aimed to help you to find players for matches. It works with help of Slack interactive messages and doesn't flood a lot. So it's really easy way to start a game. Also, it reports games results and could show statistics on request. It is written on Node.js as a server application. Botkit is used as a basis for the bot to communicate with users. Match's results and statistics are based on the information from Firebase datastorage.
You should go to the project setup in firebase console and click Add Firebase to your web application. You should get information like this:
<script src="https://www.gstatic.com/firebasejs/3.7.3/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "SOME_FIREBASE_API_KEY",
authDomain: "SOME_FIREBASE_AUTH_DOMAIN",
databaseURL: "https:/SOME_FIREBASE_PROJECT_NAME.firebaseio.com",
storageBucket: "SOME_FIREBASE_PROJECT_NAME.appspot.com",
messagingSenderId: "SOME_FIREBASE_MESSAGING_SENDER_ID"
};
firebase.initializeApp(config);
</script>Please, save this config information, it'll be needed later.
First of all, you need to create slack application and:
-
Give our application the following permission in Features -> OAuth & Permissions:
- Confirm user’s identity.
- Access user’s profile and team profile fields.
- View email addresses of people on this team.
-
And specify Redirect URL on the same page. Redirect URL should point to https://yousite.com/oauth.
-
Go to Bot users and add Bot User, named, for example, foosbot to the application.
-
Install the application to your team on Intall App page.
-
Then you should collect all necessary tokens and secrets for your bot:
- Bot User OAuth Access Token on Install App page.
- Client ID, Client Secret and Redirect URL on OAuth & Permissions page.
-
Enabling Interactive Messages will be possible ONLY after running your application on the server (see server section). Once application on your server runs successfully, it'll create an endpoint for slack interactive messages on path https://yousite.com/slack/receive. You should specify this URL as Request URL for your application on Interactive Messages page.
To deploy the application to your server you need Node.Js 7.7.4 or higher and npm 4.4.1 or higher. The application could add all necessary node_modules with help of npm install command.
Slack demands to have SSL certificate on your server for using Interactive messages. You can get it, for example, from Let's Encrypt provider. Please, save public key and merged certificate somewhere on your server.
After that you have to create file named config.json in SlackBot/app/config/ directory with config for Slackbot and Firebase
{
"settings": {
"maxPlayers": 4
},
"slack": {
"token": "$(Bot User OAuth Access Token)",
"clientId": "$(Cliend ID)",
"redirectUri": "$(Redirect URL)",
"clientSecret": "$(Cliend Secret)"
},
"firebase": {
"apiKey": "SOME_FIREBASE_API_KEY-quwPnMxLfag",
"authDomain": "SOME_FIREBASE_AUTH_DOMAIN.firebaseapp.com",
"databaseURL": "https://SOME_FIREBASE_PROJECT_NAME.firebaseio.com",
"storageBucket": "SOME_FIREBASE_PROJECT_NAME.appspot.com"
},
"ssl": {
"privateKey": "path/to/publicKey",
"certificate": "path/to/certificate"
}
}Then you will be able to start the application, turn on Slack Interactive Messages, invite bot to general channel, and start to use it.
The bot has two main commands mentioned above:
@foosbot play - for looking for players with help of interactive messages with buttons
@foosbot stats - for displaying week's statistics
