Avatar

A few months back I had been working on network automation and APIs via DevNet for different technologies and getting certified. I was spending some time exploring Webex Teams, bots, and thinking of use cases for integration. There are some really cool items that can be done for integrations and I began working on some of my custom home monitoring tools, like my garage opener. A Great benefit of using Webex Teams for this was that I didn’t need a separate app on my phone for this.

Then the pandemic happened and life changed – constant news reinforcing our primal fear instincts; groceries in scant supply; schooling issues for our children. I wanted to do something for our team to help keep spirits high.

Using the Webex teams SDK

I realized it would be really easy to create a very simple bot that had a very simple purpose, one positive message for people, every day. It was to be a Webex Teams space without a lot of discussion, just a positive message every day. Using the Webex Teams SDK and a handy Raspberry Pi, this was very easy to get going.

I quickly set up a Webex Teams bot on that Raspberry Pi, created a space, and told a few people about it. A few people invited some other people. Pretty soon we had 50 people and it was officially a “thing”. So I had to take my minimum viable project and improve some of the quotes in the list, which had been scraped from a repository on Github, and was… a good start. It had some cleanup to be done.

This portion of theDailyPositive bot was beneficial to me. While it was a personal project that I did in off hours, picking out good, uplifiting quotes was really positive for keeping mental sanity during this time.

The Daily Positive
The Daily Positive: a Webex Teams bot for good

Over the course of four months this slowly expanded, reaching about 180 employees as of August 2020. But I had begun to experience a few operational challenges in sustaining this on my Raspberry Pi, notably a few hangs (likely due to a few other things I had running on it), and during some network upgrades (to support my new office layouts with kids at home), the Raspberry Pi had a few days where it was down. So whether the Pi just got tired, or had lost connection, there were a few times that the daily positive just did not run. I wasn’t feeling so positive about that.

Time to migrate this to the cloud

As I was doing some side integration work with creating some cloud capabilities for Webex Teams use cases, I had already poked in AWS to get some Teams messaging working. I decided for this project to use Google cloud platform so that I could gain exposure to that platform, for which I had another use case (involving Webex Teams). 

The 2 key GCP functions to bring this to fruition were the Cloud Scheduler (for Cron like scheduling), and cloud functions. Tying these two items together allowed the function to run on a scheduled basis, similar to how my existing setup worked. 

GCP Scheduling of Webex Teams Bot

While the migration was pretty straight forward, as with everything, there were some challenges. These were initially ported into a cloud function in GCP. Some of the initial work done on the raspberry Pi included using the requests library and the Webex teams SDK. These weren’t available in GCP (at the time of writing), so I had to use standard HTTP posts using http library. This was not difficult to do, but required some thought. In addition, the cloud scheduler needed some IAM privileges to access the function. After working through those two items, I had a development room where I validated functionality, and after a few days migrated it to production.

The updated repo for the daily positive is here, containing both the Raspberry Pi code, and the gcp software. https://github.com/will0129/thedailypositive

A nice aspect of this, is the function is extremely lightweight and, with it only running once a day, doesn’t even scratch the surface on pricing. So this makes this migration a very affordable way to ensure that the daily positive can bring a bit of good news … daily … regardless of the state of my Raspberry Pi.

Billing through GCP is basically none for such a lightweight app.
Billing through GCP is basically none for such a lightweight app.

 


We’d love to hear what you think. Ask a question or leave a comment below.
And stay connected with Cisco DevNet on social!

Twitter @CiscoDevNet | Facebook | LinkedIn

Visit the new Developer Video Channel