Since we separate Alexa Skill's Lambda function from our implementation of Web Server, when a new voice command was processed by the Alexa Lambda and the puzzle state was updated, the Web Server who's responding to the Arduino about the current state or the next move should be notified and updated as well.
To do this, we will need inter-invocation of two lambda functions which is as easy as a few lines of code shown below.
By using aws-sdk
nodejs package, here is a great example from StackOverflow.
A concrete example in our code base is in slidingPuzzle/lambda/custom/stateHandlers.js
where we update our "Web Server" with the latest puzzle state through invoking that lambda function whose action
paramters is update
, or namely ../prod/puzzle?action=update&toMove=true&startingPos=...
: