For the last Hacker Week of 2018 I decided to try out how to use my newly bought Google Home Mini for monitoring our Backend Services. The idea was that google assistant should be giving me voice alerts, informing me about AWS Cloud Watch alarms or failed Jenkins jobs. I also wanted to have the possibility to ask Google Assistant about the number of alarms happening and about their nature.
Google Assistant ->Talk to me:
The first step was to make my google home mini accesible from the outside world. I was setting up a simple nodeJs server on one of our local machines and made it visible to the outside with the help of ngrok
For the routing I used the „express“ and for communicating with google home the „google-home-push“ plugin. It was very easy to set it up and required just a couple of lines of code.
A lambda on AWS, that is triggered by alarms happening in AWS Cloudwatch calls an endpoint of my server through a public URL provided by ngrok. The alarm message is passed as a parameter to the google mini who reads the message out loud.
In a next step I added two more endpoints. One for getting the last emitted alert and another one giving me the number of alerts of the last 24 hours.
So far, Google Assistant has only passively been reading out my alerts -> Time to add some Action(s). With the help of Dialogflow you can create the functionality to make Google Assistant have a conversation with you. When talking to Google Assistant, an „Action“ is analysing the spoken words, trying to identify certain keywords that will trigger an „Intent“. An Intent can provide a static answer, ask a question back to the user or will connect to a „Webhook“ that calls a „Function“, Google’s version of a lambda.
In my case, I created a Function in nodeJs and hosted it on Firebase. The whole procedure is for free, as long as your function is not calling any third third party REST services. In my case, I wanted to communicate with my small server app I had set up, so I opted for a „Pay as you go plan“. I am not worried about the cost as this is only a private Function an the amount of calls to it are minimal and the expenses should stay in the ballpark of a few cents total.
All that was left to do now was to deploy the function on Firebase and to integrate my Action into my Google Home profile (this is literally done by the click of one button).
And in the end:
Having my Function linked to my Google Home profile allows me to invoke it from all of my Google Home and Android devices by saying „OK Google, talk to <my function name>. My Google Home Mini is constantly telling me about AWS alarms and failed Jenkins jobs and I can ask it about the latest alert being triggered or how many alerts happened in the last 24 hours..
Where to go from here:
Playing around with Google Assistant and the Google Home Mini was a lot of fun. Once I figured out how to use Dialogflow (it can be a bit confusing initially ), the development of my Action was straight forward. It is quite mesmerizing to see the power of googles AI in speech analysing and content suggestion.
My current setup forces me to divide my backend logic, using a function hosted on Firebase and a nodeJs server running on a local machine (to be able to push the alarm messages to my Google Home Mini) . This is not an ideal solution and in a next step I would be trying to host all my logic on Firebase.
As for the functionality it could be interesting to be able to tell Google Assistant to react to certain events like „Roll back the latest Deploy“ or „Create a bug ticket on Jira“. With relatively little effort Google Assistant could be used as a powerful tool for monitoring your services and interact with them.