During the day, I noticed I was often bogged down with negative thoughts and discouragement. To combat that, I created an automated program that makes use of an agent to send different types of messages to my Garmin smartwatch.
Originally, I wanted to see if I could get access to Garmin’s APIs so that I could trigger a positive affirmation whenever my stress level was high. However, they would not grant my application the permissions needed to write data or alerts to Garmin devices. I had to come up with a workaround that made use of Google’s open APIs.
The main idea is that I would receive affirmations, CCNA facts, language vocabulary, random words, weather anomalies, and fun facts from an agent (OpenAI API). These messages would then be written to a Google Calendar event. The project was first deployed locally using a webhook, then scheduled using Windows Task Scheduler, and finally deployed to a Docker container managed with Docker Desktop.
Here is an outline of what I did, some of the challenges I faced, and a rough overview of how to put something like this together yourself.
The first key point is obtaining the affirmations, random facts, or whatever information you want to generate from the agent. There are a few ways to do this. You can even use Ollama locally, which is what I did at first, and later connect to OpenAI for higher-quality facts, affirmations, and more up-to-date weather anomalies.
To interact with the LLM, I use LangChain mainly for its ability to add context to prompts and its support for prompt templating. For example, I can always pass the current time when requesting a weather anomaly. You can also pass the model you are using directly into LangChain.
llm = Ollama(model="llama3")
llm = ChatOpenAI(
model="gpt-4o",
temperature=0.7
)
To use GPT-4o, you need an API key. This is a good article explaining how to get started with OpenAI API credentials:
You can create and manage your API keys here:
You will also need to create a Google Cloud application and OAuth credentials in order to post calendar events or send email. There are many good tutorials available on creating a Google Cloud project and configuring OAuth tokens. Here’s one that I found helpful:
After setting up the environment, the application sends a prompt to the LLM to generate an affirmation and then posts the result to Google Calendar. The calendar notification is picked up by the smartwatch, which displays the affirmation at a random time. For weather events, the user receives an alert corresponding to when the weather anomaly is expected to occur.
Future Improvements
Feedback score
Docker logs

Leave a Reply