Ideally, I would’ve loved to have the entire solution live in the cloud. Amazon Lambda is perfect for the small tasks required in this automation. Unfortunately, a Lambda function would not be able to send data to Baby Connect for two main reasons.
My code uses a Node.js library called nightmare to perform browser automation. Now, in general using external node libraries is possible in a Lambda function. First, you would set up a project folder locally and run
npm install to load the external module. Next, zip the entire thing and upload it as the source of your Lambda function.
As I mentioned, nightmare uses Electron to create a headless browser session. Now, although Electron won’t actually show a browser window, it still requires an X Window display. I got around having to run a full X11 server on my Raspberry Pi by using the X virtual framebuffer (Xvfb) package, and creating a virtual display before launching my node application.
In addition to requiring additional native binaries, this workaround also requires some setup steps before the actual node application code can be executed. Neither of these fit with the way Lambda is designed.