How I Created “DaddyHome” with OpenFaaS and Kubernetes — Part 2 “Adapting to Requirement Changes”

Ken Fukuyama
4 min readMar 7, 2018

--

Introduction

This post is the 2nd part of how I used OpenFaaS with Kubernetes and Rancher to integrate my home assistant with location services and Slack bots.

Overview

I’m assuming you have read the previous post and you know what the “Where’s Daddy” feature does. In this post, I’m going to show how we can adapt to requirement changes by taking advantage of FaaS (Functions as a Service).

  • The Additional Requirement
  • The Instant Message version of “Where’s Daddy”
  • Wrap Up

The Additional Requirement

My Wife’s Requirement

Requirements change. You know it. The initial requirements never end to be the final requirements (I doubt there’s a ‘final requirement’ either). It’s because things change. For example, when I first talked about the concept of “Where’s Daddy”, my wife hardly cared about it. But after I actually made the feature with Google Home, she actually started to show some interest about it. Having a real product and experiencing it changes people’s thoughts and makes imaginations or ideas go a step further. My wife’s requirement was:

  • I want to use “Where’s Daddy” with my Smartphone

Of course something like this requirement would come out sooner or later, because “DaddyHome” was meant to be used by my kids at the first place. They had no means to use smartphones or write text messages — hence I used Google Home.

In order to satisfy my wife’s requirements, I was sure that integrating “DaddyHome” with Instant Messengers would be a great fit. Therefore, I decided to create a LINE Bot (LINE is the most famous Instant Messenger in Japan) to integrate with “Where’s Daddy”. Let’s see how we can put these things together.

The Instant Message version of “Where’s Daddy”

By taking advantage of FaaS, we can add a new Instant Message Interface like the following diagram (the red part is what has been added).

Adding the LINE Interface

The point here is that:

  • We want a function who takes care of LINE webhooks: LINE has a Go SDK to easily handle webhooks and create bots. The line-webhook function takes care of this.
  • We want to use Dialogflow the same way Google Home uses it: Dialogflow has a Node.js SDK to easily integrate with its API. The df-broker function takes advantage of this.

Note how I wasn’t tide to a specific language here and was able to choose the language which handles the use case the best. This is one of the advantages of OpenFaaS, too.

Why separate the functions?
Some of you probably thought “Shouldn’t line-webhook just directly call Dialogflow?”. And yes, that is perfectly possible. But there are benefits in separating the functions. Suppose that requirements change further and:

  • We want to add Facebook Messenger as the interface.
  • We want to add Skype phone calls as the interface.
  • We want to add Alexa as the interface.
  • We want to add X as the interface.

By separating the function, this can be quite easily done by adding a x-webhook function and call the df-broker function. Hence, adding flexibility to the “Where’s Daddy” feature. The following architecture is doable without much difficulty.

Adding Further Interfaces

Note that these changes do not affect the “Find Daddy Service” (the Orange circle in the middle).

Finally, this is what the LINE Bot integration actually looks like.

LINE Bot “Where’s Daddy”

Pretty cool isn’t it? Theoretically, if I want, I can add another third party service by just adding another webhook function.

Wrap up

I hope you got the sense of how FaaS can increase your core service’s flexibility. Your core service isn’t the one who is responsible to adapt to third party service changes. For example, suppose the LINE API got deprecated and you have to migrate to a different version of the API. If you take advantage of FaaS, your core service needs no change. Just update the line-webhook function, and you’re good to go again. No need to touch the “Find Daddy Service”! This is one of the huge advantages of FaaS in my opinion and particularly, OpenFaaS makes this really easy to achieve.

For those who are interested in the code, you can find it from the links below:

This is the end of the post and it concludes the “Where’s Daddy” feature. In the next post, I’m going to integrate Slack Bots with Google Home to be able to talk with my kids via Slack. I’m pretty sure I’m not the only who wants to say some words from their office to their kids before they go to bed. Stay tuned!

--

--

Ken Fukuyama

Front-end Engineer@CYDAS, Inc. OpenFaaS Contributor. Loves Technologies. IaC, DevOps, Containers, Frontend, Backend, BigData.