Pushes messages to a pre-selected Slack channel, when users log new weight data in Withings or new sleep or activity data in Fitbit.
- Create an application in the Withings developer dashboard.
- Create an application in the Fitbit developer dashboard.
- Create an application on Slack, with a webhook to post messages to a specific channel.
- Copy the
.env.template
file to.env
, and modify the values.
Retrieve the image:
docker pull ghcr.io/caarmen/slack-health-bot:latest
Create a folder on the host where the database will be saved: /path/to/data/
.
Run the docker image.
docker run --detach --publish 8000:8000 -v `pwd`/.env:/app/.env -v /path/to/data/:/tmp/data ghcr.io/caarmen/slack-health-bot
- Open the following url in a browser: http://your-server/v1/withings-authorization/your-slack-alias
- Change
your-server
with the address on which the server is available. - Change
your-slack-alias
with your slack username.
- Change
- Authorize the app in the Withings screen.
- Log a new weight measurement in your Withings account.
- After a couple of minutes, you should see a message in the configured slack channel saying:
New weight from @
your-slack-alias
: XX kg
- After a couple of minutes, you should see a message in the configured slack channel saying:
You can force a measurement to be posted to slack, by simulating Withings calling the webhook:
curl --location 'http://your-server/withings-notification-webhook/' \
--form 'userid="1234567"' \
--form 'startdate="1680377444"' \
--form 'enddate="1682969444"'
- Open the following url in a browser: http://your-server/v1/fitbit-authorization/your-slack-alias
- Change
your-server
with the address on which the server is available. - Change
your-slack-alias
with your slack username.
- Change
- Authorize the app in the Fitbit screen.
- Log a new sleep measurement or activity in your Fitbit account.
- After the polling period (if polling is enabled), or after a the webhook is called,
you should see a message in the configured slack channel saying (for the sleep example):
New sleep from @
your-slack-alias
:• Went to bed at 22:17
• Woke up at 7:59
• Total sleep: 8h 31m
• Awake: 1h 11m
• Score: 96
- After the polling period (if polling is enabled), or after a the webhook is called,
you should see a message in the configured slack channel saying (for the sleep example):
You can find your userid in the database file:
sqlite3 -header -column /path/to/slackhealthbot.db \
"select
slack_alias,
withings_users.oauth_userid as withings_userid,
fitbit_users.oauth_userid as fitbit_userid
from users
left outer join withings_users on users.id = withings_users.user_id
left outer join fitbit_users on users.id = fitbit_users.user_id;"