In Part 1, I introduced an app that sends an SMS notification when your Fitbit battery is low. Part 2 covered the Authentication Flow of the process. This post describes how the device status is checked and communicated to the user.
The flow is as follows:
- The CloudWatch Scheduler kicks off a Lambda job that pulls registered users from the DynamoDB table. This information is based to a SNS topic, which in turn…
- …kicks off the Lambda function that obtains the Fitbit device info. The Fitbit api is called, and the resulting message is processed by the Lambda function. The device information is stored in and retrieved from the DynamoDB table as needed for processing and history tracking.
- If the result was a success then the a message is sent to the SNS topic for the subscribed user – assuming that the battery status is low AND the user has not already been notified.
- If a “Token Expired” error is returned, then the Lambda function passes the required information to the Refresh User SNS topic. The Lambda function again calls a Fitbit API; this time to refresh the token.
- If the token is refreshed, then the information is saved to the DynamoDB table and passed to the Get Device Info Topic (starting the process all over again)
- If a failure occurs, then a message is sent to the user, directing them to re-authorize the application to access their Fitbit account.
Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 3”
In Part 1, I introduced an app that sends an SMS notification when your Fitbit battery is low. Part 2 covers the Authentication Flow of the process.
The flow is as follows:
- User accesses the sign-up page (and by default, provides authorization via Fitbit.com). The request is passed through an API Gateway to a Lambda function. The Lambda function calls a Fitbit api to authenticate the user.
- The Fitbit authentication returns to the Lambda code. From there: (3) the token is saved to a DynamoDB database, (4) a message is placed on a SNS topic, and (5) a success response is sent back to the webpage
- The user information (access_token, refresh_token, and mobile number) is saved to a DynamoDB table
- An SNS topic receives the mobile number as a message
- A success message is sent back to the end user.
- The SNS topic (step 4) calls a second Lambda function.
- The Create_User_Topic lambda function creates a sns topic for the newly authenticated user.
- Once the topic is created, a notice is sent to the user’s mobile device – asking to confirm subscription.
- The user confirms the subscription.
Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 2”
A few weeks ago, my Fitbit (one of my new favorite devices) died.
Not died, as in bricked; my battery died.
That was a bit surprising, as I am signed up for low battery notifications. Turns out, I did get a notice – in an email. Problem was, I wasn’t checking my email that day.
The next day, I went back to the Fitbit website to sign-up for SMS notifications; unfortunately, Fitbit doesn’t provide a low battery notification via SMS.
So, I built my own, using a handful of AWS services (Lambda, SNS, API Gateway, and DynamoDB) and exposed Fitbit APIs.
So far, it works well. After subscribing to the service, I got an introductory note telling my my battery status. A few hours later, I received a second notice – letting me know that my battery was low. Continue reading “A Fitbit Low Battery SMS Notification using AWS – Part 1”