A simple Slack bot that can monitor weekly Strava group progress. The Slack bot runs in Google Functions. A selectable number of groups can be monitored and the results can be posted to a slack channel using a configurable cron job. All configuration for the bot is stored in Firestore.
Members in each group can earn points in a group in 2 ways:
Achieve a weekly goal by logging at least 3 activities with a minimum of 30 minutes of active time.
Achieve a position on the leader boards at the end of each week and earn FitCoin. The Top 5 in each category will earn FitCoin.
Activity Type | Category | 1st Place | 2nd Place | 3rd Place | 4th Place | 5th Place |
---|---|---|---|---|---|---|
Distance | 5 FitCoin | 4 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin | |
On Wheels | Duration | 5 FitCoin | 4 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin |
Elevation | 5 FitCoin | 5 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin | |
------------- | -------------- | --------- | --------- | --------- | --------- | --------- |
Distance | 5 FitCoin | 4 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin | |
On Foot | Duration | 5 FitCoin | 4 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin |
Elevation | 5 FitCoin | 5 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin | |
------------- | -------------- | --------- | --------- | --------- | --------- | --------- |
Other | Duration | 5 FitCoin | 4 FitCoin | 3 FitCoin | 2 FitCoin | 1 FitCoin |
Configuration Item | Description |
---|---|
slackWebhookUrl | Set the Slack Webhook URL to post messages to. |
stravaBotId | Name of the Strava bot account |
stravaClientId | Strava OAuth ID of the bot account |
stravaRefreshToken | Strava OAuth refresh token of the bot account |
stravaClientSecret | Strava OAuth client secret token of the bot account |
stravaClubs | Array of Strava clubs to monitor |
An example config upload is provided in upload-config.ts.
To use the Strava API you will need an Oauth refresh token, to get that you will first need to create an API application, you can then get your client ID and secret from the strava api settings page
The scope of the Strava OAuth token must be set to read,activity:read,activity:write
.
Write permission is needed to create the weekly placeholder event
More details on Strava authentication can be found on their website.
You can get a refresh token with the correct scope by running the create-strava-token.ts script:
npm run ts ./examples/create-strava-token.ts -- --clientId <your-client-id> --clientSecret <your-client-secret>
Authorize the OAuth login of the strava account you want to give access and you will get the refresh token
For local development, service account credentials can be created by following getting started Google guide. Generate JSON service account credentials. Place the credentials in the project root directory and ensure it is named service-account.json
.