Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caarmen/slack-health-bot
Slack notifications for limited Withings and Fitbit data
https://github.com/caarmen/slack-health-bot
Last synced: 12 days ago
JSON representation
Slack notifications for limited Withings and Fitbit data
- Host: GitHub
- URL: https://github.com/caarmen/slack-health-bot
- Owner: caarmen
- License: mit
- Created: 2023-04-29T21:39:11.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-01T15:53:54.000Z (19 days ago)
- Last Synced: 2025-02-01T16:31:38.585Z (19 days ago)
- Language: Python
- Homepage:
- Size: 554 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slack-health-bot: Slack notifications for limited Withings and Fitbit data
Pushes messages to a pre-selected Slack channel, when users log new weight data in Withings or new sleep or activity data in Fitbit.
[](https://github.com/caarmen/slack-health-bot/actions/workflows/check.yml?query=branch%3Amain)
[](https://github.com/caarmen/slack-health-bot/blob/main/LICENSE)
[](https://github.com/caarmen/slack-health-bot/releases)[](https://github.com/caarmen/slack-health-bot/archive/refs/heads/main.zip)

[](https://github.com/caarmen/slack-health-bot/releases)
[](https://github.com/caarmen/slack-health-bot/commits/main)
[](https://github.com/caarmen/slack-health-bot/commits/main)[](https://github.com/caarmen/slack-health-bot/stargazers)
[](https://github.com/caarmen/slack-health-bot/forks)## Configuration
* Create an application in the [Withings developer dashboard](https://developer.withings.com/dashboard/).
* Create an application in the [Fitbit developer dashboard](https://dev.fitbit.com/apps/).
* Create an application [on Slack](https://api.slack.com/apps), with a webhook to post messages to a specific channel.
* Copy the `.env.template` file to `.env`, and modify the values.
* [Optional]: Copy the `config/app-custom.yaml.template` file to `app-custom.yaml`, and override any values which are defined in `config/app-default.yaml`.## Retrieve the docker image
Retrieve the image:
```
docker pull ghcr.io/caarmen/slack-health-bot:latest
```## Run the docker image
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 `pwd`/app-custom.yaml:/app/config/app-custom.yaml -v /path/to/data/:/tmp/data ghcr.io/caarmen/slack-health-bot
```## Using the application
### Withings
* 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.
* 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#### Forcing a measurement to be pushed to slack
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"'
```### Fitbit
* 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.
* 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: 96You 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;"
```