Skip to content

Commit

Permalink
Merge pull request #14 from caarmen/document-fitbit-in-readme
Browse files Browse the repository at this point in the history
Add fitbit info to readme
  • Loading branch information
caarmen authored May 21, 2023
2 parents 480474e + 748cefe commit 13fd21d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
SERVER_URL=http://localhost:8000/
DATABASE_PATH=/tmp/data/slackhealthbot.db
WITHINGS_CLIENT_ID=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
WITHINGS_CLIENT_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
WITHINGS_CALLBACK_URL=http://localhost:8000/
FITBIT_CLIENT_ID=01A2B3
FITBIT_CLIENT_SECRET=0123456789abcdef0123456789abcdef
FITBIT_POLL_INTERVAL_S=3600
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXXXX/abcdefghijklmnopqrstuvwx
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# slack-health-bot integration
# 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.
Pushes messages to a pre-selected Slack channel, when users log new weight data in Withings or new sleep data in Fitbit.

[![GitHub Workflow Status (with branch)](https://img.shields.io/github/actions/workflow/status/caarmen/slack-health-bot/check.yml)](https://github.com/caarmen/slack-health-bot/actions/workflows/check.yml?query=branch%3Amain)
[![GitHub](https://img.shields.io/github/license/caarmen/slack-health-bot)](https://github.com/caarmen/slack-health-bot/blob/main/LICENSE)
Expand All @@ -18,13 +18,12 @@ Pushes messages to a pre-selected slack channel, when users log new weight data
## 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.

## Retrieve the docker image

Log into the [github container registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry).

Retrieve the image:
```
docker pull ghcr.io/caarmen/slack-health-bot:latest
Expand All @@ -42,14 +41,16 @@ docker run --detach --publish 8000:8000 -v `pwd`/.env:/app/.env -v /path/to/data

## 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.
- You should see a message in the configured slack channel saying: "`your-slack-alias` weighed in at XX kg on Sat 29 Apr 2023, 17:45"
- 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
#### 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/' \
Expand All @@ -58,6 +59,25 @@ curl --location 'http://your-server/withings-notification-webhook/' \
--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 in your Fitbit account.
- After the polling period, you should see a message in the configured slack channel saying:
> 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
You can find your userid in the database file:
```
sqlite3 -header -column /path/to/slackhealthbot.db \
Expand Down

0 comments on commit 13fd21d

Please sign in to comment.